Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / xbt / xbt_os_thread.c
index c697ae7..b80fb31 100644 (file)
@@ -9,7 +9,7 @@
  * 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
@@ -25,7 +25,8 @@
 #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>
@@ -37,7 +38,7 @@
 #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 */
@@ -46,7 +47,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync_os, xbt, "Synchronization mechanism (OS
 
 
 /* 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
@@ -124,7 +125,7 @@ void xbt_os_thread_mod_preinit(void)
 
   thread_mod_inited = 1;
 
-#ifndef HAVE_SEM_INIT
+#if !HAVE_SEM_INIT
   next_sem_ID_lock = xbt_os_mutex_init();
 #endif
 }
@@ -141,7 +142,7 @@ void xbt_os_thread_mod_postexit(void)
   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
 
@@ -200,7 +201,7 @@ xbt_os_thread_t xbt_os_thread_create(const char *name,  pvoid_f_pvoid_t start_ro
  */
 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);
@@ -254,11 +255,6 @@ void xbt_os_thread_setguardsize(int guard_size)
 #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();
@@ -404,7 +400,7 @@ void xbt_os_cond_destroy(xbt_os_cond_t cond)
 }
 
 typedef struct xbt_os_sem_ {
-#ifndef HAVE_SEM_INIT
+#if !HAVE_SEM_INIT
   char *name;
 #endif
   sem_t s;
@@ -423,7 +419,7 @@ xbt_os_sem_t xbt_os_sem_init(unsigned int value)
    * 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);
@@ -467,7 +463,7 @@ void xbt_os_sem_release(xbt_os_sem_t sem)
 
 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));