Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define correctly variables for windows.
[simgrid.git] / tools / tesh2 / src / runner.c
index 79ccc08..35f0691 100644 (file)
@@ -24,7 +24,7 @@
 #include <readline.h>\r
 #include <explode.h>\r
 \r
-#ifndef WIN32\r
+#ifndef _XBT_WIN32\r
 #include <sys/resource.h>\r
 #endif\r
 \r
@@ -36,7 +36,7 @@
 \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
@@ -92,12 +92,16 @@ static const char* builtin[] =
 /* 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
@@ -121,7 +125,7 @@ runner_start_routine(void* p);
 /*static void\r
 check_syntax(void);*/\r
 \r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
 \r
 static HANDLE \r
 timer_handle = NULL;\r
@@ -206,7 +210,7 @@ runner_init(/*int check_syntax_flag, */int timeout, fstreams_t fstreams)
        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
@@ -277,7 +281,7 @@ runner_init(/*int check_syntax_flag, */int timeout, fstreams_t fstreams)
                        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
@@ -288,7 +292,7 @@ runner_init(/*int check_syntax_flag, */int timeout, fstreams_t fstreams)
                                \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
@@ -301,7 +305,7 @@ runner_init(/*int check_syntax_flag, */int timeout, fstreams_t fstreams)
                                \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
@@ -321,7 +325,7 @@ runner_init(/*int check_syntax_flag, */int timeout, fstreams_t fstreams)
                \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
@@ -378,7 +382,7 @@ runner_init(/*int check_syntax_flag, */int timeout, fstreams_t fstreams)
                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
@@ -506,7 +510,7 @@ runner_destroy(void)
        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
@@ -600,7 +604,7 @@ runner_summarize(void)
        \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
@@ -654,7 +658,7 @@ runner_summarize(void)
                \r
                printf(")\n\n");\r
                \r
-               #ifndef WIN32\r
+               #ifndef _XBT_WIN32\r
                if(!getrusage(RUSAGE_SELF, &r_usage))\r
                {\r
                \r