Open anbe42 opened 10 years ago
On FreeBSD off_t
is always int64_t
and the variables are like this (note no _POSIX prefix):
#define _V6_ILP32_OFF32 -1
#define _V6_ILP32_OFFBIG 0
#define _V6_LP64_OFF64 0
#define _V6_LPBIG_OFFBIG -1
POSIX says -1 means unsupported and 0 means might be supported. I guess you could deduce that in all possibly supported configurations off_t
is 64-bit, but that's complicated.
Instead, I suggest using a simpler test like, at least for syspovconfig_bsd.h
:
#include <limits.h>
#ifdef OFF_MAX
#if OFF_MAX >= 0x7fffffffffffffffLL
// off_t is at least 64 bits
#else
// off_t is 32 bits
#endif
#else
// Unable to detect
#endif
#if LONG_MAX >= 0x7fffffffffffffffLL
// long is at least 64 bits.
#define POV_LONG long
#else
// long is 32 bits.
#define POV_LONG long long
#endif
The master branch now uses _POSIX_V6_LP64OFF64 and friends in vfe/unix/syspovconfig*.h to define the 64bit POV_LONG as either long and long long.
Checking only for defined(_POSIX_V6_LP64_OFF64) is not correct - platforms like armhf define this to -1 (see /usr/include/arm-linux-gnueabihf/bits/environments.h [Debian armhf]). On the other hand these macros are not defined if it is possible to have different environments on a platform and sysconf can be used to query the actual value (see /usr/include/x86_64-linux-gnu/bits/environments.h [Debian amd64]). So using (defined(_POSIX_V6_LP64_OFF64) && _POSIX_V6_LP64_OFF64 > 0) (probably needed for all POSIX* variables) might be a start to solve this issue.
Anyway, there should be a test at compile time that triggers an error if POV_LONG is not a 64bit type ... otherwise you run into spurious segfaults later on.