/* Used in RL to get win/lin portability, and in SG when CONTEXT_THREAD */
/* in SG, when using HAVE_UCONTEXT_CONTEXTS, xbt_os_thread_stub is used instead */
-/* Copyright (c) 2007-2017. The SimGrid Team.
+/* Copyright (c) 2007-2018. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
return pthread_getspecific(xbt_self_thread_key);
}
-void xbt_os_thread_key_create(xbt_os_thread_key_t* key)
-{
- int errcode = pthread_key_create(key, NULL);
- xbt_assert(errcode==0 , "pthread_key_create failed");
-}
-
-void xbt_os_thread_set_specific(xbt_os_thread_key_t key, void* value)
-{
- int errcode = pthread_setspecific(key, value);
- xbt_assert(errcode==0, "pthread_setspecific failed");
-}
-
-void* xbt_os_thread_get_specific(xbt_os_thread_key_t key)
-{
- return pthread_getspecific(key);
-}
-
-#include <sched.h>
-void xbt_os_thread_yield(void)
-{
- sched_yield();
-}
-
/****** mutex related functions ******/
typedef struct xbt_os_mutex_ {
pthread_mutex_t m;
free(mutex);
}
-/***** condition related functions *****/
-typedef struct xbt_os_cond_ {
- pthread_cond_t c;
-} s_xbt_os_cond_t;
-
-xbt_os_cond_t xbt_os_cond_init(void)
-{
- xbt_os_cond_t res = xbt_new(s_xbt_os_cond_t, 1);
- int errcode = pthread_cond_init(&(res->c), NULL);
- xbt_assert(errcode==0, "pthread_cond_init() failed: %s", strerror(errcode));
- return res;
-}
-
-void xbt_os_cond_wait(xbt_os_cond_t cond, xbt_os_mutex_t mutex)
-{
- int errcode = pthread_cond_wait(&(cond->c), &(mutex->m));
- xbt_assert(errcode==0, "pthread_cond_wait(%p,%p) failed: %s", cond, mutex, strerror(errcode));
-}
-
-void xbt_os_cond_signal(xbt_os_cond_t cond)
-{
- int errcode = pthread_cond_signal(&(cond->c));
- xbt_assert(errcode==0, "pthread_cond_signal(%p) failed: %s", cond, strerror(errcode));
-}
-
-void xbt_os_cond_broadcast(xbt_os_cond_t cond)
-{
- int errcode = pthread_cond_broadcast(&(cond->c));
- xbt_assert(errcode==0, "pthread_cond_broadcast(%p) failed: %s", cond, strerror(errcode));
-}
-
-void xbt_os_cond_destroy(xbt_os_cond_t cond)
-{
- if (!cond)
- return;
-
- int errcode = pthread_cond_destroy(&(cond->c));
- xbt_assert(errcode==0, "pthread_cond_destroy(%p) failed: %s", cond, strerror(errcode));
- free(cond);
-}
-
typedef struct xbt_os_sem_ {
#if !HAVE_SEM_INIT
char *name;