From c48cc0afdcfbfe8678a02d0d4131074aacf76dbe Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 15 Aug 2013 16:26:16 -0700 Subject: [PATCH] Fix OS X build. --- public/sourcepawn/ke_thread_posix.h | 12 ++++++++++++ sourcepawn/jit/AMBuilder | 3 +++ sourcepawn/jit/x86/jit_x86.cpp | 1 - 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/public/sourcepawn/ke_thread_posix.h b/public/sourcepawn/ke_thread_posix.h index 75e8ed4a..cbbaa89b 100644 --- a/public/sourcepawn/ke_thread_posix.h +++ b/public/sourcepawn/ke_thread_posix.h @@ -24,6 +24,9 @@ #if defined(__linux__) # include #endif +#if defined(__APPLE__) +# include +#endif namespace ke { @@ -94,9 +97,18 @@ class ConditionVariable : public Lockable WaitResult Wait(size_t timeout_ms) { AssertCurrentThreadOwns(); +#if defined(__linux__) struct timespec ts; if (clock_gettime(CLOCK_REALTIME, &ts) == -1) return Wait_Error; +#else + struct timeval tv; + gettimeofday(&tv, NULL); + + struct timespec ts; + ts.tv_sec = tv.tv_sec; + ts.tv_nsec = tv.tv_usec * 1000; +#endif ts.tv_sec += timeout_ms / 1000; ts.tv_nsec += (timeout_ms % 1000) * 1000000; diff --git a/sourcepawn/jit/AMBuilder b/sourcepawn/jit/AMBuilder index a1fa16ca..3dfaa9f7 100644 --- a/sourcepawn/jit/AMBuilder +++ b/sourcepawn/jit/AMBuilder @@ -15,6 +15,9 @@ compiler['CXXINCLUDES'].append(os.path.join(base, 'knight', 'shared')) if AMBuild.target['platform'] == 'linux': compiler['POSTLINKFLAGS'].append('-lpthread') compiler['POSTLINKFLAGS'].append('-lrt') +if AMBuild.target['platform'] == 'darwin': + compiler['POSTLINKFLAGS'].append('-lpthread') + compiler['POSTLINKFLAGS'].append('-ldl') extension = AMBuild.AddJob('sourcepawn.jit.x86') binary = Cpp.LibraryBuilder('sourcepawn.jit.x86', AMBuild, extension, compiler) diff --git a/sourcepawn/jit/x86/jit_x86.cpp b/sourcepawn/jit/x86/jit_x86.cpp index 1e94a7e9..c3d22a40 100644 --- a/sourcepawn/jit/x86/jit_x86.cpp +++ b/sourcepawn/jit/x86/jit_x86.cpp @@ -217,7 +217,6 @@ GenerateArray(BaseRuntime *rt, uint32_t argc, cell_t *argv, int autozero) if (argv[0] <= 0) return SP_ERROR_ARRAY_TOO_BIG; - uint32_t dim = 1; // second to last dimension uint32_t cells = argv[0]; for (uint32_t dim = 1; dim < argc; dim++) {