medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 2c0ebd1fe78568d3deb3ab4fdfa46086cfc20b44
parent d2d21710aeda778cb560be1822acdd586f62eab6
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon Oct 24 20:21:17 +0300

OS X fixes

Diffstat:
Makefile | 2+-
os.mk | 2+-
unix_thread.h | 14+++++++++-----
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile @@ -28,7 +28,7 @@ CXXFLAGS += -std=c++11 -msse2 -fno-exceptions -fno-rtti -I. \ -O2 \ -ggdb3 -fno-omit-frame-pointer -fno-strict-aliasing -fno-strict-overflow \ -DGLFW_INCLUDE_NONE -LDFLAGS += -lm -pthread +LDFLAGS += -lm -include os.mk -include rules.mk diff --git a/os.mk b/os.mk @@ -1,7 +1,7 @@ # Makefile OS detection ifneq ($(shell uname -s),Darwin) CXXFLAGS += -fPIC - LDFLAGS += -lglfw -ldl + LDFLAGS += -lglfw -ldl -lpthread else LDFLAGS += -framework OpenGL -lglfw3 endif diff --git a/unix_thread.h b/unix_thread.h @@ -6,6 +6,7 @@ #include <unistd.h> #include <sys/syscall.h> +#include "platform.h" #include "intrinsics.h" #define THREAD( f ) void * f( void * data ) @@ -24,11 +25,10 @@ inline void thread_init( Thread * thread, ThreadCallback callback, void * data ) } inline u32 thread_getid() { - // TODO: make these casts explicit and checked -#if defined( __linux__ ) - return syscall( SYS_gettid ); -#elif defined( __OpenBSD__ ) - return getthrid(); +#if PLATFORM_LINUX + return checked_cast< u32 >( pthread_self() ); +#elif PLATFORM_OPENBSD + return checked_cast< u32 >( getthrid() ); #else #error new platform #endif @@ -49,10 +49,14 @@ inline void thread_join( Thread * thread ) { } inline void thread_yield() { +#if PLATFORM_OSX + sched_yield(); +#else int ok = pthread_yield(); if( ok == -1 ) { err( 1, "pthread_yield" ); } +#endif } #endif // _UNIX_THREAD_H_