Skip to content

Commit 0bfe728

Browse files
boolemancerggerganov
authored andcommitted
Fix the Windows pthread_create shim
The current implementation doesn't actually set the out parameter, and it returns 0 on failure instead of on success.
1 parent 4e5674a commit 0bfe728

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES
143143
else()
144144
message(STATUS "x86 detected")
145145
if (MSVC)
146-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2")
147-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /arch:AVX2")
146+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
147+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:AVX2")
148148
else()
149149
if (EMSCRIPTEN)
150150
# we require support for WASM SIMD 128-bit

ggml.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ typedef HANDLE pthread_t;
3737

3838
typedef DWORD thread_ret_t;
3939
static int pthread_create(pthread_t* out, void* unused, thread_ret_t(*func)(void*), void* arg) {
40-
out = CreateThread(NULL, 0, func, arg, 0, NULL);
41-
return out != NULL;
40+
HANDLE handle = CreateThread(NULL, 0, func, arg, 0, NULL);
41+
if (handle == NULL)
42+
{
43+
return EAGAIN;
44+
}
45+
46+
*out = handle;
47+
return 0;
4248
}
4349

4450
static int pthread_join(pthread_t thread, void* unused) {

0 commit comments

Comments
 (0)