Debian Codegraph @

server/pse/freebsd.txt

raw
1 /*
2 * Compile and run this as a C program to get the kinfo_proc offsets
3 * for your architecture.
4 * While FreeBSD works hard at binary-compatibility within an ABI, various
5 * we can't say for sure that these are right for _all_ use on a hardware
6 * platform. The LP64 ifdef affects the offsets considerably.
7 *
8 * We use these offsets in hardware-specific files for FreeBSD, to avoid a cgo
9 * compilation-time dependency, allowing us to cross-compile for FreeBSD from
10 * other hardware platforms, letting us distribute binaries for FreeBSD.
11 */
12
13 #include <stddef.h>
14 #include <stdint.h>
15 #include <stdio.h>
16 #include <sys/types.h>
17 #include <sys/user.h>
18
19 #define SHOW_OFFSET(FIELD) printf(" KIP_OFF_%s = %zu\n", #FIELD, offsetof(struct kinfo_proc, ki_ ## FIELD))
20
21 int main(int argc, char *argv[]) {
22 /* Uncomment these if you want some extra debugging aids:
23 SHOW_OFFSET(pid);
24 SHOW_OFFSET(ppid);
25 SHOW_OFFSET(uid);
26 */
27 SHOW_OFFSET(size);
28 SHOW_OFFSET(rssize);
29 SHOW_OFFSET(pctcpu);
30 }