Fix GetLongBit() returns value when _SC_LONG_BIT is not available

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure
2016-05-13 09:37:58 -07:00
parent c6a791bef9
commit 10a3c26c9a
+16 -1
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())
}