From: Martin Quinson Date: Sun, 6 Mar 2016 20:58:37 +0000 (+0100) Subject: kill our _XBT_WIN32. Standard _WIN32 is sufficient X-Git-Tag: v3_13~522^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/795359a4a2c81571bb061f8dfbcc6c15323c9bf3 kill our _XBT_WIN32. Standard _WIN32 is sufficient --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 18f50cadfa..3e68ce76e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,6 @@ ENDIF() if(WIN32) - #Need env INCLUDE set(CMAKE_INCLUDE_WIN "${CMAKE_C_COMPILER}") set(CMAKE_LIB_WIN "${CMAKE_C_COMPILER}") string(REGEX REPLACE "/bin/gcc.*" "/include" CMAKE_INCLUDE_WIN "${CMAKE_INCLUDE_WIN}") @@ -178,8 +177,6 @@ if(WIN32) set(INCLUDES ${INCLUDES} ${CMAKE_INCLUDE_WIN}) unset(CMAKE_INCLUDE_WIN) - set(_XBT_WIN32 1) - endif() include_directories(${INCLUDES}) @@ -514,23 +511,11 @@ endif() if(CMAKE_SYSTEM_NAME MATCHES "Darwin") add_definitions(-D_XOPEN_SOURCE=700 -D_DARWIN_C_SOURCE) endif() - -if(WIN32) - # We always provide our own implementation of ucontext on Windows. - try_compile(HAVE_UCONTEXT - ${CMAKE_BINARY_DIR} - ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_AC_CHECK_MCSC.c - COMPILE_DEFINITIONS -D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt - ) -else() - # We always provide our own implementation of ucontext on Windows. - try_compile(HAVE_UCONTEXT +try_compile(HAVE_UCONTEXT ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_AC_CHECK_MCSC.c) -endif() #If can have both context - if(HAVE_UCONTEXT) set(HAVE_UCONTEXT_CONTEXTS 1) message("-- Support for ucontext factory") @@ -604,15 +589,6 @@ if(HAVE_UCONTEXT_H) set(makecontext_CPPFLAGS_2 "-D_XOPEN_SOURCE=700") endif() - if(WIN32) - if(ARCH_32_BITS) - set(makecontext_CPPFLAGS "-DTEST_makecontext -D_I_X86_") - else() - set(makecontext_CPPFLAGS "-DTEST_makecontext -D_AMD64_") - endif() - set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 -I${CMAKE_HOME_DIRECTORY}/src/include -I${CMAKE_HOME_DIRECTORY}/src/xbt") - endif() - file(REMOVE ${CMAKE_BINARY_DIR}/conftestval) if(CMAKE_CROSSCOMPILING) @@ -635,8 +611,6 @@ if(HAVE_UCONTEXT_H) string(REPLACE "," "" makecontext_size "${MAKECONTEXT_SIZE}") set(pth_skaddr_makecontext "#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})") set(pth_sksize_makecontext "#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})") - else() - # message(FATAL_ERROR "makecontext is not compilable") endif() endif() diff --git a/include/simgrid_config.h.in b/include/simgrid_config.h.in index 47e50f554f..10f75e0c05 100644 --- a/include/simgrid_config.h.in +++ b/include/simgrid_config.h.in @@ -32,10 +32,6 @@ SIMGRID_VERSION_MINOR, \ SIMGRID_VERSION_PATCH) -#cmakedefine _XBT_WIN32 @_XBT_WIN32@ /*this variable is set if it is a windows platform*/ -#cmakedefine _WIN32 @_WIN32@ /*this variable is set if it is a 32 bits windows platform*/ -#cmakedefine _WIN64 @_WIN64@ /*this variable is set if it is a 64 bits windows platform*/ - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@ diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index ceed72a590..e8f1bb4777 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -199,7 +199,7 @@ static int prng_random(int min, int max) // Use rejection in order to avoid skew unsigned long x; do { -#ifndef _XBT_WIN32 +#ifndef _WIN32 x = (unsigned long) random(); #else x = (unsigned long) rand(); diff --git a/src/mc/mc_global.cpp b/src/mc/mc_global.cpp index da49931e86..1fc984e33a 100644 --- a/src/mc/mc_global.cpp +++ b/src/mc/mc_global.cpp @@ -13,7 +13,7 @@ #include "mc/mc.h" -#ifndef _XBT_WIN32 +#ifndef _WIN32 #include #include #include diff --git a/src/portable.h b/src/portable.h index f610526f1f..9e5adda52f 100644 --- a/src/portable.h +++ b/src/portable.h @@ -15,7 +15,7 @@ #include "xbt/base.h" #include "xbt/misc.h" -#ifdef _XBT_WIN32 +#ifdef _WIN32 # include #endif @@ -39,7 +39,7 @@ #include -#ifdef _XBT_WIN32 +#ifdef _WIN32 #ifndef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK #endif diff --git a/src/simdag/dax_dtd.c b/src/simdag/dax_dtd.c index a9f46f3d1d..be760b589f 100644 --- a/src/simdag/dax_dtd.c +++ b/src/simdag/dax_dtd.c @@ -1313,7 +1313,7 @@ const char dax__flexml_version[] = "1.9.6"; #include #include -#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__) +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__) # ifndef __STRICT_ANSI__ # include # include @@ -1601,7 +1601,7 @@ const char* *dax__statenames=NULL; * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ -#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__) +#if defined(_WIN32) # ifndef __STRICT_ANSI__ # include # include diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index ae2e69aa33..02de65b661 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -721,7 +721,7 @@ void sg_config_init(int *argc, char **argv) xbt_cfg_register(&_sg_cfg_set, "contexts/guard_size", "Guard size for contexts stacks in memory pages", xbt_cfgelm_int, 1, 1, _sg_cfg_cb_context_guard_size); -#if defined(_XBT_WIN32) || (PTH_STACKGROWTH != -1) +#if defined(_WIN32) || (PTH_STACKGROWTH != -1) xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/guard_size", 0); #else xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/guard_size", 1); diff --git a/src/simix/RawContext.cpp b/src/simix/RawContext.cpp index bb1af0a2ee..e494570240 100644 --- a/src/simix/RawContext.cpp +++ b/src/simix/RawContext.cpp @@ -128,7 +128,7 @@ __asm__ ( ".text\n" ".globl _raw_makecontext\n" "_raw_makecontext:\n" -#elif defined(_XBT_WIN32) +#elif defined(_WIN32) ".text\n" ".globl raw_makecontext\n" "raw_makecontext:\n" @@ -164,7 +164,7 @@ __asm__ ( ".text\n" ".globl _raw_swapcontext\n" "_raw_swapcontext:\n" -#elif defined(_XBT_WIN32) +#elif defined(_WIN32) ".text\n" ".globl raw_swapcontext\n" "raw_swapcontext:\n" @@ -204,7 +204,7 @@ __asm__ ( ); #elif PROCESSOR_i686 __asm__ ( -#if defined(APPLE) || defined(_XBT_WIN32) +#if defined(APPLE) || defined(_WIN32) ".text\n" ".globl _raw_makecontext\n" "_raw_makecontext:\n" @@ -231,7 +231,7 @@ __asm__ ( ); __asm__ ( -#if defined(APPLE) || defined(_XBT_WIN32) +#if defined(APPLE) || defined(_WIN32) ".text\n" ".globl _raw_swapcontext\n" "_raw_swapcontext:\n" diff --git a/src/simix/smx_context.cpp b/src/simix/smx_context.cpp index e88b271d35..75ddf214f0 100644 --- a/src/simix/smx_context.cpp +++ b/src/simix/smx_context.cpp @@ -17,7 +17,7 @@ #include "simgrid/modelchecker.h" -#ifdef _XBT_WIN32 +#ifdef _WIN32 #include #include #else @@ -127,7 +127,7 @@ void *SIMIX_context_stack_new(void) if (smx_context_guard_size > 0 && !MC_is_active()) { -#if defined(_XBT_WIN32) || (PTH_STACKGROWTH != -1) +#if defined(_WIN32) || (PTH_STACKGROWTH != -1) static int warned_once = 0; if (!warned_once) { XBT_WARN("Stack overflow protection is known to be broken on your system. Either you're on Windows or PTH_STACKGROWTH != -1 (current value is %d).", @@ -143,14 +143,14 @@ void *SIMIX_context_stack_new(void) char *alloc = (char*)xbt_malloc0(size + xbt_pagesize); stack = alloc - ((uintptr_t)alloc & (xbt_pagesize - 1)) + xbt_pagesize; *((void **)stack - 1) = alloc; -#elif !defined(_XBT_WIN32) +#elif !defined(_WIN32) if (posix_memalign(&stack, xbt_pagesize, size) != 0) xbt_die("Failed to allocate stack."); #else stack = _aligned_malloc(size, xbt_pagesize); #endif -#ifndef _XBT_WIN32 +#ifndef _WIN32 if (mprotect(stack, smx_context_guard_size, PROT_NONE) == -1) { xbt_die("Failed to protect stack: %s", strerror(errno)); /* This is fatal. We are going to fail at some point when @@ -184,7 +184,7 @@ void SIMIX_context_stack_delete(void *stack) VALGRIND_STACK_DEREGISTER(valgrind_stack_id); #endif -#ifndef WIN32 +#ifndef _WIN32 if (smx_context_guard_size > 0 && !MC_is_active()) { stack = (char *)stack - smx_context_guard_size; if (mprotect(stack, smx_context_guard_size, diff --git a/src/surf/xml/simgrid_dtd.c b/src/surf/xml/simgrid_dtd.c index b2d329e200..8f9d90f2e5 100644 --- a/src/surf/xml/simgrid_dtd.c +++ b/src/surf/xml/simgrid_dtd.c @@ -4568,7 +4568,7 @@ const char surfxml_flexml_version[] = "1.9.6"; #include #include -#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__) +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__) # ifndef __STRICT_ANSI__ # include # include @@ -5222,7 +5222,7 @@ const char* *surfxml_statenames=NULL; * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ -#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__) +#if defined(_WIN32) # ifndef __STRICT_ANSI__ # include # include @@ -5991,8 +5991,8 @@ YY_RULE_SETUP if (!AX_surfxml_ASroute_src) FAIL("Required attribute `src' not set for `ASroute' element."); LEAVE; STag_surfxml_ASroute(); surfxml_pcdata_ix = 0; ETag_surfxml_ASroute(); popbuffer(); /* attribute */ switch (YY_START) { - case S_surfxml_AS: case S_surfxml_AS_3: case S_surfxml_AS_5: SET(S_surfxml_AS_6); break; - case S_surfxml_AS_1: case S_surfxml_AS_4: case S_surfxml_AS_6: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break; + case S_surfxml_AS: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break; + case S_surfxml_AS_1: case S_surfxml_AS_3: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break; } } YY_BREAK @@ -6016,8 +6016,8 @@ YY_RULE_SETUP ETag_surfxml_ASroute(); popbuffer(); /* attribute */ switch (YY_START) { - case S_surfxml_AS: case S_surfxml_AS_3: case S_surfxml_AS_5: SET(S_surfxml_AS_6); break; - case S_surfxml_AS_1: case S_surfxml_AS_4: case S_surfxml_AS_6: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break; + case S_surfxml_AS: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break; + case S_surfxml_AS_1: case S_surfxml_AS_3: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break; } } YY_BREAK diff --git a/src/xbt/ex.c b/src/xbt/ex.c index 680b110661..7a04ac6566 100644 --- a/src/xbt/ex.c +++ b/src/xbt/ex.c @@ -61,7 +61,7 @@ # define HAVE_BACKTRACE 1 /* Hello linux box */ #endif -#if defined(_XBT_WIN32) && defined(_M_IX86) && !defined(__GNUC__) +#if defined(_WIN32) && defined(_M_IX86) && !defined(__GNUC__) # define HAVE_BACKTRACE 1 /* Hello x86 windows box */ #endif @@ -126,7 +126,7 @@ void xbt_backtrace_display_current(void) #if defined(HAVE_EXECINFO_H) && defined(HAVE_POPEN) && defined(ADDR2LINE) # include "src/xbt/backtrace_linux.c" -#elif (defined(_XBT_WIN32) && defined (_M_IX86)) && !defined(__GNUC__) +#elif (defined(_WIN32) && defined (_M_IX86)) && !defined(__GNUC__) # include "src/xbt/backtrace_windows.c" #else # include "src/xbt/backtrace_dummy.c" diff --git a/src/xbt/parmap.cpp b/src/xbt/parmap.cpp index 88431cc0d2..8dff2fe504 100644 --- a/src/xbt/parmap.cpp +++ b/src/xbt/parmap.cpp @@ -11,7 +11,7 @@ #include #endif -#ifndef _XBT_WIN32 +#ifndef _WIN32 #include #endif diff --git a/src/xbt/xbt_main.c b/src/xbt/xbt_main.c index 7c6795f3b7..ff685cd3ad 100644 --- a/src/xbt/xbt_main.c +++ b/src/xbt/xbt_main.c @@ -9,7 +9,7 @@ #define XBT_LOG_LOCALLY_DEFINE_XBT_CHANNEL /* MSVC don't want it to be declared extern in headers and local here */ #include "xbt/misc.h" -#include "simgrid_config.h" /* _XBT_WIN32 */ +#include "simgrid_config.h" #include "src/internal_config.h" /* MMALLOC_WANT_OVERRIDE_LEGACY */ #include "src/portable.h" #include "xbt/sysdep.h" @@ -24,8 +24,8 @@ #include "simgrid/sg_config.h" #include -#ifdef _XBT_WIN32 -#include +#ifdef _WIN32 +#include /* To silence MSVC on abort() */ #endif XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module, xbt, "module handling"); @@ -48,7 +48,7 @@ int xbt_pagebits = 0; static void xbt_preinit(void) _XBT_GNUC_CONSTRUCTOR(200); static void xbt_postexit(void); -#ifdef _XBT_WIN32 +#ifdef _WIN32 # undef _XBT_NEED_INIT_PRAGMA #endif @@ -56,14 +56,10 @@ static void xbt_postexit(void); #pragma init (xbt_preinit) #endif -#ifdef _XBT_WIN32 +#ifdef _WIN32 #include #ifndef __GNUC__ -/* Dummy prototype to make gcc happy */ -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, - LPVOID lpvReserved); - /* Should not be necessary but for some reason, * DllMain is called twice at attachment and * at detachment.*/ @@ -71,8 +67,7 @@ static int xbt_dll_process_is_attached = 0; /* see also http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx */ /* and http://www.microsoft.com/whdc/driver/kernel/DLL_bestprac.mspx */ -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, - LPVOID lpvReserved) +static BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { if (fdwReason == DLL_PROCESS_ATTACH && xbt_dll_process_is_attached == 0) { @@ -90,7 +85,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, static void xbt_preinit(void) { unsigned int seed = 2147483647; -#ifndef _XBT_WIN32 +#ifndef _WIN32 xbt_pagesize = sysconf(_SC_PAGESIZE); #else SYSTEM_INFO si; @@ -115,7 +110,7 @@ static void xbt_preinit(void) { xbt_dict_preinit(); srand(seed); -#ifndef _XBT_WIN32 +#ifndef _WIN32 srand48(seed); #endif atexit(xbt_postexit); @@ -184,7 +179,7 @@ void xbt_abort(void) extern void __gcov_flush(void); __gcov_flush(); #endif -#ifdef _XBT_WIN32 +#ifdef _WIN32 /* It was said *in silence*. We don't want to see the error message printed * by the Microsoft's implementation of abort(). */ raise(SIGABRT); diff --git a/teshsuite/simdag/platforms/flatifier.cpp b/teshsuite/simdag/platforms/flatifier.cpp index b70a5910f9..fec3e126c0 100644 --- a/teshsuite/simdag/platforms/flatifier.cpp +++ b/teshsuite/simdag/platforms/flatifier.cpp @@ -4,7 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef _XBT_WIN32 +#include "src/internal_config.h" +#ifdef HAVE_UNISTD_H #include #endif diff --git a/tools/cmake/MaintainerMode.cmake b/tools/cmake/MaintainerMode.cmake index 91f86d6fb6..51e01cf2fe 100644 --- a/tools/cmake/MaintainerMode.cmake +++ b/tools/cmake/MaintainerMode.cmake @@ -138,8 +138,7 @@ if(enable_maintainer_mode AND NOT WIN32) set(string1 "'s/extern *\\([^(]*\\)\\( \\|\\( \\*\\)\\)/XBT_PUBLIC_DATA(\\1\\3) /'") set(string2 "'s/XBT_PUBLIC_DATA(\\([^)]*\\)) *\\([^(]*\\)(/XBT_PUBLIC(\\1) \\2(/'") set(string5 "'s/SET(DOCTYPE)/SET(ROOT_dax__adag)/'") - set(string8 "'s/#if defined(_WIN32)/#if defined(_XBT_WIN32)/g'") - set(string9 "'s/#include /#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n# ifndef __STRICT_ANSI__\\n# include \\n# include \\n# endif\\n#else\\n# include \\n#endif/g'") + set(string9 "'s/#include /#if defined(_WIN32)\\n# ifndef __STRICT_ANSI__\\n# include \\n# include \\n# endif\\n#else\\n# include \\n#endif/g'") set(string14 "'\\!^ \\* Generated [0-9/]\\{10\\} [0-9:]\\{8\\}\\.$$!d'") set(string15 "'s/FAIL(\"Premature EOF/if(!ETag_surfxml_include_state()) FAIL(\"Premature EOF/'") @@ -182,7 +181,6 @@ if(enable_maintainer_mode AND NOT WIN32) #surf/xml/simgrid_dtd.c: surf/xml/simgrid_dtd.l COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/surf/xml/simgrid_dtd.c - COMMAND ${SED_EXE} -i ${string8} src/surf/xml/simgrid_dtd.l COMMAND ${FLEX_EXE} -o src/surf/xml/simgrid_dtd.c -Psurf_parse_ --noline src/surf/xml/simgrid_dtd.l COMMAND ${SED_EXE} -i ${string9} src/surf/xml/simgrid_dtd.c COMMAND ${SED_EXE} -i ${string15} src/surf/xml/simgrid_dtd.c @@ -192,7 +190,6 @@ if(enable_maintainer_mode AND NOT WIN32) #simdag/dax_dtd.c: simdag/dax_dtd.l COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_HOME_DIRECTORY}/src/simdag/dax_dtd.c - COMMAND ${SED_EXE} -i ${string8} src/simdag/dax_dtd.l COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_HOME_DIRECTORY}/src/simdag COMMAND ${FLEX_EXE} -o src/simdag/dax_dtd.c -Pdax_ --noline src/simdag/dax_dtd.l COMMAND ${SED_EXE} -i ${string9} src/simdag/dax_dtd.c diff --git a/tools/cmake/src/internal_config.h.in b/tools/cmake/src/internal_config.h.in index 7fd37b126a..a9a62edddf 100644 --- a/tools/cmake/src/internal_config.h.in +++ b/tools/cmake/src/internal_config.h.in @@ -21,9 +21,6 @@ #ifndef _M_IX86 #cmakedefine _M_IX86 @_M_IX86@ #endif -#cmakedefine _XBT_WIN32 @_XBT_WIN32@ // this variable is set if it is a windows platform -#cmakedefine _WIN32 @_WIN32@ // this variable is set if it is a 32 bits windows platform -#cmakedefine _WIN64 @_WIN64@ // this variable is set if it is a 64 bits windows platform #cmakedefine APPLE @APPLE@ /* Set to true if enable_model-checking is true */ #cmakedefine MMALLOC_WANT_OVERRIDE_LEGACY @MMALLOC_WANT_OVERRIDE_LEGACY@ diff --git a/tools/graphicator/graphicator.c b/tools/graphicator/graphicator.c index bffc21a722..a32e74ce1e 100644 --- a/tools/graphicator/graphicator.c +++ b/tools/graphicator/graphicator.c @@ -4,15 +4,10 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifndef _XBT_WIN32 -#include -#endif - #include "simgrid/msg.h" #include "xbt/graph.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(graphicator, - "Graphicator Logging System"); +XBT_LOG_NEW_DEFAULT_CATEGORY(graphicator, "Graphicator Logging System"); int main(int argc, char **argv) {