File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 55 */
66
77#include "premake.h"
8+ #if defined(PLATFORM_MACOSX ) || defined(PLATFORM_BSD ) || defined(PLATFORM_LINUX ) || defined(PLATFORM_SOLARIS ) || defined(PLATFORM_HURD ) || defined(PLATFORM_HAIKU ) || defined(PLATFORM_COSMO )
9+
10+ #if !defined(HAVE_UNAME )
11+ #define HAVE_UNAME 1
12+ #endif
13+ #include <sys/utsname.h>
14+ #include <string.h>
15+
16+ #else
17+
18+ #define HAVE_UNAME 0
19+
20+ #endif
821
922int os_is64bit (lua_State * L )
1023{
@@ -24,6 +37,30 @@ int os_is64bit(lua_State* L)
2437 }
2538 }
2639#endif
40+ #if HAVE_UNAME
41+ struct utsname data ;
42+ if (uname (& data ) >= 0 )
43+ {
44+ // Non-exhaustive list of 64bit architectures reported by uname -m
45+ static const char * knownArchitectures [] = {
46+ "x86_64" , "adm64" ,
47+ "arm64" , "aarch64" ,
48+ "ppc64" , "ppc64le" ,
49+ "s390x" ,
50+ "mips64" , "mips64el" ,
51+ "riscv64" ,
52+ "longarch64"
53+ };
54+ for (size_t a = 0 ; a < (sizeof (knownArchitectures ) / sizeof (const char * )); ++ a )
55+ {
56+ if (strcmp (data .machine , knownArchitectures [a ]) == 0 )
57+ {
58+ lua_pushboolean (L , 1 );
59+ return 1 ;
60+ }
61+ }
62+ }
63+ #endif
2764
2865 lua_pushboolean (L , 0 );
2966 return 1 ;
You can’t perform that action at this time.
0 commit comments