1
2
3
4
5 package oshi.jna.platform.unix;
6
7 import java.nio.ByteBuffer;
8
9 import com.sun.jna.Native;
10
11 import oshi.util.FileUtil;
12
13
14
15
16
17 public interface AixLibc extends CLibrary {
18
19 AixLibc INSTANCE = Native.load("c", AixLibc.class);
20
21 int PRCLSZ = 8;
22 int PRFNSZ = 16;
23 int PRARGSZ = 80;
24
25 class AixPsInfo {
26 public int pr_flag;
27 public int pr_flag2;
28 public int pr_nlwp;
29 public int pr__pad1;
30 public long pr_uid;
31 public long pr_euid;
32 public long pr_gid;
33 public long pr_egid;
34 public long pr_pid;
35 public long pr_ppid;
36 public long pr_pgid;
37 public long pr_sid;
38 public long pr_ttydev;
39 public long pr_addr;
40 public long pr_size;
41 public long pr_rssize;
42 public Timestruc pr_start;
43 public Timestruc pr_time;
44 public short pr_cid;
45 public short pr__pad2;
46 public int pr_argc;
47 public long pr_argv;
48 public long pr_envp;
49 public byte[] pr_fname = new byte[PRFNSZ];
50 public byte[] pr_psargs = new byte[PRARGSZ];
51 public long[] pr__pad = new long[8];
52 public AixLwpsInfo pr_lwp;
53
54 public AixPsInfo(ByteBuffer buff) {
55 this.pr_flag = FileUtil.readIntFromBuffer(buff);
56 this.pr_flag2 = FileUtil.readIntFromBuffer(buff);
57 this.pr_nlwp = FileUtil.readIntFromBuffer(buff);
58 this.pr__pad1 = FileUtil.readIntFromBuffer(buff);
59 this.pr_uid = FileUtil.readLongFromBuffer(buff);
60 this.pr_euid = FileUtil.readLongFromBuffer(buff);
61 this.pr_gid = FileUtil.readLongFromBuffer(buff);
62 this.pr_egid = FileUtil.readLongFromBuffer(buff);
63 this.pr_pid = FileUtil.readLongFromBuffer(buff);
64 this.pr_ppid = FileUtil.readLongFromBuffer(buff);
65 this.pr_pgid = FileUtil.readLongFromBuffer(buff);
66 this.pr_sid = FileUtil.readLongFromBuffer(buff);
67 this.pr_ttydev = FileUtil.readLongFromBuffer(buff);
68 this.pr_addr = FileUtil.readLongFromBuffer(buff);
69 this.pr_size = FileUtil.readLongFromBuffer(buff);
70 this.pr_rssize = FileUtil.readLongFromBuffer(buff);
71 this.pr_start = new Timestruc(buff);
72 this.pr_time = new Timestruc(buff);
73 this.pr_cid = FileUtil.readShortFromBuffer(buff);
74 this.pr__pad2 = FileUtil.readShortFromBuffer(buff);
75 this.pr_argc = FileUtil.readIntFromBuffer(buff);
76 this.pr_argv = FileUtil.readLongFromBuffer(buff);
77 this.pr_envp = FileUtil.readLongFromBuffer(buff);
78 FileUtil.readByteArrayFromBuffer(buff, this.pr_fname);
79 FileUtil.readByteArrayFromBuffer(buff, this.pr_psargs);
80 for (int i = 0; i < pr__pad.length; i++) {
81 this.pr__pad[i] = FileUtil.readLongFromBuffer(buff);
82 }
83 this.pr_lwp = new AixLwpsInfo(buff);
84 }
85
86 }
87
88 class AixLwpsInfo {
89 public long pr_lwpid;
90 public long pr_addr;
91 public long pr_wchan;
92 public int pr_flag;
93 public byte pr_wtype;
94 public byte pr_state;
95 public byte pr_sname;
96 public byte pr_nice;
97 public int pr_pri;
98 public int pr_policy;
99 public byte[] pr_clname = new byte[PRCLSZ];
100 public int pr_onpro;
101 public int pr_bindpro;
102
103 public AixLwpsInfo(ByteBuffer buff) {
104 this.pr_lwpid = FileUtil.readLongFromBuffer(buff);
105 this.pr_addr = FileUtil.readLongFromBuffer(buff);
106 this.pr_wchan = FileUtil.readLongFromBuffer(buff);
107 this.pr_flag = FileUtil.readIntFromBuffer(buff);
108 this.pr_wtype = FileUtil.readByteFromBuffer(buff);
109 this.pr_state = FileUtil.readByteFromBuffer(buff);
110 this.pr_sname = FileUtil.readByteFromBuffer(buff);
111 this.pr_nice = FileUtil.readByteFromBuffer(buff);
112 this.pr_pri = FileUtil.readIntFromBuffer(buff);
113 this.pr_policy = FileUtil.readIntFromBuffer(buff);
114 FileUtil.readByteArrayFromBuffer(buff, this.pr_clname);
115 this.pr_onpro = FileUtil.readIntFromBuffer(buff);
116 this.pr_bindpro = FileUtil.readIntFromBuffer(buff);
117 }
118 }
119
120
121
122
123 class Timestruc {
124 public long tv_sec;
125 public int tv_nsec;
126 public int pad;
127
128 public Timestruc(ByteBuffer buff) {
129 this.tv_sec = FileUtil.readLongFromBuffer(buff);
130 this.tv_nsec = FileUtil.readIntFromBuffer(buff);
131 this.pad = FileUtil.readIntFromBuffer(buff);
132 }
133 }
134
135
136
137
138
139
140 int thread_self();
141 }