]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
Fix the Windows pthread_create shim
authorboolemancer <redacted>
Tue, 8 Nov 2022 11:04:23 +0000 (03:04 -0800)
committerGeorgi Gerganov <redacted>
Tue, 8 Nov 2022 13:02:32 +0000 (15:02 +0200)
The current implementation doesn't actually set the out parameter,
and it returns 0 on failure instead of on success.

CMakeLists.txt
ggml.c

index 9a509334020396b05449f7e334633b3f204b1a20..38e4cd7b7196b736b11a7a38b5594045864924eb 100644 (file)
@@ -143,8 +143,8 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES
 else()
     message(STATUS "x86 detected")
     if (MSVC)
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2")
-        set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /arch:AVX2")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
+        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:AVX2")
     else()
         if (EMSCRIPTEN)
             # we require support for WASM SIMD 128-bit
diff --git a/ggml.c b/ggml.c
index 79b910bbac66f815e6e8c7e0a0954396e99d228f..484b6dcce1262133cf7510c59fd822877a87b6d3 100644 (file)
--- a/ggml.c
+++ b/ggml.c
@@ -37,8 +37,14 @@ typedef HANDLE pthread_t;
 
 typedef DWORD thread_ret_t;
 static int pthread_create(pthread_t* out, void* unused, thread_ret_t(*func)(void*), void* arg) {
-    out = CreateThread(NULL, 0, func, arg, 0, NULL);
-    return out != NULL;
+    HANDLE handle = CreateThread(NULL, 0, func, arg, 0, NULL);
+    if (handle == NULL)
+    {
+        return EAGAIN;
+    }
+
+    *out = handle;
+    return 0;
 }
 
 static int pthread_join(pthread_t thread, void* unused) {