summaryrefslogtreecommitdiff
path: root/src/platform-headers.h
blob: dc3a4baeac363c0b6bfccd917d5373504087916e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*--------------------------------------------------------------------
 * Copyright © 2016 James Hunt <jamesodhunt@ubuntu.com>.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *--------------------------------------------------------------------
 */

/*--------------------------------------------------------------------
 * Description: This file contains platform-specific system includes
 *--------------------------------------------------------------------
 */

#ifndef _PROCENV_PLATFORM_HEADERS_H
#define _PROCENV_PLATFORM_HEADERS_H

/*------------------------------------------------------------------*/

#if defined (PROCENV_PLATFORM_DARWIN)

#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <sys/statvfs.h>
#include <sys/ucred.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <pthread.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <sys/sysctl.h>

#define	PROCENV_LINK_LEVEL_FAMILY  AF_LINK
#define PROCENV_CPU_TYPE           int

/* XXX: fake value as cpu set are not available on darwin */
#define PROCENV_CPU_SET_TYPE       void

#define PROCENV_MNT_GET_FLAGS(mnt) (mnt)->f_flags
#define PROCENV_MNT_GET_FSID(mnt)  (mnt)->f_fsid.val

#define PROCENV_STATFS_INT_TYPE    uint64_t
#define PROCENV_STATFS_INT_FMT     PRIu64

typedef struct statfs procenv_mnt_type;

#endif /* PROCENV_PLATFORM_DARWIN*/

/*------------------------------------------------------------------*/

/* XXX: for now, let's assume "unknown" is similar to Linux :-) */
#if defined (PROCENV_PLATFORM_LINUX) || defined (PROCENV_PLATFORM_GENERIC)

#include <sys/statvfs.h>
#include <sys/vfs.h>
#include <mntent.h>
#include <sched.h>
#include <link.h>

#include <linux/if.h>

#include <sys/inotify.h>
#include <sys/prctl.h>
#include <sys/personality.h>
#include <sys/syscall.h>

#ifndef _SYS_PRCTL_H
#include <linux/prctl.h>
#endif

#include <linux/version.h>

/* Lucid provides prctl.h, but not securebits.h */
#if defined (PR_GET_SECUREBITS) && defined (HAVE_LINUX_SECUREBITS_H)
#include <linux/securebits.h>
#endif

#include <linux/capability.h>
#include <linux/vt.h>

#if defined (HAVE_SYS_APPARMOR_H)
#include <sys/apparmor.h>
#endif

#if defined (HAVE_SELINUX_SELINUX_H)
#include <selinux/selinux.h>
#endif

#if defined (HAVE_SYS_CAPABILITY_H)
#include <sys/capability.h>
#endif

#if defined (__GLIBC__)
#include <sys/sysmacros.h>
#endif

/* Network family for entries containing link-level interface
 * details. These entries will be cached to allow MAC addresses
 * to be extracted from them when displaying the corresponding
 * higher-level network family entries for the interface in
 * question.
 */
#define PROCENV_LINK_LEVEL_FAMILY  AF_PACKET
#define PROCENV_PTHREAD_GUARD_SIZE_TYPE  size_t
#define PROCENV_PTHREAD_GUARD_SIZE_FMT   "%lu"

#define PROCENV_CPU_SET_TYPE       cpu_set_t
#define PROCENV_CPU_TYPE           int

#endif /* PROCENV_PLATFORM_LINUX || PROCENV_PLATFORM_GENERIC */

/*------------------------------------------------------------------*/

#if defined (PROCENV_PLATFORM_MINIX)

#include <sched.h>
#include <sys/mount.h>
#include <sys/fstypes.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/statvfs.h>
#include <sys/ucred.h>
#include <net/if.h>
#include <netinet/in.h>
#include <kvm.h>
#include <link.h>

#define	PROCENV_LINK_LEVEL_FAMILY        AF_LINK
#define PROCENV_PTHREAD_GUARD_SIZE_TYPE  int
#define PROCENV_PTHREAD_GUARD_SIZE_FMT   "%u"
#define PROCENV_CPU_TYPE                 cpuid_t
#define PROCENV_CPU_SET_TYPE             cpuset_t
#define PROCENV_MNT_GET_FLAGS(mnt)       (mnt)->f_flag
#define PROCENV_MNT_GET_FSID(mnt)        (mnt)->f_fsidx.__fsid_val

