|
49 | 49 | #ifdef TB_CONFIG_OS_HAIKU
|
50 | 50 | # include <image.h>
|
51 | 51 | #endif
|
| 52 | +#ifdef __COSMOPOLITAN__ |
| 53 | +# include <sys/utsname.h> |
| 54 | +#endif |
52 | 55 |
|
53 | 56 | // for uid
|
54 | 57 | #ifndef TB_CONFIG_OS_WINDOWS
|
@@ -958,7 +961,18 @@ static tb_void_t xm_engine_init_host(xm_engine_t* engine)
|
958 | 961 |
|
959 | 962 | // init system host
|
960 | 963 | tb_char_t const* syshost = tb_null;
|
961 |
| -#if defined(TB_CONFIG_OS_WINDOWS) |
| 964 | +#if defined(__COSMOPOLITAN__) |
| 965 | + struct utsname buffer; |
| 966 | + if (uname(&buffer) == 0) |
| 967 | + { |
| 968 | + if (tb_strstr(buffer.sysname, "Darwin")) |
| 969 | + syshost = "macosx"; |
| 970 | + else if (tb_strstr(buffer.sysname, "Linux")) |
| 971 | + syshost = "linux"; |
| 972 | + else if (tb_strstr(buffer.sysname, "Windows")) |
| 973 | + syshost = "windows"; |
| 974 | + } |
| 975 | +#elif defined(TB_CONFIG_OS_WINDOWS) |
962 | 976 | syshost = "windows";
|
963 | 977 | #elif defined(TB_CONFIG_OS_MACOSX)
|
964 | 978 | syshost = "macosx";
|
@@ -1039,7 +1053,22 @@ static tb_void_t xm_engine_init_arch(xm_engine_t* engine)
|
1039 | 1053 |
|
1040 | 1054 | // init system architecture
|
1041 | 1055 | tb_char_t const* sysarch = tb_null;
|
1042 |
| -#if defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX) |
| 1056 | +#if defined(__COSMOPOLITAN__) |
| 1057 | + struct utsname buffer; |
| 1058 | + if (uname(&buffer) == 0) |
| 1059 | + { |
| 1060 | + sysarch = buffer.machine; |
| 1061 | + if (tb_strstr(buffer.sysname, "Windows")) |
| 1062 | + { |
| 1063 | + if (!tb_strcmp(buffer.machine, "x86_64")) |
| 1064 | + sysarch = "x64"; |
| 1065 | + else if (!tb_strcmp(buffer.machine, "i686") || !tb_strcmp(buffer.machine, "i386")) |
| 1066 | + sysarch = "x86"; |
| 1067 | + } |
| 1068 | + else if (!tb_strcmp(buffer.machine, "aarch64")) |
| 1069 | + sysarch = "arm64"; |
| 1070 | + } |
| 1071 | +#elif defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX) |
1043 | 1072 | // the GetNativeSystemInfo function type
|
1044 | 1073 | typedef void (WINAPI *GetNativeSystemInfo_t)(LPSYSTEM_INFO);
|
1045 | 1074 |
|
|
0 commit comments