Workaround for compilation on OpenBSD 5.6
On OpenBSD 5.6 sys/ucred.h uses NGROUP define, but misses include to sys/param.h in which NGROUP is defined. sys/ucred.h is included in sys/mount.h which we need to get the cached ram. Because of this include chain our compilation will fail with missing NGROUP define. This can be resolved by including in our code (and in correct order) system headers.
This commit is contained in:
parent
d516985146
commit
c052f58eab
@ -72,6 +72,9 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
message(STATUS "OpenBSD detected")
|
||||
message(WARNING "OpenBSD is still experimental!")
|
||||
set(METER_SOURCES "openbsd/memory.cc" "openbsd/cpu.cc" "openbsd/load.cc")
|
||||
if(CMAKE_SYSTEM_VERSION VERSION_LESS 5.7)
|
||||
add_definitions(-DOPENBSD_WORKAROUND=1)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Cannot be compiled on this system")
|
||||
endif()
|
||||
|
@ -18,9 +18,22 @@
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
// Ugly fix to compilation on OpenBSD 5.6
|
||||
// these need to be before include sys/mount.h
|
||||
// and be in this exact order. Otherwise compiling on
|
||||
// OpenBSD 5.6 will fail with missing NGROUPS define
|
||||
// or missing gid_t typedefs
|
||||
#ifdef OPENBSD_WORKAROUND
|
||||
#include <sys/types.h> // typedefs
|
||||
#include <sys/param.h> // missing NGROUPS
|
||||
#include <sys/ucred.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <sys/mount.h> // VFS_* which we use to get cache
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/vmmeter.h> // vmtotal struct
|
||||
|
||||
#include "error.h"
|
||||
|
Loading…
Reference in New Issue
Block a user