Threading support in mingw win32 builds
This commit is contained in:
parent
f6558fd3fa
commit
9faec7b318
4
Makefile
4
Makefile
@ -26,10 +26,12 @@ ifndef KRK_ENABLE_STATIC
|
||||
else
|
||||
# For Windows, disable format string warnings because gcc will get mad
|
||||
# about non-portable Windows format specifiers...
|
||||
CFLAGS += -Wno-format
|
||||
CFLAGS += -Wno-format -static-libgcc
|
||||
# And we need to link this by name with extension because I don't want
|
||||
# to actually rename it to kuroko.dll or whatever.
|
||||
MODLIBS = libkuroko.so
|
||||
LDLIBS += -l:libwinpthread.a
|
||||
${OBJS}: CFLAGS += -DKRKINLIB
|
||||
endif
|
||||
all: ${TARGET} ${MODULES} ${TOOLS}
|
||||
KUROKO_LIBS = libkuroko.so
|
||||
|
@ -17,6 +17,7 @@ typedef long long krk_integer_type;
|
||||
# define PRIkrk_int "%I64d"
|
||||
# define PRIkrk_hex "%I64x"
|
||||
# define parseStrInt strtoll
|
||||
# define ENABLE_THREADING
|
||||
# else
|
||||
typedef long krk_integer_type;
|
||||
# define PRIkrk_int "%ld"
|
||||
|
@ -7,6 +7,13 @@
|
||||
#ifdef ENABLE_THREADING
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <winnt.h>
|
||||
#define sched_yield() YieldProcessor()
|
||||
#endif
|
||||
|
||||
static inline void _krk_internal_spin_lock(int volatile * lock) {
|
||||
while(__sync_lock_test_and_set(lock, 0x01)) {
|
||||
sched_yield();
|
||||
|
4
src/vm.h
4
src/vm.h
@ -243,7 +243,11 @@ typedef struct KrkVM {
|
||||
*
|
||||
* See @c KrkThreadState for more information.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(KRKINLIB)
|
||||
#define krk_currentThread (*krk_getCurrentThread())
|
||||
#else
|
||||
extern threadLocal KrkThreadState krk_currentThread;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Singleton instance of the shared VM state.
|
||||
|
Loading…
x
Reference in New Issue
Block a user