From 10a3c26c9a48adcdf507303eb2e256b664bd84e5 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Fri, 13 May 2016 09:37:58 -0700 Subject: [PATCH] Fix GetLongBit() returns value when _SC_LONG_BIT is not available Signed-off-by: Kenfe-Mickael Laventure --- libcontainer/system/sysconfig.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libcontainer/system/sysconfig.go b/libcontainer/system/sysconfig.go index 3e3d7e01e..4fba6c2b7 100644 --- a/libcontainer/system/sysconfig.go +++ b/libcontainer/system/sysconfig.go @@ -4,6 +4,21 @@ package system /* #include +#include + +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()) }