Skip to content

Commit c55222e

Browse files
committed
windows fixed
1 parent 8824130 commit c55222e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

ggml.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,59 @@ static int sched_yield (void) {
7272
Sleep (0);
7373
return 0;
7474
}
75+
76+
typedef struct pthread_mutex_tag {
77+
CRITICAL_SECTION critical_section;
78+
} pthread_mutex_t;
79+
80+
typedef struct pthread_mutexattr_tag {
81+
int attr;
82+
} pthread_mutexattr_t;
83+
84+
int pthread_mutex_init(pthread_mutex_t * mutex, const pthread_mutexattr_t * attr) {
85+
InitializeCriticalSection (&mutex->critical_section);
86+
return 0;
87+
}
88+
89+
int pthread_mutex_destroy(pthread_mutex_t * mutex) {
90+
DeleteCriticalSection(&mutex->critical_section);
91+
return 0;
92+
}
93+
94+
95+
int pthread_mutex_lock(pthread_mutex_t * mutex) {
96+
EnterCriticalSection(&mutex->critical_section);
97+
return 0;
98+
}
99+
100+
int pthread_mutex_unlock(pthread_mutex_t * mutex) {
101+
LeaveCriticalSection(&mutex->critical_section);
102+
return 0;
103+
}
104+
105+
typedef struct pthread_cond_tag {
106+
CONDITION_VARIABLE cond;
107+
} pthread_cond_t;
108+
109+
int pthread_cond_init(pthread_cond_t * cond, void * unused) {
110+
InitializeConditionVariable (&cond->cond);
111+
return 0;
112+
}
113+
114+
int pthread_cond_destroy(pthread_cond_t * cond) {
115+
return 0;
116+
}
117+
118+
int pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) {
119+
SleepConditionVariableCS(&cond->cond, &mutex->critical_section, INFINITE);
120+
return 0;
121+
}
122+
123+
int pthread_cond_broadcast(pthread_cond_t * cond) {
124+
WakeAllConditionVariable(&cond->cond);
125+
return 0;
126+
}
127+
75128
#else
76129
#include <pthread.h>
77130
#include <stdatomic.h>

0 commit comments

Comments
 (0)