* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/internal_config.h"
-#ifdef HAVE_PTHREAD_SETAFFINITY
+#if HAVE_PTHREAD_SETAFFINITY
#define _GNU_SOURCE
#include <sched.h>
#endif
/* use named sempahore when sem_init() does not work */
-#ifndef HAVE_SEM_INIT
+#if !HAVE_SEM_INIT
static int next_sem_ID = 0;
static xbt_os_mutex_t next_sem_ID_lock;
#endif
thread_mod_inited = 1;
-#ifndef HAVE_SEM_INIT
+#if !HAVE_SEM_INIT
next_sem_ID_lock = xbt_os_mutex_init();
#endif
}
free(main_thread);
main_thread = NULL;
thread_mod_inited = 0;
-#ifndef HAVE_SEM_INIT
+#if !HAVE_SEM_INIT
xbt_os_mutex_destroy(next_sem_ID_lock);
#endif
*/
int xbt_os_thread_bind(xbt_os_thread_t thread, int cpu){
int errcode = 0;
-#ifdef HAVE_PTHREAD_SETAFFINITY
+#if HAVE_PTHREAD_SETAFFINITY
pthread_t pthread = thread->t;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
}
typedef struct xbt_os_sem_ {
-#ifndef HAVE_SEM_INIT
+#if !HAVE_SEM_INIT
char *name;
#endif
sem_t s;
* Any attempt to use it leads to ENOSYS (function not implemented).
* If such a prehistoric system is detected, do the job with sem_open instead
*/
-#ifdef HAVE_SEM_INIT
+#if HAVE_SEM_INIT
if (sem_init(&(res->s), 0, value) != 0)
THROWF(system_error, errno, "sem_init() failed: %s", strerror(errno));
res->ps = &(res->s);
void xbt_os_sem_destroy(xbt_os_sem_t sem)
{
-#ifdef HAVE_SEM_INIT
+#if HAVE_SEM_INIT
if (sem_destroy(sem->ps) < 0)
THROWF(system_error, errno, "sem_destroy() failed: %s",
strerror(errno));