#define PROCENV_STATFS_INT_TYPE    uint64_t
#define PROCENV_STATFS_INT_FMT     PRIu64

typedef struct statvfs procenv_mnt_type;

#endif /* PROCENV_PLATFORM_MINIX */

/*------------------------------------------------------------------*/

#if defined (PROCENV_PLATFORM_FREEBSD)

#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <sys/statvfs.h>
#include <sys/ucred.h>
#include <sys/consio.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <kvm.h>
#include <pthread_np.h>
#include <link.h>

#define	PROCENV_LINK_LEVEL_FAMILY  AF_LINK
#define PROCENV_CPU_TYPE           int
#define PROCENV_CPU_SET_TYPE       cpuset_t
#define PROCENV_MNT_GET_FLAGS(mnt) (mnt)->f_flags
#define PROCENV_MNT_GET_FSID(mnt)  (mnt)->f_fsid.val

#define PROCENV_STATFS_INT_TYPE    uint64_t
#define PROCENV_STATFS_INT_FMT     PRIu64

typedef struct statfs procenv_mnt_type;

#endif /* PROCENV_PLATFORM_FREEBSD*/

/*------------------------------------------------------------------*/

#if defined (PROCENV_PLATFORM_NETBSD)

/* Required to access "struct kinfo_proc" (from sys/sysctl.h) */
#ifndef _KMEMUSER
#define _KMEMUSER
#endif

#include <sched.h>
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/statvfs.h>
#include <sys/ucred.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <kvm.h>
#include <dev/wscons/wsdisplay_usl_io.h>
#include <link.h>

#define	PROCENV_LINK_LEVEL_FAMILY  AF_LINK
#define PROCENV_CPU_TYPE           cpuid_t
#define PROCENV_CPU_SET_TYPE       cpuset_t
#define PROCENV_MNT_GET_FLAGS(mnt) (mnt)->f_flag
#define PROCENV_MNT_GET_FSID(mnt)  (mnt)->f_fsidx.__fsid_val

#define PROCENV_STATFS_INT_TYPE    uint64_t
#define PROCENV_STATFS_INT_FMT     PRIu64

typedef struct statvfs procenv_mnt_type;

#endif /* PROCENV_PLATFORM_NETBSD */

/*------------------------------------------------------------------*/

#if defined (PROCENV_PLATFORM_OPENBSD)

#include <sched.h>
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/proc.h>

#include <sys/statvfs.h>
#include <sys/ucred.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <kvm.h>
#include <dev/wscons/wsdisplay_usl_io.h>
#include <link.h>

#define	PROCENV_LINK_LEVEL_FAMILY  AF_LINK
#define PROCENV_CPU_TYPE           cpuid_t
#define PROCENV_CPU_SET_TYPE       struct cpuset
#define PROCENV_MNT_GET_FLAGS(mnt) (mnt)->f_flags
#define PROCENV_MNT_GET_FSID(mnt)  (mnt)->f_fsid.val

#define PROCENV_STATFS_INT_TYPE    uint64_t
#define PROCENV_STATFS_INT_FMT     PRIu64

typedef struct statfs procenv_mnt_type;

#endif /* PROCENV_PLATFORM_OPENBSD */

/*------------------------------------------------------------------*/

#if defined (PROCENV_PLATFORM_HURD)

#include <mntent.h>
#include <sys/vfs.h>
#include <sys/statvfs.h>
#include <net/if.h>
#include <link.h>

#if defined (HAVE_SYS_CAPABILITY_H)
#include <sys/capability.h>
#endif

#define PROCENV_CPU_TYPE     int
#define PROCENV_CPU_SET_TYPE cpu_set_t

#endif /* PROCENV_PLATFORM_HURD */

/*------------------------------------------------------------------*/

#if defined (PROCENV_PLATFORM_GENERIC)

/* XXX: see above */

#endif /* PROCENV_PLATFORM_GENERIC */

/*------------------------------------------------------------------*/

#endif /* _PROCENV_PLATFORM_HEADERS_H */

/*------------------------------------------------------------------*/