Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 13 Sep 2015 15:45:00 +0000 (17:45 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 13 Sep 2015 15:45:00 +0000 (17:45 +0200)
14 files changed:
CMakeLists.txt
appveyor.yml
include/simgrid_config.h.in
include/smpi/smpi.h
include/xbt/base.h
include/xbt/log.h
include/xbt/sysdep.h
src/simdag/sd_daxloader.c
src/simix/smx_context.c
src/surf/surfxml_parse.c
src/xbt/parmap.c
tools/cmake/CompleteInFiles.cmake
tools/cmake/DefinePackages.cmake
tools/cmake/test_prog/prog_thread_storage.c

index 7ab35ff..105c070 100644 (file)
@@ -16,7 +16,7 @@ endif()
 ## Check the C/C++ standard that we need
 ##   See also tools/cmake/Flags.cmake that sets our paranoid warning flags
 if (MSVC)
-  message("-- MicroSoft Visual C detected. Good luck.")
+  message("-- You are compiling SimGrid with MicroSoft Visual C. Good luck.")
 else() # gcc or clang
   INCLUDE(CheckCCompilerFlag)
   CHECK_C_COMPILER_FLAG(-fstack-cleaner HAVE_C_STACK_CLEANER)
index 09b49fb..68e80ee 100644 (file)
@@ -20,11 +20,9 @@ environment:
   BOOST_ROOT: c:\Libraries\boost
   BOOST_LIBRARYDIR: c:\Libraries\boost\stage\lib
   
-#  -DCMAKE_CXX_FLAGS_RELEASE="/MT /W1 /O2 /Ob2 /D NDEBUG" -DCMAKE_CXX_FLAGS_DEBUG="/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1 /W1"
-#  -DCMAKE_CXX_FLAGS_RELEASE="/MT /W1 /O2 /Ob2 /D NDEBUG" -DCMAKE_CXX_FLAGS_DEBUG="/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1 /W1"
 build_script:
-- if [%PLATFORM%]==[Win32] cmake -G "Visual Studio 14 2015"  .
-- if [%PLATFORM%]==[x64] cmake -G "Visual Studio 14 2015 Win64" .
+- if [%PLATFORM%]==[Win32] cmake -G "Visual Studio 14 2015" -Denable_smpi=OFF .
+- if [%PLATFORM%]==[x64] cmake -G "Visual Studio 14 2015 Win64" -Denable_smpi=OFF .
 - msbuild ALL_BUILD.vcxproj /verbosity:normal
 
 test_script:
index 5265002..ba2e972 100644 (file)
        #endif
 #endif
 
+/* Define to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
+/* Define to 1 if you have the <sys/time.h> header file. */
+#cmakedefine HAVE_SYS_TIME_H @HAVE_SYS_TIME_H@
 
 /* Define to 1 if mmalloc is compiled in. */
 #cmakedefine HAVE_MMALLOC @HAVE_MMALLOC@
index 2a4bd89..a9117e2 100644 (file)
@@ -7,9 +7,15 @@
 #ifndef SMPI_H
 #define SMPI_H
 
+#include <simgrid_config.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#include <stddef.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
+#endif
+
+#include <stddef.h>
 #include <xbt/misc.h>
 #include <xbt/function_types.h>
 
index 1241b63..54ab270 100644 (file)
@@ -89,7 +89,7 @@
 #        define XBT_INLINE
 #    endif
 #  else
-#     if defined (__VISUALC__)
+#     if defined (_MSC_VER)
 #       define XBT_INLINE __inline
 #     else
 #       define XBT_INLINE  inline
 #  endif /* __cplusplus */
 #endif
 
+#if defined(__GNUC__)
+#   define XBT_ALWAYS_INLINE inline __attribute__ ((always_inline))
+#else
+#   define XBT_ALWAYS_INLINE XBT_INLINE
+#endif
+
+#if defined(__GNUC__)
+#   define XBT_THREAD_LOCAL __thread
+#elif defined(_MSC_VER)
+#   define XBT_THREAD_LOCAL __declspec(thread)
+#else
+#   define XBT_THREAD_LOCAL No thread local on this architecture
+#endif
+
 /* improvable on gcc (by evaluating arguments only once), but wouldn't be portable */
 #ifdef MIN
 # undef MIN
 
 #endif
 
+#ifdef _MSC_VER /* MSVC has no ssize_t, and I fail to use the SSIZE_T declared in BaseTsd.h */
+       #if defined(_WIN64)
+               typedef __int64 ssize_t;
+       #else
+               typedef long ssize_t;
+       #endif
+
+/* Microsoft wants to improve the code quality blah blah blah */
+/* See: https://msdn.microsoft.com/en-us/library/8ef0s5kh.aspx */
+       /* warning C4996: '_strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup. */
+       # define _CRT_NONSTDC_NO_WARNINGS
+       /* warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. */
+       # define _CRT_SECURE_NO_WARNINGS
+#endif
+
+
+
 #ifdef _XBT_WIN32
 #define XBT_INTERNAL
 #else
index 68132cf..240096d 100644 (file)
@@ -395,8 +395,8 @@ extern xbt_log_layout_t xbt_log_default_layout;
  */
 #define _XBT_LOG_ISENABLEDV(catv, priority)                  \
        (priority >= XBT_LOG_STATIC_THRESHOLD                 \
-        && (catv.initialized || _xbt_log_cat_init(&catv, priority)) \
-        && priority >= catv.threshold)
+        && ((catv).initialized || _xbt_log_cat_init(&(catv), priority)) \
+        && priority >= (catv).threshold)
 
 /*
  * Internal Macros
@@ -422,11 +422,28 @@ extern xbt_log_layout_t xbt_log_default_layout;
   fprintf(stderr,"%s:%d:\n" f, __FILE__, __LINE__, __VA_ARGS__)
 # define XBT_LOG(...) XBT_CLOG(0, __VA_ARGS__)
 #else
-# define XBT_CLOG_(catv, prio, ...)                                     \
+
+// This code is duplicated to remove one level of indirection, working around a MSVC bug
+// See: http://stackoverflow.com/questions/9183993/msvc-variadic-macro-expansion
+
+# define XBT_CLOG(category, prio, ...) \
+  do {                                                                  \
+    if (_XBT_LOG_ISENABLEDV((category), prio)) {                        \
+      s_xbt_log_event_t _log_ev;                                        \
+      _log_ev.cat = &(category);                                        \
+      _log_ev.priority = (prio);                                        \
+      _log_ev.fileName = __FILE__;                                      \
+      _log_ev.functionName = _XBT_FUNCTION;                             \
+      _log_ev.lineNum = __LINE__;                                       \
+      _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+    }                                                                   \
+  }  while (0)
+
+# define XBT_LOG(prio,...) \
   do {                                                                  \
-    if (_XBT_LOG_ISENABLEDV(catv, prio)) {                              \
+    if (_XBT_LOG_ISENABLEDV((*_simgrid_log_category__default), prio)) { \
       s_xbt_log_event_t _log_ev;                                        \
-      _log_ev.cat = &(catv);                                            \
+      _log_ev.cat = _simgrid_log_category__default;                     \
       _log_ev.priority = (prio);                                        \
       _log_ev.fileName = __FILE__;                                      \
       _log_ev.functionName = _XBT_FUNCTION;                             \
@@ -434,8 +451,6 @@ extern xbt_log_layout_t xbt_log_default_layout;
       _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
     }                                                                   \
   }  while (0)
-# define XBT_CLOG(cat, prio, ...) XBT_CLOG_(_XBT_LOGV(cat), prio, __VA_ARGS__)
-# define XBT_LOG(...) XBT_CLOG_((*_XBT_LOGV(default)), __VA_ARGS__)
 #endif
 
 /** @ingroup XBT_log
@@ -444,74 +459,214 @@ extern xbt_log_layout_t xbt_log_default_layout;
  * \param ... the format string and its arguments
  *  @brief Log an event at the DEBUG priority on the specified category with these args.
  */
