浏览代码

Small platform detection/usage improvements (#346)

* Use BX_PLATFORM_POSIX where needed

The semaphone implementation already uses BX_PLATFORM_POSIX to include
<pthread.h> on all the POSIX platforms; do the same also in other places
for consistency. This is done also for <sched.h>, which is a POSIX API,
and sched_yield() from it is already guarded by BX_PLATFORM_POSIX.

* Drop support for GNU libc older than 2.12

glibc 2.12 was released on 2010, and at this point any supported Linux
distro has that version or way greather than that.
Pino Toscano 6 月之前
父节点
当前提交
b59b7debd3
共有 3 个文件被更改,包括 4 次插入29 次删除
  1. 1 8
      src/mutex.cpp
  2. 1 9
      src/os.cpp
  3. 2 12
      src/thread.cpp

+ 1 - 8
src/mutex.cpp

@@ -10,14 +10,7 @@
 #if BX_CRT_NONE
 #if BX_CRT_NONE
 #	include <bx/cpu.h>
 #	include <bx/cpu.h>
 #	include <bx/crt0.h>
 #	include <bx/crt0.h>
-#elif  BX_PLATFORM_ANDROID \
-	|| BX_PLATFORM_LINUX   \
-	|| BX_PLATFORM_IOS     \
-	|| BX_PLATFORM_OSX     \
-	|| BX_PLATFORM_PS4     \
-	|| BX_PLATFORM_RPI	   \
-	|| BX_PLATFORM_NX      \
-	|| BX_PLATFORM_VISIONOS
+#elif  BX_PLATFORM_POSIX
 #	include <pthread.h>
 #	include <pthread.h>
 #elif  BX_PLATFORM_WINDOWS \
 #elif  BX_PLATFORM_WINDOWS \
 	|| BX_PLATFORM_WINRT   \
 	|| BX_PLATFORM_WINRT   \

+ 1 - 9
src/os.cpp

@@ -19,15 +19,7 @@
 #	endif // WIN32_LEAN_AND_MEAN
 #	endif // WIN32_LEAN_AND_MEAN
 #	include <windows.h>
 #	include <windows.h>
 #	include <psapi.h>
 #	include <psapi.h>
-#elif  BX_PLATFORM_ANDROID    \
-	|| BX_PLATFORM_EMSCRIPTEN \
-	|| BX_PLATFORM_IOS        \
-	|| BX_PLATFORM_LINUX      \
-	|| BX_PLATFORM_NX         \
-	|| BX_PLATFORM_OSX        \
-	|| BX_PLATFORM_PS4        \
-	|| BX_PLATFORM_RPI        \
-	|| BX_PLATFORM_VISIONOS
+#elif  BX_PLATFORM_POSIX
 #	include <sched.h> // sched_yield
 #	include <sched.h> // sched_yield
 #	if BX_PLATFORM_IOS       \
 #	if BX_PLATFORM_IOS       \
 	|| BX_PLATFORM_OSX       \
 	|| BX_PLATFORM_OSX       \

+ 2 - 12
src/thread.cpp

@@ -14,18 +14,8 @@
 
 
 #if BX_CRT_NONE
 #if BX_CRT_NONE
 #	include <bx/crt0.h>
 #	include <bx/crt0.h>
-#elif  BX_PLATFORM_ANDROID \
-	|| BX_PLATFORM_LINUX   \
-	|| BX_PLATFORM_IOS     \
-	|| BX_PLATFORM_OSX     \
-	|| BX_PLATFORM_PS4     \
-	|| BX_PLATFORM_RPI     \
-	|| BX_PLATFORM_NX      \
-	|| BX_PLATFORM_VISIONOS
+#elif  BX_PLATFORM_POSIX
 #	include <pthread.h>
 #	include <pthread.h>
-#	if BX_PLATFORM_LINUX && (BX_CRT_GLIBC < 21200)
-#		include <sys/prctl.h>
-#	endif // BX_PLATFORM_
 #elif  BX_PLATFORM_WINDOWS \
 #elif  BX_PLATFORM_WINDOWS \
 	|| BX_PLATFORM_WINRT   \
 	|| BX_PLATFORM_WINRT   \
 	|| BX_PLATFORM_XBOXONE \
 	|| BX_PLATFORM_XBOXONE \
@@ -243,7 +233,7 @@ namespace bx
 	|| BX_PLATFORM_IOS   \
 	|| BX_PLATFORM_IOS   \
 	|| BX_PLATFORM_VISIONOS
 	|| BX_PLATFORM_VISIONOS
 		pthread_setname_np(_name);
 		pthread_setname_np(_name);
-#elif (BX_CRT_GLIBC >= 21200)
+#elif BX_CRT_GLIBC
 		pthread_setname_np(ti->m_handle, _name);
 		pthread_setname_np(ti->m_handle, _name);
 #elif BX_PLATFORM_LINUX
 #elif BX_PLATFORM_LINUX
 		prctl(PR_SET_NAME,_name, 0, 0, 0);
 		prctl(PR_SET_NAME,_name, 0, 0, 0);