| 249 | */ |
| 250 | |
| 251 | int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) |
| 252 | { |
| 253 | /* |
| 254 | Once initialization is used here rather than in my_init(), to |
| 255 | 1) avoid my_init() pitfalls- undefined order in which initialization should |
| 256 | run |
| 257 | 2) be potentially useful C++ (in static constructors that run before main()) |
| 258 | 3) just to simplify the API. |
| 259 | Also, the overhead of my_pthread_once is very small. |
| 260 | */ |
| 261 | static my_pthread_once_t once_control= MY_PTHREAD_ONCE_INIT; |
| 262 | my_pthread_once(&once_control, check_native_cond_availability); |
| 263 | |
| 264 | if (have_native_conditions) |
| 265 | { |
| 266 | my_InitializeConditionVariable(&cond->native_cond); |
| 267 | return 0; |
| 268 | } |
| 269 | else |
| 270 | return legacy_cond_init(cond, attr); |
| 271 | } |
| 272 | |
| 273 | |
| 274 | int pthread_cond_destroy(pthread_cond_t *cond) |