X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2810ecbd370c15886dddb4563ae1a8e27ba161f3..addf942a7913b477a273e7a372967b200d95d12c:/src/portable.h diff --git a/src/portable.h b/src/portable.h index 3676725399..61a3ea0f43 100644 --- a/src/portable.h +++ b/src/portable.h @@ -11,7 +11,15 @@ #ifndef GRAS_PORTABLE_H #define GRAS_PORTABLE_H -#include "gras_config.h" +/* + * win32 or win64 (__WIN32 is defined for win32 and win64 applications, __TOS_WIN__ is defined by xlC). +*/ +#ifdef _WIN32 +# include "win32/config.h" +# include +#else +# include "gras_config.h" +#endif #include @@ -37,44 +45,8 @@ # include /* sometimes required for fd_set */ # endif -#ifdef HAVE_WINSOCK2_H -# include -# include /* socklen_t, but doubtful */ -# ifndef HAVE_WINSOCK_H -# define HAVE_WINSOCK_H -# endif -#elif HAVE_WINSOCK_H -# include -#endif - -#ifdef HAVE_WINSOCK_H -# define tcp_read( s, buf, len ) recv( s, buf, len, 0 ) -# define tcp_write( s, buf, len ) send( s, buf, len, 0 ) -# define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) ) -# define ioctl_t u_long -# define AC_SOCKET_INVALID ((unsigned int) ~0) - -# ifdef SD_BOTH -# define tcp_close( s ) (shutdown( s, SD_BOTH ), closesocket( s )) -# else -# define tcp_close( s ) closesocket( s ) -# endif - -# define EWOULDBLOCK WSAEWOULDBLOCK -# define EINPROGRESS WSAEINPROGRESS -# define ETIMEDOUT WSAETIMEDOUT - -# undef sock_errno -# undef sock_errstr -# define sock_errno WSAGetLastError() -# define sock_errstr(err) gras_wsa_err2string(err) -const char *gras_wsa_err2string(int errcode); - -# define S_IRGRP 0 -# define S_IWGRP 0 - -#else +#ifndef HAVE_WINSOCK_H # define tcp_read( s, buf, len) read( s, buf, len ) # define tcp_write( s, buf, len) write( s, buf, len ) # define sock_errno errno @@ -101,6 +73,11 @@ const char *gras_wsa_err2string(int errcode); # define O_BINARY 0 #endif +#ifdef HAVE_GETLINE +# define _GNU_SOURCE +# include +#endif + /**** **** Time handling ****/ @@ -116,18 +93,13 @@ const char *gras_wsa_err2string(int errcode); # endif #endif -#ifdef _WIN32 -#define sleep _sleep /* else defined in stdlib.h */ -#endif /**** **** Contexts ****/ #ifdef USE_UCONTEXT -# ifndef S_SPLINT_S /* This header drives splint into the wall */ -# include -# endif +# include #endif #ifdef _WIN32 @@ -149,10 +121,19 @@ const char *gras_wsa_err2string(int errcode); #ifdef HAVE_SNPRINTF #include #else +# if (defined(_MSC_VER) && defined(DLL_EXPORT)) + __declspec(dllexport) int snprintf(char *, size_t, const char *, /*args*/ ...); + __declspec(dllexport) int vsnprintf(char *, size_t, const char *, va_list); +# elif (defined(_MSC_VER) && !defined(DLL_EXPORT) && !defined(DLL_STATIC) ) + __declspec(dllimport) int snprintf(char *, size_t, const char *, /*args*/ ...); + __declspec(dllimport) int vsnprintf(char *, size_t, const char *, va_list); +#else extern int snprintf(char *, size_t, const char *, /*args*/ ...); extern int vsnprintf(char *, size_t, const char *, va_list); #endif +#endif + /* use internal functions when OS provided ones are borken */ #if defined(HAVE_SNPRINTF) && defined(PREFER_PORTABLE_SNPRINTF) extern int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...);