File tree 1 file changed +55
-0
lines changed 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,61 @@ static int sched_yield (void) {
72
72
Sleep (0 );
73
73
return 0 ;
74
74
}
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
+ UNUSED (unused );
112
+ return 0 ;
113
+ }
114
+
115
+ int pthread_cond_destroy (pthread_cond_t * cond ) {
116
+ DeleteCriticalSection (& cond -> cond );
117
+ return 0 ;
118
+ }
119
+
120
+ int pthread_cond_wait (pthread_cond_t * cond , pthread_mutex_t * mutex ) {
121
+ SleepConditionVariableCS (& cond -> cond , & mutex -> critical_section , INFINITE );
122
+ return 0 ;
123
+ }
124
+
125
+ int pthread_cond_broadcast (pthread_cond_t * cond ) {
126
+ WakeAllConditionVariable (& cond -> cond );
127
+ return 0 ;
128
+ }
129
+
75
130
#else
76
131
#include <pthread.h>
77
132
#include <stdatomic.h>
You can’t perform that action at this time.
0 commit comments