* 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
#include <semaphore.h>
#include <errno.h>
-#if defined(WIN32)
+#if defined(_WIN32)
+#include <windows.h>
#elif defined(__MACH__) && defined(__APPLE__)
#include <stdint.h>
#include <sys/types.h>
#include "xbt/sysdep.h"
#include "xbt/ex.h"
#include "src/xbt/ex_interface.h" /* We play crude games with exceptions */
-#include "src/portable.h"
+#include "src/internal_config.h"
#include "xbt/xbt_os_time.h" /* Portable time facilities */
#include "xbt/xbt_os_thread.h" /* This module */
#include "src/xbt_modinter.h" /* Initialization/finalization of this module */
/* 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);
#endif
}
-const char *xbt_os_thread_name(xbt_os_thread_t t)
-{
- return t->name;
-}
-
const char *xbt_os_thread_self_name(void)
{
xbt_os_thread_t me = xbt_os_thread_self();
}
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));