set(INCLUDES "${INCLUDES} -I/usr/include/")
endif(EXISTS /usr/include/)
+### Check 32bits or 64bits
+INCLUDE (CheckTypeSize)
+CHECK_TYPE_SIZE("long" SIZEOF_LONG)
+IF(SIZEOF_LONG EQUAL 4)
+ SET(ARCH_32_BITS 1)
+ELSE(SIZEOF_LONG EQUAL 4)
+ SET(ARCH_32_BITS 0)
+ENDIF(SIZEOF_LONG EQUAL 4)
+
if(WIN32)
set(INCLUDES_MORE $ENV{INCLUDE})
string(REPLACE "\\" "/" INCLUDES_MORE "${INCLUDES_MORE}")
message(" -- INCLUDES ${INCLUDES}\n\n")
set(__STRICT_ANSI__ 1)
set(_MSC_VER 1)
- set(_WIN32 1)
+ set(_XBT_WIN32 1)
+ if(BORLAND) ### BORLAND COMPILER
+ set(__BORLANDC__ 1)
+ set(_XBT_BORLANDC_COMPILER 1)
+ endif(BORLAND)
+ if(MSVC_VERSION) ### MicroSoftVisualC COMPILER
+ set(__VISUALC__ 1)
+ set(_XBT_VISUALC_COMPILER 1)
+ endif(MSVC_VERSION)
+ if(ARCH_32_BITS) ### Arch 32bits
+ set(_WIN32 1)
+ else(ARCH_32_BITS) ### Arch 64bits
+ set(_WIN64 1)
+ endif(ARCH_32_BITS)
endif(WIN32)
add_definitions (${INCLUDES})
SET(MEMORYCHECK_COMMAND "${PROJECT_DIRECTORY}/buildtools/Cmake/my_valgrind.pl")
#If you use the --read-var-info option Memcheck will run more slowly but may give a more detailed description of any illegal address.
-### Check 32bits or 64bits
-INCLUDE (CheckTypeSize)
-CHECK_TYPE_SIZE("long" SIZEOF_LONG)
-IF(SIZEOF_LONG EQUAL 4)
- SET(ARCH_32_BITS 1)
-ELSE(SIZEOF_LONG EQUAL 4)
- SET(ARCH_32_BITS 0)
-ENDIF(SIZEOF_LONG EQUAL 4)
-
INCLUDE(CTest)
ENABLE_TESTING()
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(WIN32)
- set(makecontext_CPPFLAGS_2 "-DWIN32 ${INCLUDES}")
+ set(makecontext_CPPFLAGS_2 "-D_XBT_WIN32 ${INCLUDES}")
endif(WIN32)
try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
#surf/simgrid_dtd.c: surf/simgrid_dtd.l
exec_program("${CMAKE_COMMAND} -E make_directory ${PROJECT_DIRECTORY}/src/surf")
exec_program("${FLEX_EXE} -o src/surf/simgrid_dtd.c -Psurf_parse_ --noline src/surf/simgrid_dtd.l" "${PROJECT_DIRECTORY}/")
-set(CHAINE "'s/#include <unistd.h>/#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n# ifndef __STRICT_ANSI__\\n# include <io.h>\\n# include <process.h>\\n# endif\\n#else\\n# include <unistd.h>\\n#endif/g' -i src/surf/simgrid_dtd.c")
+set(CHAINE "'s/#include <unistd.h>/#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n# ifndef __STRICT_ANSI__\\n# include <io.h>\\n# include <process.h>\\n# endif\\n#else\\n# include <unistd.h>\\n#endif/g' -i src/surf/simgrid_dtd.c")
exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}")
#xbt/graphxml.c: xbt/graphxml.l
exec_program("${CMAKE_COMMAND} -E make_directory ${PROJECT_DIRECTORY}/src/xbt")
exec_program("${FLEX_EXE} -o src/xbt/graphxml.c -Pxbt_graph_parse_ --noline src/xbt/graphxml.l" "${PROJECT_DIRECTORY}")
-set(CHAINE "'s/#include <unistd.h>/#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n# ifndef __STRICT_ANSI__\\n# include <io.h>\\n# include <process.h>\\n# endif\\n#else\\n# include <unistd.h>\\n#endif/g' -i src/xbt/graphxml.c")
+set(CHAINE "'s/#include <unistd.h>/#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n# ifndef __STRICT_ANSI__\\n# include <io.h>\\n# include <process.h>\\n# endif\\n#else\\n# include <unistd.h>\\n#endif/g' -i src/xbt/graphxml.c")
exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}")
#simdag/dax_dtd.c: simdag/dax_dtd.l
exec_program("${CMAKE_COMMAND} -E make_directory ${PROJECT_DIRECTORY}/src/simdag")
exec_program("${FLEX_EXE} -o src/simdag/dax_dtd.c -Pdax_ --noline src/simdag/dax_dtd.l" "${PROJECT_DIRECTORY}")
-set(CHAINE "'s/#include <unistd.h>/#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n# ifndef __STRICT_ANSI__\\n# include <io.h>\\n# include <process.h>\\n# endif\\n#else\\n# include <unistd.h>\\n#endif/g' -i src/simdag/dax_dtd.c")
+set(CHAINE "'s/#include <unistd.h>/#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)\\n# ifndef __STRICT_ANSI__\\n# include <io.h>\\n# include <process.h>\\n# endif\\n#else\\n# include <unistd.h>\\n#endif/g' -i src/simdag/dax_dtd.c")
exec_program("${SED_EXE} ${CHAINE}" "${PROJECT_DIRECTORY}")
elseif(HAVE_FLEXML AND HAVE_FLEX AND SED_EXE)
### Make Libs
if(WIN32)
foreach(file ${simgrid_sources})
- set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "/D DLL_EXPORT")
+ set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "/D _XBT_DLL_EXPORT")
endforeach(file ${simgrid_sources})
foreach(file ${gras_sources})
- set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "/D DLL_EXPORT")
+ set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "/D _XBT_DLL_EXPORT")
endforeach(file ${gras_sources})
endif(WIN32)
// With Cmake it creates <root>/src/gras_config.h
/* Set somes variables for Windows compilation */
+
+#ifdef _XBT_DLL_EXPORT
+ #define DLL_EXPORT
+#else
+ #define DLL_IMPORT
+#endif
+
#ifndef __STRICT_ANSI__
#cmakedefine __STRICT_ANSI__ @__STRICT_ANSI__@
#endif
#ifndef _MSC_VER
#cmakedefine _MSC_VER @_MSC_VER@
#endif
-#ifndef _WIN32
- #cmakedefine _WIN32 @_WIN32@
-#endif
-#ifndef WIN32
- #cmakedefine WIN32 @WIN32@
-#endif
-#ifdef _WIN32
- #define __VISUALC__
-#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 __VISUALC__ @__VISUALC__@
+#cmakedefine __BORLANDC__ @__BORLANDC__@
+#cmakedefine _XBT_VISUALC_COMPILER @_XBT_VISUALC_COMPILER@
+#cmakedefine _XBT_BORLANDC_COMPILER @_XBT_BORLANDC_COMPILER@
/* Set to true if enable_model-checking is true */
#cmakedefine MMALLOC_WANT_OVERIDE_LEGACY @MMALLOC_WANT_OVERIDE_LEGACY@
#include <stdio.h>
#include <stdlib.h>
-#ifdef _WIN32
+#ifdef _XBT_WIN32
#include <win32_ucontext.h>
#else
#include <ucontext.h>
#define _XOPEN_SOURCE
#endif
-#ifdef WIN32
+#ifdef _XBT_WIN32
#include "win32_ucontext.h"
#include "win32_ucontext.c"
#endif
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/misc.h" /* XBT_PUBLIC */
-#ifndef DLL_EXPORT
+
+#ifdef _XBT_DLL_EXPORT
+ #define DLL_EXPORT
+#else
#define DLL_IMPORT
#endif
/*
* Do NOT access any members of this structure directly. FIXME: move to private?
*/
-#ifdef WIN32
+#ifdef _XBT_WIN32
#define XBT_LOG_BUFF_SIZE 16384 /* Size of the static string in which we build the log string */
#else
#define XBT_LOG_BUFF_SIZE 2048 /* Size of the static string in which we build the log string */
int lineNum;
va_list ap;
va_list ap_copy; /* need a copy to launch dynamic layouts when the static ones overflowed */
-#ifdef WIN32
+#ifdef _XBT_WIN32
char *buffer;
#else
char buffer[XBT_LOG_BUFF_SIZE];
* code.
* Setting the LogEvent's valist member is done inside _log_logEvent.
*/
-#ifdef WIN32
+#ifdef _XBT_WIN32
#define _XBT_LOG_PRE(catv, priority) do { \
if (_XBT_LOG_ISENABLEDV(catv, priority)) { \
s_xbt_log_event_t _log_ev = \
* Function calling convention (not used for now)
*/
-#ifdef _WIN32
+#ifdef _XBT_WIN32
# ifndef _XBT_CALL
# define _XBT_CALL __cdecl
# endif
# define XBT_PUBLIC_DATA(type) extern type
/* Link against the DLL */
-#elif (defined(_WIN32) && !defined(DLL_EXPORT) && !defined(DLL_STATIC))
+#elif (defined(_XBT_WIN32) && !defined(DLL_EXPORT) && !defined(DLL_STATIC))
# define XBT_PUBLIC(type) __declspec(dllimport) type
# define XBT_EXPORT_NO_IMPORT(type) type
# define XBT_IMPORT_NO_EXPORT(type) __declspec(dllimport) type
int sock;
xbt_queue_shift_timed(me->socks_to_close, &sock, 0);
if (tcp_close(sock) < 0) {
-#ifdef _WIN32
+#ifdef _XBT_WIN32
WARN2("error while closing tcp socket %d: %d (%s)\n", sock, sock_errno);
#else
WARN3("error while closing tcp socket %d: %d (%s)\n",
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
# else
- #ifdef WIN32
+ #ifdef _XBT_WIN32
/* the environment, as specified by the opengroup, used to initialize the process properties */
extern char **wenviron;
#else
int gras_os_getpid(void)
{
-#ifdef _WIN32
+#ifdef _XBT_WIN32
return (long int) GetCurrentProcessId();
#else
return (long int) getpid();
#include "simgrid_config.h"
#include "xbt/misc.h"
/*
- * win32 or win64 (__WIN32 is defined for win32 and win64 applications, __TOS_WIN__ is defined by xlC).
+ * win32 or win64 (__XBT_WIN32 is defined for win32 and win64 applications, __TOS_WIN__ is defined by xlC).
*/
-#ifdef _WIN32
+#ifdef _XBT_WIN32
# include "win32/config.h"
# include <windows.h>
#else
#include <stdarg.h>
#include <ctype.h>
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
* 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(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
#include <stdarg.h>
#include <ctype.h>
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
#ifdef CONTEXT_THREADS
/* context switch based os thread */
SIMIX_ctx_thread_factory_init(&simix_global->context_factory);
-#elif !defined(WIN32)
+#elif !defined(_XBT_WIN32)
/* context switch based ucontext */
SIMIX_ctx_sysv_factory_init(&simix_global->context_factory);
#else
#endif /* CONTEXT_THREADS */
else if (!strcmp(name, "sysv"))
- #if !defined(WIN32) && !defined(CONTEXT_THREADS)
+ #if !defined(_XBT_WIN32) && !defined(CONTEXT_THREADS)
SIMIX_ctx_sysv_factory_init(factory);
#else
THROW0(not_found_error, 0, "Factory 'sysv' does not exist: no System V thread support under Windows");
# include <valgrind/valgrind.h>
#endif /* HAVE_VALGRIND_VALGRIND_H */
-#ifdef WIN32
+#ifdef _XBT_WIN32
#include "ucontext.h"
#include "ucontext.c"
#endif
#include "surf/random_mgr.h"
#include "xbt/sysdep.h"
-#ifdef WIN32
+#ifdef _XBT_WIN32
static unsigned int _seed = 2147483647;
#include <stdarg.h>
#include <ctype.h>
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
* 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(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
#include <stdarg.h>
#include <ctype.h>
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
#define MAX_DRIVE 26
#endif
-#ifdef _WIN32
+#ifdef _XBT_WIN32
#include <windows.h>
static const char *disk_drives_letter_table[MAX_DRIVE] = {
"A:\\",
"Y:\\",
"Z:\\"
};
-#endif /* #ifdef _WIN32 */
+#endif /* #ifdef _XBT_WIN32 */
/*
* Returns the initial path. On Windows the initial path is
const char *__surf_get_initial_path(void)
{
-#ifdef _WIN32
+#ifdef _XBT_WIN32
unsigned i;
char current_directory[MAX_PATH + 1] = { 0 };
unsigned int len = GetCurrentDirectory(MAX_PATH + 1, current_directory);
*/
int __surf_is_absolute_file_path(const char *file_path)
{
-#ifdef _WIN32
+#ifdef _XBT_WIN32
WIN32_FIND_DATA wfd = { 0 };
HANDLE hFile = FindFirstFile(file_path, &wfd);
#endif
}
-#ifdef WIN32
+#ifdef _XBT_WIN32
# define FILE_DELIM "\\"
#else
# define FILE_DELIM "/" /* FIXME: move to better location */
/*
- * win32 or win64 (__WIN32 is defined for win32 and win64 applications, __TOS_WIN__ is defined by xlC).
+ * win32 or win64 (__XBT_WIN32 is defined for win32 and win64 applications, __TOS_WIN__ is defined by xlC).
*/
/* If the platform is not resolved _XBT_PLATFORM_ID is set to zero. */
#endif
#if defined(_XBT_WIN32_PLATFORM) || defined(_XBT_WIN64_PLATFORM) || defined(_XBT_WIN16_PLATFORM) || defined(_XBT_WINCE_PLATFORM)
-#ifndef _WIN32
- #define _WIN32
+#ifndef _XBT_WIN32
+ #define _XBT_WIN32
#endif
#endif
-#endif /* #define __XBT_SELECT_PLATFORM_FEATURES_H__ */
\ No newline at end of file
+#endif /* #define __XBT_SELECT_PLATFORM_FEATURES_H__ */
# define HAVE_BACKTRACE 1 /* Hello linux box */
#endif
-#if defined(WIN32) && defined(_M_IX86) && !defined(__GNUC__)
+#if defined(_XBT_WIN32) && defined(_M_IX86) && !defined(__GNUC__)
# define HAVE_BACKTRACE 1 /* Hello x86 windows box */
#endif
#if defined(HAVE_EXECINFO_H) && defined(HAVE_POPEN) && defined(ADDR2LINE)
# include "backtrace_linux.c"
-#elif (defined(WIN32) && defined (_M_IX86)) && !defined(__GNUC__)
+#elif (defined(_XBT_WIN32) && defined (_M_IX86)) && !defined(__GNUC__)
# include "backtrace_windows.c"
#else
# include "backtrace_dummy.c"
#include <stdarg.h>
#include <ctype.h>
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
* 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(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
#include <stdarg.h>
#include <ctype.h>
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
+#if defined(_XBT_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__TOS_WIN__)
# ifndef __STRICT_ANSI__
# include <io.h>
# include <process.h>
va_end(ev->ap);
va_end(ev->ap_copy);
-#ifdef WIN32
+#ifdef _XBT_WIN32
free(ev->buffer);
#endif
}
#include "xbt/sysdep.h"
/*The function ffs doesn't exist for windows*/
-#ifdef WIN32
+#ifdef _XBT_WIN32
int XBT_INLINE ffs(int x)
{
int r;
#pragma fini (xbt_postexit)
#endif
-#ifdef WIN32
+#ifdef _XBT_WIN32
#include <windows.h>
/* Dummy prototype to make gcc happy */
/* ********************************* WINDOWS IMPLEMENTATION ************************************ */
-#elif defined(WIN32)
+#elif defined(_XBT_WIN32)
#include <math.h>
#include <math.h> /* floor */
-#ifdef WIN32
+#ifdef _XBT_WIN32
#include <sys/timeb.h>
#endif
#ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
gettimeofday(&tv, NULL);
-#elif defined(WIN32)
+#elif defined(_XBT_WIN32)
struct timeval tv;
# if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)
struct _timeb tm;
sleep(sec);
(void) usleep((sec - floor(sec)) * 1000000);
-#elif WIN32
+#elif _XBT_WIN32
Sleep((floor(sec) * 1000) + ((sec - floor(sec)) * 1000));
#else /* don't have usleep. Use select to sleep less than one second */
/* KEEP IT IN SYNC WITH OS IMPLEMENTATION (both win and lin) */
#ifdef HAVE_PTHREAD_H
pthread_mutex_t m;
-#elif defined(WIN32)
+#elif defined(_XBT_WIN32)
CRITICAL_SECTION lock;
#endif
};
xbt_os_mutex_destroy((xbt_os_mutex_t) mutex);
}
-#ifdef WIN32
+#ifdef _XBT_WIN32
enum { /* KEEP IT IN SYNC WITH OS IMPLEM */
SIGNAL = 0,
BROADCAST = 1,
/* KEEP IT IN SYNC WITH OS IMPLEMENTATION (both win and lin) */
#ifdef HAVE_PTHREAD_H
pthread_cond_t c;
-#elif defined(WIN32)
+#elif defined(_XBT_WIN32)
HANDLE events[MAX_EVENTS];
unsigned int waiters_count; /* the number of waiters */
/* 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 WIN32
+#ifndef _XBT_WIN32
#include <unistd.h>
#endif
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen, gras, "Stub generator");
-#ifdef _WIN32
+#ifdef _XBT_WIN32
#include <windows.h>
#endif
generate_sim(project_name);
generate_rl(project_name);
generate_makefile_local(project_name, deployment_file);
-#ifdef _WIN32
+#ifdef _XBT_WIN32
generate_borland_simulation_project(project_name);
generate_borland_real_life_project(project_name);
generate_simulation_dsp_file(project_name);
#include <stdarg.h>
-#ifdef _WIN32
+#ifdef _XBT_WIN32
/* stupid stubs so that it compiles on windows */
void generate_sim(char *project)
{
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(stubgen);
-#ifdef _WIN32
+#ifdef _XBT_WIN32
char *__gras_path = NULL;
FILE *stream = fopen(name, "w+");
fprintf(stream,
- "Ce fichier est uniquement utilisé par le gestionnaire de projets et doit être traité comme le fichier projet\n\n\nmain\n");
+ "Ce fichier est uniquement utilis� par le gestionnaire de projets et doit �tre trait� comme le fichier projet\n\n\nmain\n");
fclose(stream);
}
fprintf(project->stream, "# PROP Intermediate_Dir \"Release\"\n");
fprintf(project->stream, "# PROP Target_Dir \"\"\n");
/* TODO : the include directory */
- /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /GX /O2 /I \"./%s\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n",__gras_path); */
+ /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /GX /O2 /I \"./%s\" /D \"_XBT_WIN32\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n",__gras_path); */
fprintf(project->stream,
- "# ADD BASE CPP /nologo /W3 /GX /O2 /I \"%s\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n",
+ "# ADD BASE CPP /nologo /W3 /GX /O2 /I \"%s\" /D \"_XBT_WIN32\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n",
__gras_path);
fprintf(project->stream,
- "# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n");
+ "# ADD CPP /nologo /W3 /GX /O2 /D \"_XBT_WIN32\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n");
fprintf(project->stream, "# ADD BASE RSC /l 0x40c /d \"NDEBUG\"\n");
fprintf(project->stream, "# ADD RSC /l 0x40c /d \"NDEBUG\n");
fprintf(project->stream, "BSC32=bscmake.exe\n");
fprintf(project->stream, "# PROP Ignore_Export_Lib 0\n");
fprintf(project->stream, "# PROP Target_Dir \"\"\n");
/* TODO : the include directory */
- /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I \"./%s\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n",__gras_path); */
+ /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I \"./%s\" /D \"_XBT_WIN32\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n",__gras_path); */
fprintf(project->stream,
- "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I \"%s\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n",
+ "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I \"%s\" /D \"_XBT_WIN32\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n",
__gras_path);
fprintf(project->stream,
- "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n");
+ "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"_XBT_WIN32\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n");
fprintf(project->stream, "# ADD BASE RSC /l 0x40c /d \"_DEBUG\"\n");
fprintf(project->stream, "# ADD RSC /l 0x40c /d \"_DEBUG\"\n");
fprintf(project->stream, "BSC32=bscmake.exe\n");
#define __DEF_H
#if (defined(__BUILTIN) && !defined(__CHKCMD) && !defined(WARN_DEF_MISMATCH))
-#ifdef WIN32
+#ifdef _XBT_WIN32
#pragma message(Macro definition mismatch : __BUILTIN defined but __CHKCMD not defined)
#else
#warning "Macro definition mismatch : __BUILTIN defined but __CHKCMD not defined"
#endif
/* must be defined first */
-#ifdef WIN32
+#ifdef _XBT_WIN32
#define _WIN32_WINNT 0x0400
extern "C" {
#endif
-#ifdef WIN32
+#ifdef _XBT_WIN32
#define strdup _strdup
#define chdir _chdir
* file descriptor and pid types for portability.
*/
-#ifdef WIN32
+#ifdef _XBT_WIN32
#ifndef __FD_T_DEFINED
typedef HANDLE fd_t;
output_handling_t output_handling;
int async; /* if 1, the command is asynchronous */
- #ifdef WIN32
+ #ifdef _XBT_WIN32
char* t_command_line; /* translate the command line on Windows */
unsigned is_not_found:1;
#endif
fd_t stdout_fd; /* the stdout fd of the command */
fd_t stdin_fd; /* the stdin fd of the command */
int exit_code; /* the exit code of the command */
- #ifdef WIN32
+ #ifdef _XBT_WIN32
unsigned long stat_val;
#else
int stat_val;
char* signal; /* the signal raised by the command if any */
xbt_os_mutex_t mutex;
- #ifndef WIN32
+ #ifndef _XBT_WIN32
int killed; /* if 1, the command was killed */
int execlp_errno;
#endif
extern "C" {\r
#endif\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
\r
/* terminal line hangup */ \r
#ifndef SIGHUP\r
*/\r
#define WTERMSIG(__status) (__status)\r
\r
-#endif /* WIN32 */\r
+#endif /* _XBT_WIN32 */\r
\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
const char* \r
signal_name(DWORD got, const char* expected);\r
#else\r
#include <reader.h>\r
#include <timer.h>\r
\r
-#ifndef WIN32\r
+#ifndef _XBT_WIN32\r
#include <sys/types.h>\r
#include <sys/wait.h>\r
#include <sys/stat.h>\r
command->root->cmd_nb++;\r
xbt_os_mutex_release(mutex);\r
\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
command->killed = 0;\r
command->execlp_errno = 0;\r
#endif\r
\r
/* execute the command of the test */\r
\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
command_exec(command, command->context->command_line);\r
#else\r
/* play the translated command line on Windows */\r
return NULL;\r
}\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
\r
#ifndef BUFSIZE\r
#define BUFSIZE 4096\r
}\r
#endif\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
void\r
command_wait(command_t command)\r
{\r
while(!command->reader->done)\r
xbt_os_thread_yield();\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
CloseHandle(command->stdout_fd);\r
#else\r
close(command->stdout_fd);\r
}\r
}\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
void\r
command_kill(command_t command)\r
{\r
if(cs_successeded != command->status)\r
{\r
\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
if(command->killed)\r
printf(" <killed command>\n");\r
#endif\r
{\r
/* close the stdin and the stdout pipe handles */\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
if((*ptr)->stdin_fd != INDEFINITE_FD)\r
CloseHandle((*ptr)->stdin_fd);\r
\r
context->output_handling = oh_check;\r
context->async = 0;\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
context->t_command_line = NULL;\r
context->is_not_found = 0;\r
#endif\r
if((*ptr)->signal)\r
free((*ptr)->signal);\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
if((*ptr)->t_command_line)\r
free((*ptr)->t_command_line);\r
#endif\r
context->command_line = NULL;\r
}\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
if(context->t_command_line)\r
{\r
free(context->t_command_line);\r
dup->command_line = strdup(context->command_line);\r
\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
dup->t_command_line = strdup(context->t_command_line);\r
dup->is_not_found = context->is_not_found;\r
#endif\r
context->command_line = NULL;\r
}\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
if(context->t_command_line)\r
{\r
free(context->t_command_line);\r
#include <is_cmd.h>\r
#include <getpath.h>\r
\r
-#ifndef WIN32\r
+#ifndef _XBT_WIN32\r
#include <xsignal.h>\r
#endif\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
static int\r
is_w32_cmd(char* cmd, char** path)\r
{\r
return 0;\r
}\r
\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
sprintf(path,"%s/%s",fstream->directory, fstream->name);\r
#else\r
sprintf(path,"%s\\%s",fstream->directory, fstream->name);\r
\r
if(context->command_line)\r
{\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
if(!context->is_not_found)\r
{\r
#endif\r
if(fstream_launch_command(fstream, context, mutex) < 0)\r
break;\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
}\r
#endif\r
}\r
/* Check that last command of the file ran well */\r
if(context->command_line)\r
{\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
if(!context->is_not_found)\r
{\r
#endif\r
if(fstream_launch_command(fstream, context, mutex) < 0)\r
return -1;\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
}\r
#endif\r
}\r
context->line = /*strdup(filepos)*/ filepos;\r
context->pos = strdup(filepos);\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
{\r
\r
/* translate the command line */\r
\r
xbt_str_trim(context->signal," \n");\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
if(!strstr("SIGSEGVSIGTRAPSIGBUSSIGFPESIGILL", context->signal))\r
{\r
ERROR2("[%s] Signal `%s' not supported by this platform", filepos, context->signal);\r
{\r
if(exists)\r
{\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
unsetenv(name);\r
#else\r
SetEnvironmentVariable(name, NULL);\r
free(variable->val);\r
variable->val = strdup(val);\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
SetEnvironmentVariable(variable->name, variable->val);\r
#else\r
setenv(variable->name, variable->val, 1);\r
\r
xbt_dynar_push(unit->runner->variables, &variable);\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
SetEnvironmentVariable(variable->name, variable->val);\r
#else\r
setenv(variable->name, variable->val, 0);\r
#include <sys/types.h>\r
#include <sys/stat.h>\r
\r
-#ifndef WIN32\r
+#ifndef _XBT_WIN32\r
#include <pwd.h>\r
#else\r
#endif\r
#define PATH_MAX 255\r
#endif\r
\r
-#ifndef WIN32\r
+#ifndef _XBT_WIN32\r
int\r
getpath(const char* file, char** path)\r
{\r
/* logs */
XBT_LOG_NEW_DEFAULT_CATEGORY(tesh,"TEst SHell utility");
-#ifdef WIN32
+#ifdef _XBT_WIN32
/* Windows specific : the previous process error mode */
static UINT
prev_error_mode = 0;
static int
sig_int = 0;
-#ifdef WIN32
+#ifdef _XBT_WIN32
static void
sig_int_handler(int signum)
{
/* then, finalize tesh (release all the allocated memory and exits) */
finalize();
- #ifndef WIN32
+ #ifndef _XBT_WIN32
return exit_code;
#endif
char* buffer;
char* suffix = strdup(".tesh");
- #ifdef WIN32
+ #ifdef _XBT_WIN32
/* Windows specific : don't display the general-protection-fault message box and
* the the critical-error-handler message box (instead the system send the error
* to the calling process : tesh)
xbt_os_sem_destroy(units_sem);
/* Windows specific (restore the previouse error mode */
- #ifdef WIN32
+ #ifdef _XBT_WIN32
SetErrorMode(prev_error_mode);
#endif
/* get to the last / (if any) to get the short name of the file */
delimiter = strrchr(optarg,'/');
- #ifdef WIN32
+ #ifdef _XBT_WIN32
if(!delimiter)
delimiter = strrchr(optarg,'\\');
#endif
delimiter = strrchr(optarg,'/');
- #ifdef WIN32
+ #ifdef _XBT_WIN32
if(!delimiter)
delimiter = strrchr(optarg,'\\');
#endif
delimiter = strrchr(optarg,'/');
- #ifdef WIN32
+ #ifdef _XBT_WIN32
if(!delimiter)
delimiter = strrchr(optarg,'\\');
#endif
if(!screen_cleaned)
{
- #ifdef WIN32
+ #ifdef _XBT_WIN32
system("cls");
#else
system("clear");
{
if(!screen_cleaned)
{
- #ifdef WIN32
+ #ifdef _XBT_WIN32
system("cls");
#else
system("clear");
reader->thread = xbt_os_thread_create("", reader_start_routine, reader);\r
}\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
static void*\r
reader_start_routine(void* p)\r
{\r
#include <readline.h>\r
#include <explode.h>\r
\r
-#ifndef WIN32\r
+#ifndef _XBT_WIN32\r
#include <sys/resource.h>\r
#endif\r
\r
\r
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);\r
\r
-#if (!defined(__BUILTIN) && defined(__CHKCMD) && !defined(WIN32))\r
+#if (!defined(__BUILTIN) && defined(__CHKCMD) && !defined(_XBT_WIN32))\r
static const char* builtin[] =\r
{\r
"alias",\r
/* under darwin, the environment gets added to the process at startup time. So, it's not defined at library link time, forcing us to extra tricks */\r
# include <crt_externs.h>\r
# define environ (*_NSGetEnviron())\r
-# elif !defined(WIN32)\r
- /* the environment, as specified by the opengroup, used to initialize the process properties */\r
- extern char **environ;\r
+# else\r
+ #ifdef _XBT_WIN32\r
+ /* the environment, as specified by the opengroup, used to initialize the process properties */\r
+ # define environ **wenviron;\r
+ #else\r
+ extern char **environ;\r
+ #endif\r
# endif\r
\r
-#ifndef WIN32\r
+#ifndef _XBT_WIN32\r
extern char**\r
environ;\r
#endif\r
/*static void\r
check_syntax(void);*/\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
\r
static HANDLE \r
timer_handle = NULL;\r
const char* cstr;\r
variable_t variable;\r
\r
- #if (defined(__CHKCMD) && defined(__BUILTIN) && !defined(WIN32))\r
+ #if (defined(__CHKCMD) && defined(__BUILTIN) && !defined(_XBT_WIN32))\r
FILE* s;\r
int n = 0;\r
size_t len;\r
variable->env = 1;\r
xbt_dynar_push(runner->variables, &variable);\r
\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
if(!strcmp("PATH", buffer))\r
#else\r
if(!strcmp("Path", buffer) || !strcmp("PATH", buffer))\r
\r
/* get the list of paths */\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
runner->path = explode(';', val);\r
#else\r
runner->path = explode(':', val);\r
\r
len = strlen(p);\r
\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
for(j = len - 1; p[j] == '/' || p[j] == ' '; j--)\r
#else\r
for(j = len - 1; p[j] == '\\' || p[j] == ' '; j--)\r
\r
sprintf(buffer,"%d",getpid());\r
\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
setenv("TESH_PPID", buffer, 0);\r
setenv("TESH_DIR", tesh_dir, 0);\r
#else\r
check_syntax();\r
*/\r
\r
- #if (!defined(WIN32) && defined(__CHKCMD))\r
+ #if (!defined(_XBT_WIN32) && defined(__CHKCMD))\r
#if defined(__BUILTIN)\r
\r
if(!is_tesh_root)\r
if(runner->variables)\r
xbt_dynar_free(&runner->variables);\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
CloseHandle(timer_handle);\r
#endif\r
\r
\r
if(!dry_run_flag)\r
{\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
struct rusage r_usage;\r
#else\r
FILETIME start_time;\r
\r
printf(")\n\n");\r
\r
- #ifndef WIN32\r
+ #ifndef _XBT_WIN32\r
if(!getrusage(RUSAGE_SELF, &r_usage))\r
{\r
\r
writer->thread = xbt_os_thread_create("", writer_start_routine, writer);\r
}\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
static void*\r
writer_start_routine(void* p)\r
{\r
\r
#include <stdio.h>\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
static char *\r
w32error_to_string(DWORD errcode) \r
{\r
if(err[i].code == errcode && err[i].kind == kind)\r
return err[i].string;\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
\r
/* assume it's a W32 error */\r
return w32error_to_string((DWORD)errcode);\r
\r
#include <xsignal.h>\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
int\r
is_an_unhandled_exception(DWORD exit_code);\r
\r
{"SIG UNKNOWN" ,-1}\r
};\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
const char* signal_name(DWORD got, const char* expected) \r
#else\r
const char* signal_name(unsigned int got, char *expected) \r
{\r
int i;\r
\r
- #ifdef WIN32\r
+ #ifdef _XBT_WIN32\r
\r
for (i=0; i < MAX_EXECPTION; i++)\r
if (exceptions[i].value == got)\r
}\r
\r
\r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
int\r
is_an_unhandled_exception(DWORD exit_code)\r
{\r