• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/libxml/

Lines Matching refs:tok

178     xmlMutexPtr tok;
180 if ((tok = malloc(sizeof(xmlMutex))) == NULL)
184 pthread_mutex_init(&tok->lock, NULL);
186 tok->mutex = CreateMutex(NULL, FALSE, NULL);
188 if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
189 free(tok);
192 tok->tid = -1;
194 return (tok);
199 * @tok: the simple mutex
205 xmlFreeMutex(xmlMutexPtr tok)
207 if (tok == NULL) return;
211 pthread_mutex_destroy(&tok->lock);
213 CloseHandle(tok->mutex);
215 delete_sem(tok->sem);
217 free(tok);
222 * @tok: the simple mutex
227 xmlMutexLock(xmlMutexPtr tok)
229 if (tok == NULL)
233 pthread_mutex_lock(&tok->lock);
235 WaitForSingleObject(tok->mutex, INFINITE);
237 if (acquire_sem(tok->sem) != B_NO_ERROR) {
243 tok->tid = find_thread(NULL);
250 * @tok: the simple mutex
255 xmlMutexUnlock(xmlMutexPtr tok)
257 if (tok == NULL)
261 pthread_mutex_unlock(&tok->lock);
263 ReleaseMutex(tok->mutex);
265 if (tok->tid == find_thread(NULL)) {
266 tok->tid = -1;
267 release_sem(tok->sem);
285 xmlRMutexPtr tok;
287 if ((tok = malloc(sizeof(xmlRMutex))) == NULL)
291 pthread_mutex_init(&tok->lock, NULL);
292 tok->held = 0;
293 tok->waiters = 0;
294 pthread_cond_init(&tok->cv, NULL);
297 InitializeCriticalSection(&tok->cs);
298 tok->count = 0;
300 if ((tok->lock = xmlNewMutex()) == NULL) {
301 free(tok);
304 tok->count = 0;
306 return (tok);
311 * @tok: the reentrant mutex
317 xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
319 if (tok == NULL)
323 pthread_mutex_destroy(&tok->lock);
324 pthread_cond_destroy(&tok->cv);
327 DeleteCriticalSection(&tok->cs);
329 xmlFreeMutex(tok->lock);
331 free(tok);
336 * @tok: the reentrant mutex
341 xmlRMutexLock(xmlRMutexPtr tok)
343 if (tok == NULL)
349 pthread_mutex_lock(&tok->lock);
350 if (tok->held) {
351 if (pthread_equal(tok->tid, pthread_self())) {
352 tok->held++;
353 pthread_mutex_unlock(&tok->lock);
356 tok->waiters++;
357 while (tok->held)
358 pthread_cond_wait(&tok->cv, &tok->lock);
359 tok->waiters--;
362 tok->tid = pthread_self();
363 tok->held = 1;
364 pthread_mutex_unlock(&tok->lock);
366 EnterCriticalSection(&tok->cs);
367 ++tok->count;
369 if (tok->lock->tid == find_thread(NULL)) {
370 tok->count++;
373 xmlMutexLock(tok->lock);
374 tok->count = 1;
381 * @tok: the reentrant mutex
386 xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
388 if (tok == NULL)
394 pthread_mutex_lock(&tok->lock);
395 tok->held--;
396 if (tok->held == 0) {
397 if (tok->waiters)
398 pthread_cond_signal(&tok->cv);
399 tok->tid = 0;
401 pthread_mutex_unlock(&tok->lock);
403 if (!--tok->count)
404 LeaveCriticalSection(&tok->cs);
406 if (tok->lock->tid == find_thread(NULL)) {
407 tok->count--;
408 if (tok->count == 0) {
409 xmlMutexUnlock(tok->lock);