Merge pull request #823 from mlaventure/alpine-getlongbit

Fix GetLongBit() returns value when _SC_LONG_BIT is not available
This commit is contained in:
Michael Crosby 2016-05-16 17:15:52 -07:00
commit dd389fd665
1 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,21 @@ package system
/*
#include <unistd.h>
#include <limits.h>
int GetLongBit() {
#ifdef _SC_LONG_BIT
int longbits;
longbits = sysconf(_SC_LONG_BIT);
if (longbits < 0) {
longbits = (CHAR_BIT * sizeof(long));
}
return longbits;
#else
return (CHAR_BIT * sizeof(long));
#endif
}
*/
import "C"
@ -12,5 +27,5 @@ func GetClockTicks() int {
}
func GetLongBit() int {
return int(C.sysconf(C._SC_LONG_BIT))
return int(C.GetLongBit())
}