1
1
/*
2
- * Copyright (c) 2015 Daniel Widdis
2
+ * Copyright (c) 2015 Daniel Widdis
3
3
*
4
4
* This program is free software: you can redistribute it and/or modify
5
5
* it under the terms of the GNU Lesser General Public License as published by
33
33
*/
34
34
public interface SystemB extends Library {
35
35
36
- public static SystemB INSTANCE = (SystemB ) Native .loadLibrary ("System" ,
37
- SystemB .class );
36
+ SystemB INSTANCE = Native .loadLibrary ("System" , SystemB .class );
38
37
39
38
// host_statistics()
40
- static int HOST_LOAD_INFO = 1 ;// System loading stats
41
- static int HOST_VM_INFO = 2 ; // Virtual memory stats
42
- static int HOST_CPU_LOAD_INFO = 3 ;// CPU load stats
39
+ int HOST_LOAD_INFO = 1 ;// System loading stats
40
+ int HOST_VM_INFO = 2 ; // Virtual memory stats
41
+ int HOST_CPU_LOAD_INFO = 3 ;// CPU load stats
43
42
44
43
// host_statistics64()
45
- static int HOST_VM_INFO64 = 4 ; // 64-bit virtual memory stats
44
+ int HOST_VM_INFO64 = 4 ; // 64-bit virtual memory stats
46
45
47
46
// host_cpu_load_info()
48
- static int CPU_STATE_MAX = 4 ;
49
- static int CPU_STATE_USER = 0 ;
50
- static int CPU_STATE_SYSTEM = 1 ;
51
- static int CPU_STATE_IDLE = 2 ;
52
- static int CPU_STATE_NICE = 3 ;
47
+ int CPU_STATE_MAX = 4 ;
48
+ int CPU_STATE_USER = 0 ;
49
+ int CPU_STATE_SYSTEM = 1 ;
50
+ int CPU_STATE_IDLE = 2 ;
51
+ int CPU_STATE_NICE = 3 ;
53
52
54
53
// host_processor_info() flavor
55
- static int PROCESSOR_BASIC_INFO = 1 ;
56
- static int PROCESSOR_CPU_LOAD_INFO = 2 ;
54
+ int PROCESSOR_BASIC_INFO = 1 ;
55
+ int PROCESSOR_CPU_LOAD_INFO = 2 ;
57
56
58
57
// Data size
59
- static int UINT64_SIZE = Native .getNativeSize (long .class );
60
- static int INT_SIZE = Native .getNativeSize (int .class );
58
+ int UINT64_SIZE = Native .getNativeSize (long .class );
59
+ int INT_SIZE = Native .getNativeSize (int .class );
61
60
62
61
public static class HostCpuLoadInfo extends Structure {
63
62
public int cpu_ticks [] = new int [CPU_STATE_MAX ];
64
-
63
+
64
+ @ Override
65
65
protected List <String > getFieldOrder () {
66
- return Arrays .asList (new String [] { "cpu_ticks" } );
66
+ return Arrays .asList ("cpu_ticks" );
67
67
}
68
68
}
69
69
70
70
public static class HostLoadInfo extends Structure {
71
71
public int [] avenrun = new int [3 ]; // scaled by LOAD_SCALE
72
72
public int [] mach_factor = new int [3 ]; // scaled by LOAD_SCALE
73
-
73
+
74
+ @ Override
74
75
protected List <String > getFieldOrder () {
75
- return Arrays .asList (new String [] { "avenrun" , "mach_factor" } );
76
+ return Arrays .asList ("avenrun" , "mach_factor" );
76
77
}
77
78
}
78
79
@@ -94,12 +95,13 @@ public static class VMStatistics extends Structure {
94
95
// # of pages speculative (included in free_count)
95
96
public int speculative_count ;
96
97
98
+ @ Override
97
99
protected List <String > getFieldOrder () {
98
- return Arrays .asList (new String [] { "free_count" , "active_count" ,
99
- "inactive_count" , "wire_count" , "zero_fill_count" ,
100
- "reactivations" , "pageins" , "pageouts" , "faults" ,
101
- "cow_faults" , "lookups" , "hits" , "purgeable_count" ,
102
- "purges" , "speculative_count" } );
100
+ return Arrays .asList ("free_count" , "active_count" ,
101
+ "inactive_count" , "wire_count" , "zero_fill_count" ,
102
+ "reactivations" , "pageins" , "pageouts" , "faults" ,
103
+ "cow_faults" , "lookups" , "hits" , "purgeable_count" ,
104
+ "purges" , "speculative_count" );
103
105
}
104
106
}
105
107
@@ -137,34 +139,34 @@ public static class VMStatistics64 extends Structure {
137
139
138
140
@ Override
139
141
protected List <String > getFieldOrder () {
140
- return Arrays .asList (new String [] { "free_count" , "active_count" ,
141
- "inactive_count" , "wire_count" ,
142
- "zero_fill_count" , "reactivations" ,
143
- "pageins" , "pageouts" ,
144
- "faults" , "cow_faults" ,
145
- "lookups" , "hits" ,
146
- "purges" ,
147
- "purgeable_count" , "speculative_count" ,
148
- "decompressions" , "compressions" ,
149
- "swapins" , "swapouts" ,
150
- "compressor_page_count" , "throttled_count" ,
151
- "external_page_count" , "internal_page_count" ,
152
- "total_uncompressed_pages_in_compressor" } );
142
+ return Arrays .asList ("free_count" , "active_count" ,
143
+ "inactive_count" , "wire_count" ,
144
+ "zero_fill_count" , "reactivations" ,
145
+ "pageins" , "pageouts" ,
146
+ "faults" , "cow_faults" ,
147
+ "lookups" , "hits" ,
148
+ "purges" ,
149
+ "purgeable_count" , "speculative_count" ,
150
+ "decompressions" , "compressions" ,
151
+ "swapins" , "swapouts" ,
152
+ "compressor_page_count" , "throttled_count" ,
153
+ "external_page_count" , "internal_page_count" ,
154
+ "total_uncompressed_pages_in_compressor" );
153
155
}
154
156
}
155
157
156
158
/**
157
159
* The mach_host_self system call returns the calling thread's host name
158
160
* port. It has an effect equivalent to receiving a send right for the host
159
161
* port.
160
- *
162
+ *
161
163
* @return the host's name port
162
164
*/
163
165
int mach_host_self ();
164
166
165
167
/**
166
168
* The host_page_size function returns the page size for the given host.
167
- *
169
+ *
168
170
* @param machPort
169
171
* The name (or control) port for the host for which the page
170
172
* size is desired.
@@ -177,7 +179,7 @@ protected List<String> getFieldOrder() {
177
179
/**
178
180
* The host_statistics function returns scheduling and virtual memory
179
181
* statistics concerning the host as specified by hostStat.
180
- *
182
+ *
181
183
* @param machPort
182
184
* The control port for the host for which information is to be
183
185
* obtained.
@@ -191,13 +193,12 @@ protected List<String> getFieldOrder() {
191
193
* returned (in natural-sized units).
192
194
* @return 0 on success; sets errno on failure
193
195
*/
194
- int host_statistics (int machPort , int hostStat , Structure stats ,
195
- IntByReference count );
196
+ int host_statistics (int machPort , int hostStat , Structure stats , IntByReference count );
196
197
197
198
/**
198
199
* The host_statistics64 function returns 64-bit virtual memory statistics
199
200
* concerning the host as specified by hostStat.
200
- *
201
+ *
201
202
* @param machPort
202
203
* The control port for the host for which information is to be
203
204
* obtained.
@@ -210,17 +211,16 @@ int host_statistics(int machPort, int hostStat, Structure stats,
210
211
* returned (in natural-sized units).
211
212
* @return 0 on success; sets errno on failure
212
213
*/
213
- int host_statistics64 (int machPort , int hostStat , Structure stats ,
214
- IntByReference count );
214
+ int host_statistics64 (int machPort , int hostStat , Structure stats , IntByReference count );
215
215
216
216
/**
217
217
* The sysctl() function retrieves system information and allows processes
218
218
* with appropriate privileges to set system information. The information
219
219
* available from sysctl() consists of integers, strings, and tables.
220
- *
220
+ *
221
221
* The state is described using a "Management Information Base" (MIB) style
222
222
* name, listed in name, which is a namelen length array of integers.
223
- *
223
+ *
224
224
* The information is copied into the buffer specified by oldp. The size of
225
225
* the buffer is given by the location specified by oldlenp before the call,
226
226
* and that location gives the amount of data copied after a successful call
@@ -229,18 +229,18 @@ int host_statistics64(int machPort, int hostStat, Structure stats,
229
229
* call supplies as much data as fits in the buffer provided and returns
230
230
* with the error code ENOMEM. If the old value is not desired, oldp and
231
231
* oldlenp should be set to NULL.
232
- *
232
+ *
233
233
* The size of the available data can be determined by calling sysctl() with
234
234
* the NULL argument for oldp. The size of the available data will be
235
235
* returned in the location pointed to by oldlenp. For some operations, the
236
236
* amount of space may change often. For these operations, the system
237
237
* attempts to round up so that the returned size is large enough for a call
238
238
* to return the data shortly thereafter.
239
- *
239
+ *
240
240
* To set a new value, newp is set to point to a buffer of length newlen
241
241
* from which the requested value is to be taken. If a new value is not to
242
242
* be set, newp should be set to NULL and newlen set to 0.
243
- *
243
+ *
244
244
* @param name
245
245
* MIB array of integers
246
246
* @param namelen
@@ -262,7 +262,7 @@ int sysctl(int[] name, int namelen, Pointer oldp, IntByReference oldlenp,
262
262
* The sysctlbyname() function accepts an ASCII representation of the name
263
263
* and internally looks up the integer name vector. Apart from that, it
264
264
* behaves the same as the standard sysctl() function.
265
- *
265
+ *
266
266
* @param name
267
267
* ASCII representation of the MIB name
268
268
* @param oldp
@@ -290,15 +290,15 @@ int sysctlbyname(String name, Pointer oldp, IntByReference oldlenp,
290
290
* to repeatedly request the same variable (the sysctl() function runs in
291
291
* about a third the time as the same request made via the sysctlbyname()
292
292
* function).
293
- *
293
+ *
294
294
* The number of elements in the mib array can be determined by calling
295
295
* sysctlnametomib() with the NULL argument for mibp.
296
- *
296
+ *
297
297
* The sysctlnametomib() function is also useful for fetching mib prefixes.
298
298
* If size on input is greater than the number of elements written, the
299
299
* array still contains the additional elements which may be written
300
300
* programmatically.
301
- *
301
+ *
302
302
* @param name
303
303
* ASCII representation of the name
304
304
* @param mibp
@@ -309,10 +309,10 @@ int sysctlbyname(String name, Pointer oldp, IntByReference oldlenp,
309
309
* @return 0 on success; sets errno on failure
310
310
*/
311
311
int sysctlnametomib (String name , Pointer mibp , IntByReference size );
312
-
312
+
313
313
/**
314
314
* The host_processor_info function returns information about processors.
315
- *
315
+ *
316
316
* @param machPort
317
317
* The control port for the host for which information is to be
318
318
* obtained.
0 commit comments