3 #include <sys/sysctl.h>
13 name
[2] = KERN_PROC_OSREL
;
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");
29 printf("FAIL osrel values different (kernel proc %u compiler %u)\n", shortProcOsrel
, shortSysparamOsrel
);