-#define XBT_CDEBUG(c, ...) XBT_CLOG(c, xbt_log_priority_debug, __VA_ARGS__)
+#define XBT_CDEBUG(categ, ...) \
+                 do {                                                                  \
+                   if (XBT_LOG_ISENABLED (categ, xbt_log_priority_debug)) {            \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = &(_XBT_LOGV(categ));                                \
+                     _log_ev.priority = xbt_log_priority_debug;                        \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the VERB priority on the specified category with these args.
  */
-#define XBT_CVERB(c, ...) XBT_CLOG(c, xbt_log_priority_verbose, __VA_ARGS__)
+#define XBT_CVERB(categ, ...)  \
+                 do {                                                                  \
+                   if (XBT_LOG_ISENABLED (categ, xbt_log_priority_verbose)) {          \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = &(_XBT_LOGV(categ));                                \
+                     _log_ev.priority = xbt_log_priority_verbose;                      \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the INFO priority on the specified category with these args.
  */
-#define XBT_CINFO(c, ...) XBT_CLOG(c, xbt_log_priority_info, __VA_ARGS__)
+#define XBT_CINFO(categ, ...) \
+                 do {                                                                  \
+                   if (XBT_LOG_ISENABLED (categ, xbt_log_priority_info)) {             \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = &(_XBT_LOGV(categ));                                \
+                     _log_ev.priority = xbt_log_priority_info;                         \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
+
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the WARN priority on the specified category with these args.
  */
-#define XBT_CWARN(c, ...) XBT_CLOG(c, xbt_log_priority_warning, __VA_ARGS__)
+#define XBT_CWARN(categ, ...) \
+                 do {                                                                  \
+                   if (XBT_LOG_ISENABLED (categ, xbt_log_priority_warning)) {          \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = &(_XBT_LOGV(categ));                                \
+                     _log_ev.priority = xbt_log_priority_warning;                      \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
+
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the ERROR priority on the specified category with these args.
  */
-#define XBT_CERROR(c, ...) XBT_CLOG(c, xbt_log_priority_error, __VA_ARGS__)
+#define XBT_CERROR(categ, ...) \
+                 do {                                                                  \
+                   if (XBT_LOG_ISENABLED (categ, xbt_log_priority_error)) {            \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = &(_XBT_LOGV(categ));                                \
+                     _log_ev.priority = xbt_log_priority_error;                        \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the CRITICAL priority on the specified category with these args (CCRITICALn exists for any n<10).
  */
-#define XBT_CCRITICAL(c, ...) XBT_CLOG(c, xbt_log_priority_critical, __VA_ARGS__)
+#define XBT_CCRITICAL(categ, ...) \
+                 do {                                                                  \
+                   if (XBT_LOG_ISENABLED (categ, xbt_log_priority_critical)) {         \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = &(_XBT_LOGV(categ));                                \
+                     _log_ev.priority = xbt_log_priority_critical;                     \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  * \param ... the format string and its arguments
  *  @brief Log an event at the DEBUG priority on the default category with these args.
  */
-#define XBT_DEBUG(...) XBT_LOG(xbt_log_priority_debug, __VA_ARGS__)
+#define XBT_DEBUG(...) \
+                 do {                                                                  \
+                   if (_XBT_LOG_ISENABLEDV(*_simgrid_log_category__default,            \
+                                               xbt_log_priority_debug)) {                  \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = _simgrid_log_category__default;                     \
+                     _log_ev.priority = xbt_log_priority_debug;                        \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the VERB priority on the default category with these args.
  */
-#define XBT_VERB(...) XBT_LOG(xbt_log_priority_verbose, __VA_ARGS__)
+#define XBT_VERB(...) \
+                 do {                                                                  \
+                   if (_XBT_LOG_ISENABLEDV(*_simgrid_log_category__default,            \
+                                               xbt_log_priority_verbose)) {                \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = _simgrid_log_category__default;                     \
+                     _log_ev.priority = xbt_log_priority_verbose;                      \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the INFO priority on the default category with these args.
  */
-#define XBT_INFO(...) XBT_LOG(xbt_log_priority_info, __VA_ARGS__)
+#define XBT_INFO(...) \
+                 do {                                                                  \
+                   if (_XBT_LOG_ISENABLEDV(*_simgrid_log_category__default,            \
+                                               xbt_log_priority_info)) {                   \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = _simgrid_log_category__default;                     \
+                     _log_ev.priority = xbt_log_priority_info;                         \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the WARN priority on the default category with these args.
  */
-#define XBT_WARN(...) XBT_LOG(xbt_log_priority_warning, __VA_ARGS__)
+#define XBT_WARN(...) \
+                 do {                                                                  \
+                   if (_XBT_LOG_ISENABLEDV(*_simgrid_log_category__default,            \
+                                               xbt_log_priority_warning)) {                \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = _simgrid_log_category__default;                     \
+                     _log_ev.priority = xbt_log_priority_warning;                      \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the ERROR priority on the default category with these args.
  */
-#define XBT_ERROR(...) XBT_LOG(xbt_log_priority_error, __VA_ARGS__)
+#define XBT_ERROR(...) \
+                 do {                                                                  \
+                   if (_XBT_LOG_ISENABLEDV(*_simgrid_log_category__default,            \
+                                               xbt_log_priority_error)) {                  \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = _simgrid_log_category__default;                     \
+                     _log_ev.priority = xbt_log_priority_error;                        \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 /** @ingroup XBT_log
  *  @hideinitializer
  *  @brief Log an event at the CRITICAL priority on the default category with these args.
  */
-#define XBT_CRITICAL(...) XBT_LOG(xbt_log_priority_critical, __VA_ARGS__)
+#define XBT_CRITICAL(...) \
+                 do {                                                                  \
+                   if (_XBT_LOG_ISENABLEDV(*_simgrid_log_category__default,            \
+                                               xbt_log_priority_critical)) {               \
+                     s_xbt_log_event_t _log_ev;                                        \
+                     _log_ev.cat = _simgrid_log_category__default;                     \
+                     _log_ev.priority = xbt_log_priority_critical;                     \
+                     _log_ev.fileName = __FILE__;                                      \
+                     _log_ev.functionName = _XBT_FUNCTION;                             \
+                     _log_ev.lineNum = __LINE__;                                       \
+                     _xbt_log_event_log(&_log_ev, __VA_ARGS__);                        \
+                   }                                                                   \
+                 }  while (0)
 
 #define _XBT_IN_OUT(...) \
   _XBT_IF_ONE_ARG(_XBT_IN_OUT_ARG1, _XBT_IN_OUT_ARGN, __VA_ARGS__)(__VA_ARGS__)
index 9ed7c53..d990aaa 100644 (file)
@@ -71,11 +71,8 @@ XBT_PUBLIC(char *) bprintf(const char *fmt, ...) _XBT_GNUC_PRINTF(1, 2);
  *  @{
  */
 
-#if defined(__GNUC__) || defined(DOXYGEN)
 /** @brief Like strdup, but xbt_die() on error */
-static inline __attribute__ ((always_inline))
-char *xbt_strdup(const char *s)
-{
+static XBT_ALWAYS_INLINE char *xbt_strdup(const char *s) {
   char *res = NULL;
   if (s) {
     res = strdup(s);
@@ -89,9 +86,7 @@ XBT_PUBLIC(void) xbt_backtrace_display_current(void);
 
 /** @brief Like malloc, but xbt_die() on error
     @hideinitializer */
-static inline __attribute__ ((always_inline))
-void *xbt_malloc(size_t n)
-{
+static XBT_ALWAYS_INLINE void *xbt_malloc(size_t n) {
   void *res;
 /*  if (n==0) {
      xbt_backtrace_display_current();
@@ -106,9 +101,7 @@ void *xbt_malloc(size_t n)
 
 /** @brief like malloc, but xbt_die() on error and memset data to 0
     @hideinitializer */
-static inline __attribute__ ((always_inline))
-void *xbt_malloc0(size_t n)
-{
+static XBT_ALWAYS_INLINE void *xbt_malloc0(size_t n) {
   void *res;
   //if (n==0) xbt_die("calloc(0) is not portable");
   res = calloc(n, 1);
@@ -119,9 +112,7 @@ void *xbt_malloc0(size_t n)
 
 /** @brief like realloc, but xbt_die() on error
     @hideinitializer */
-static inline __attribute__ ((always_inline))
-void *xbt_realloc(void *p, size_t s)
-{
+static XBT_ALWAYS_INLINE void *xbt_realloc(void *p, size_t s) {
   void *res = NULL;
   //if (s==0) xbt_die("realloc(0) is not portable");
   if (s) {
@@ -137,12 +128,6 @@ void *xbt_realloc(void *p, size_t s)
   }
   return res;
 }
-#else                           /* non __GNUC__  */
-#  define xbt_strdup(s)    strdup(s)
-#  define xbt_malloc(n)    malloc(n)
-#  define xbt_malloc0(n)   calloc(n,1)
-#  define xbt_realloc(p,s) realloc(p,s)
-#endif                          /* __GNUC__ ? */
 
 /** @brief like free
     @hideinitializer */
index e2873cd..e48ca55 100644 (file)
@@ -8,7 +8,6 @@
 #include "simgrid/simdag.h"
 #include "xbt/misc.h"
 #include "xbt/log.h"
-#include <libgen.h>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files");
 
@@ -368,8 +367,7 @@ xbt_dynar_t SD_daxload(const char *filename)
   }
 
   if (!acyclic_graph_detail(result)){
-    XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.",
-              basename((char*)filename));
+    XBT_ERROR("The DAX described in %s is not a DAG. It contains a cycle.", filename);
     xbt_dynar_foreach(result, cpt, file)
       SD_task_destroy(file);
      xbt_dynar_free_container(&result);
index 9adeeac..e447ed3 100644 (file)
@@ -18,6 +18,7 @@
 
 #ifdef _WIN32
 #include <windows.h>
+#include <malloc.h>
 #else
 #include <sys/mman.h>
 #endif
 #define _aligned_free  __mingw_aligned_free 
 #endif //MINGW
 
-#if defined(_XBT_WIN32)
-#include <malloc.h>
-#endif
-
 #ifdef HAVE_VALGRIND_VALGRIND_H
 # include <valgrind/valgrind.h>
 #endif
@@ -45,7 +42,7 @@ int smx_context_stack_size_was_set = 0;
 int smx_context_guard_size;
 int smx_context_guard_size_was_set = 0;
 #ifdef HAVE_THREAD_LOCAL_STORAGE
-static __thread smx_context_t smx_current_context_parallel;
+static XBT_THREAD_LOCAL smx_context_t smx_current_context_parallel;
 #else
 static xbt_os_thread_key_t smx_current_context_key = 0;
 #endif
index ad461b9..c82a307 100644 (file)
@@ -7,7 +7,9 @@
 #include <errno.h>
 #include <math.h>
 #include <stdarg.h> /* va_arg */
+#ifndef _MSC_VER
 #include <libgen.h>
+#endif
 
 #include "xbt/misc.h"
 #include "xbt/log.h"
@@ -1028,8 +1030,18 @@ void surf_parse_open(const char *file)
 
   if (!surf_parsed_filename_stack)
     surf_parsed_filename_stack = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
+
+#ifdef _MSC_VER
+  /* There is no dirname on windows... */
+  char drive[_MAX_DRIVE];
+  char dir[_MAX_DIR];
+  errno_t err;
+  err = _splitpath_s(file, drive, _MAX_DRIVE, dir, _MAX_DIR, NULL,0, NULL,0);
+  char *dir = bprintf("%s%s",drive,dir);
+#else
   surf_parsed_filename = xbt_strdup(file);
   char *dir = dirname(surf_parsed_filename);
+#endif
   xbt_dynar_push(surf_path, &dir);
 
   surf_file_to_parse = surf_fopen(file, "r");
index b5d9025..a19ed04 100644 (file)
@@ -5,7 +5,9 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "internal_config.h"
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 
 #ifndef _XBT_WIN32
 #include <sys/syscall.h>
index 4e76d1f..d4730da 100644 (file)
@@ -17,7 +17,11 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86|AMD64|amd64")
     message(STATUS "System processor: x86_64 (${CMAKE_SYSTEM_PROCESSOR}, 64 bits)")
     set(PROCESSOR_x86_64 1)
   ENDIF()
-  set(HAVE_RAWCTX 1)
+  if (NOT MSVC)
+    message(STATUS "Disable fast raw contextes on Microsoft Visual.")
+  else()
+    set(HAVE_RAWCTX 1)
+  endif()
 
 ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
   message(STATUS "System processor: alpha")
index a3af7a0..31d4066 100644 (file)
@@ -352,7 +352,6 @@ set(SIMIX_SRC
   src/simix/libsmx.c
   src/simix/smx_context.c
   src/simix/smx_context_base.c
-  src/simix/smx_context_raw.c
   src/simix/smx_deployment.c
   src/simix/smx_environment.c
   src/simix/smx_global.c
@@ -367,6 +366,18 @@ set(SIMIX_SRC
   ${SIMIX_GENERATED_SRC}
   )
 
+# Don't try to compile our inline assembly with MSVC
+if (MSVC)
+  set(EXTRA_DIST
+      ${EXTRA_DIST}
+      src/simix/smx_context_raw.c)
+else()
+  set(SIMIX_SRC
+      ${SIMIX_SRC}
+      src/simix/smx_context_raw.c)
+endif()
+
+# Boost context may not be available
 if (HAVE_BOOST_CONTEXT)
   set(SIMIX_SRC
       ${SIMIX_SRC}
index 86d2940..edcab03 100644 (file)
@@ -6,7 +6,12 @@
 
 #include <stdio.h>
 
-__thread int thread_specific_variable = 0;
+#ifdef _MSC_VER
+__declspec(thread)
+#else 
+__thread 
+#endif
+int thread_specific_variable = 0;
 
 int main(void) {