File tree 1 file changed +53
-0
lines changed 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,59 @@ 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
+ 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
+
75
128
#else
76
129
#include <pthread.h>
77
130
#include <stdatomic.h>
You can’t perform that action at this time.
0 commit comments