Commit 264c4e69 authored by Ben Boeckel's avatar Ben Boeckel

windows: use the proper preprocessor definitions for detecting Windows

parent 84cc5414
......@@ -22,7 +22,7 @@
#include <signal.h>
#ifndef WIN32
#ifndef _WIN32
#include <unistd.h>
#endif
......
......@@ -19,14 +19,14 @@
#include <stdlib.h>
#include <stdarg.h>
#ifndef WIN32
#ifndef _WIN32
#include <sys/time.h>
#else
#include <windows.h>
#include <winbase.h>
#endif
#ifndef WIN32
#ifndef _WIN32
double icetWallTime(void)
{
static struct timeval start = { 0, 0 };
......@@ -45,7 +45,7 @@ double icetWallTime(void)
return (tp->tv_sec - start.tv_sec) + 0.000001*(double)tp->tv_usec;
}
#else /*WIN32*/
#else /*_WIN32*/
double icetWallTime(void)
{
static DWORD start = 0;
......@@ -58,7 +58,7 @@ double icetWallTime(void)
return 0.001*(now-start);
}
}
#endif /*WIN32*/
#endif /*_WIN32*/
IceTInt icetTypeWidth(IceTEnum type)
{
......@@ -88,7 +88,7 @@ IceTInt icetTypeWidth(IceTEnum type)
return 0;
}
#ifndef WIN32
#ifndef _WIN32
IceTBoolean icetGetEnv(const char *variable_name,
char *buffer,
IceTSizeType buffer_size)
......@@ -108,7 +108,7 @@ void icetPutEnv(const char *name, const char *value)
{
setenv(name, value, ICET_TRUE);
}
#else /*WIN32*/
#else /*_WIN32*/
IceTBoolean icetGetEnv(const char *variable_name,
char *buffer,
IceTSizeType buffer_size)
......@@ -130,7 +130,7 @@ void icetPutEnv(const char *name, const char *value)
{
_putenv_s(name, value);
}
#endif /*WIN32*/
#endif /*_WIN32*/
ICET_EXPORT IceTSizeType icetSnprintf(char *buffer, IceTSizeType size,
const char *format, ...)
......@@ -139,7 +139,7 @@ ICET_EXPORT IceTSizeType icetSnprintf(char *buffer, IceTSizeType size,
IceTSizeType num_written;
va_start(format_args, format);
#ifdef WIN32
#ifdef _WIN32
num_written = _vsnprintf_s(buffer, size, _TRUNCATE, format, format_args);
#else
num_written = vsnprintf(buffer, size, format, format_args);
......
......@@ -10,17 +10,13 @@
#ifndef __IceTConfig_h
#define __IceTConfig_h
#ifndef WIN32
#cmakedefine WIN32
#endif
#cmakedefine ICET_BUILD_SHARED_LIBS
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#endif
#if defined(WIN32) && defined(ICET_BUILD_SHARED_LIBS)
#if defined(_WIN32) && defined(ICET_BUILD_SHARED_LIBS)
# ifdef IceTCore_EXPORTS
# define ICET_EXPORT __declspec( dllexport )
# define ICET_STRATEGY_EXPORT __declspec( dllexport )
......@@ -38,12 +34,12 @@
# else
# define ICET_MPI_EXPORT __declspec( dllimport )
# endif
#else /* WIN32 && SHARED_LIBS */
#else /* _WIN32 && SHARED_LIBS */
# define ICET_EXPORT
# define ICET_GL_EXPORT
# define ICET_STRATEGY_EXPORT
# define ICET_MPI_EXPORT
#endif /* WIN32 && SHARED_LIBS */
#endif /* _WIN32 && SHARED_LIBS */
#define ICET_MAJOR_VERSION @ICET_MAJOR_VERSION@
#define ICET_MINOR_VERSION @ICET_MINOR_VERSION@
......
......@@ -26,7 +26,7 @@ extern "C" {
etc.) in bytes. */
ICET_EXPORT IceTInt icetTypeWidth(IceTEnum type);
#ifdef WIN32
#ifdef _WIN32
#define strncpy(dest, src, size) strncpy_s(dest, size, src, _TRUNCATE)
#define fdopen _fdopen
#endif
......
......@@ -22,11 +22,11 @@ void write_ppm(const char *filename,
int x, y;
const unsigned char *color;
#ifndef WIN32
#ifndef _WIN32
fd = fopen(filename, "wb");
#else /*WIN32*/
#else /*_WIN32*/
fopen_s(&fd, filename, "wb");
#endif /*WIN32*/
#endif /*_WIN32*/
fprintf(fd, "P6\n");
fprintf(fd, "# %s generated by IceT test suite.\n", filename);
......
......@@ -26,7 +26,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#ifndef WIN32
#ifndef _WIN32
#include <unistd.h>
#else
#include <io.h>
......@@ -221,13 +221,13 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
realstdout = NULL;
}
icetSnprintf(filename, 64, "log.%04d", rank);
#ifndef WIN32
#ifndef _WIN32
outfd = open(filename, O_WRONLY | O_CREAT | O_APPEND, 0644);
if (outfd < 0) {
printf("Could not open %s for writing.\n", filename);
exit(1);
}
#else /*WIN32*/
#else /*_WIN32*/
if (_sopen_s(&outfd,
filename,
O_WRONLY | O_CREAT | O_APPEND,
......@@ -236,7 +236,7 @@ void initialize_test(int *argcp, char ***argvp, IceTCommunicator comm)
printf("Could not open %s for writing.\n", filename);
exit(1);
}
#endif /*WIN32*/
#endif /*_WIN32*/
dup2(outfd, 1);
} else {
realstdout = stdout;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment