1
2
3
4
5 package oshi.jna.platform.unix;
6
7 import com.sun.jna.Memory;
8 import com.sun.jna.Native;
9 import com.sun.jna.Pointer;
10 import com.sun.jna.Structure;
11 import com.sun.jna.Structure.FieldOrder;
12 import com.sun.jna.ptr.NativeLongByReference;
13
14
15
16
17
18 public interface FreeBsdLibc extends CLibrary {
19 FreeBsdLibc INSTANCE = Native.load("libc", FreeBsdLibc.class);
20
21 int UTX_USERSIZE = 32;
22 int UTX_LINESIZE = 16;
23 int UTX_IDSIZE = 8;
24 int UTX_HOSTSIZE = 128;
25
26
27
28
29 @FieldOrder({ "ut_type", "ut_tv", "ut_id", "ut_pid", "ut_user", "ut_line", "ut_host", "ut_spare" })
30 class FreeBsdUtmpx extends Structure {
31 public short ut_type;
32 public Timeval ut_tv;
33 public byte[] ut_id = new byte[UTX_IDSIZE];
34 public int ut_pid;
35 public byte[] ut_user = new byte[UTX_USERSIZE];
36 public byte[] ut_line = new byte[UTX_LINESIZE];
37 public byte[] ut_host = new byte[UTX_HOSTSIZE];
38 public byte[] ut_spare = new byte[64];
39 }
40
41
42
43
44
45 int UINT64_SIZE = Native.getNativeSize(long.class);
46
47 int INT_SIZE = Native.getNativeSize(int.class);
48
49
50
51
52
53 int CPUSTATES = 5;
54
55 int CP_USER = 0;
56
57 int CP_NICE = 1;
58
59 int CP_SYS = 2;
60
61 int CP_INTR = 3;
62
63 int CP_IDLE = 4;
64
65
66
67
68 @FieldOrder({ "tv_sec", "tv_usec" })
69 class Timeval extends Structure {
70 public long tv_sec;
71 public long tv_usec;
72 }
73
74
75
76
77 @FieldOrder({ "cpu_ticks" })
78 class CpTime extends Structure implements AutoCloseable {
79 public long[] cpu_ticks = new long[CPUSTATES];
80
81 @Override
82 public void close() {
83 Pointer p = this.getPointer();
84 if (p instanceof Memory) {
85 ((Memory) p).close();
86 }
87 }
88 }
89
90
91
92
93
94
95
96
97
98 FreeBsdUtmpx getutxent();
99
100
101
102
103
104
105
106
107
108 int thr_self(NativeLongByReference id);
109 }