FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / freebsd / osrel.c
blob7d3cbede01ca27059c859e5aa9c7f6eb1d7e417a
1 #include <unistd.h>
2 #include <sys/types.h>
3 #include <sys/sysctl.h>
4 #include <stdio.h>
5 #include <sys/param.h>
7 int main(void)
9 u_int32_t osrel;
10 int name[4];
11 name[0] = CTL_KERN;
12 name[1] = KERN_PROC;
13 name[2] = KERN_PROC_OSREL;
14 name[3] = getpid();
15 size_t newlen = sizeof(osrel);
16 sysctl(name, 4, &osrel, &newlen, NULL, 0U);
18 // this doesn't change much for each release
19 u_int32_t shortProcOsrel = osrel/1000;
20 // this changes with each patch, see https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions.html
21 u_int32_t shortSysparamOsrel = __FreeBSD_version/1000;
23 if (shortProcOsrel == shortSysparamOsrel)
25 printf("OK osrel values match\n");
27 else
29 printf("FAIL osrel values different (kernel proc %u compiler %u)\n", shortProcOsrel, shortSysparamOsrel);