Merge pull request #823 from mlaventure/alpine-getlongbit
Fix GetLongBit() returns value when _SC_LONG_BIT is not available
This commit is contained in:
commit
dd389fd665
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue