From 5c63cd8345572e9d2b4538ff0eaad9b680029f7b Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Sun, 22 Aug 2010 22:29:21 +0200 Subject: [PATCH] When compiling for the Windows API, define ECL_MS_WINDOWS_HOST instead of checking for mingw or _MSC_VER separately (Gabriel Dos Reis) --- src/c/alloc_2.d | 4 +-- src/c/ecl_features.h | 5 +++- src/c/error.d | 4 +-- src/c/file.d | 14 +++++----- src/c/gbc.d | 4 +-- src/c/load.d | 60 ++++++++++++++++++++++++++++--------------- src/c/main.d | 8 +++--- src/c/num_rand.d | 2 +- src/c/pathname.d | 6 ++--- src/c/print.d | 8 +++--- src/c/symbols_list.h | 2 +- src/c/symbols_list2.h | 2 +- src/c/tcp.d | 26 +++++++++---------- src/c/threads.d | 2 +- src/c/threads_mutex.d | 2 +- src/c/time.d | 10 ++++---- src/c/unixfsys.d | 18 ++++++------- src/c/unixint.d | 10 ++++---- src/c/unixsys.d | 12 ++++----- src/h/config.h.in | 16 +++++++----- src/h/ecl.h | 4 +-- src/h/external.h | 6 ++--- src/h/internal.h | 2 +- 23 files changed, 127 insertions(+), 100 deletions(-) diff --git a/src/c/alloc_2.d b/src/c/alloc_2.d index 1c5224210..b0078d4be 100755 --- a/src/c/alloc_2.d +++ b/src/c/alloc_2.d @@ -1033,7 +1033,7 @@ standard_finalizer(cl_object o) case t_lock: { const cl_env_ptr the_env = ecl_process_env(); ecl_disable_interrupts_env(the_env); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) CloseHandle(o->lock.mutex); #else pthread_mutex_destroy(&o->lock.mutex); @@ -1044,7 +1044,7 @@ standard_finalizer(cl_object o) case t_condition_variable: { const cl_env_ptr the_env = ecl_process_env(); ecl_disable_interrupts_env(the_env); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) CloseHandle(o->condition_variable.cv); #else pthread_cond_destroy(&o->condition_variable.cv); diff --git a/src/c/ecl_features.h b/src/c/ecl_features.h index d81000c34..753c22b3b 100644 --- a/src/c/ecl_features.h +++ b/src/c/ecl_features.h @@ -63,10 +63,13 @@ ecl_def_string_array(feature_names,static,const) = { ecl_def_string_array_elt("MINGW32"), ecl_def_string_array_elt("WIN32"), #endif +#if defined(__WIN64__) + ecl_def_string_array_elt("WIN64"), +#endif #ifdef _MSC_VER ecl_def_string_array_elt("MSVC"), #endif -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) ecl_def_string_array_elt("WINDOWS"), #endif #ifdef ECL_CMU_FORMAT diff --git a/src/c/error.d b/src/c/error.d index 56db13831..2619e2e73 100644 --- a/src/c/error.d +++ b/src/c/error.d @@ -21,7 +21,7 @@ #include #include #include -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(cygwin) +#if defined(ECL_MS_WINDOWS_HOST) || defined(cygwin) #include #endif #include @@ -444,7 +444,7 @@ FElibc_error(const char *msg, int narg, ...) make_constant_base_string(strerror(errno))); } -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(cygwin) +#if defined(ECL_MS_WINDOWS_HOST) || defined(cygwin) void FEwin32_error(const char *msg, int narg, ...) { diff --git a/src/c/file.d b/src/c/file.d index ab9206599..0bb8d5b78 100755 --- a/src/c/file.d +++ b/src/c/file.d @@ -29,7 +29,7 @@ # include #endif #include -#if !defined(__MINGW32__) && !defined(_MSC_VER) +#if !defined(ECL_MS_WINDOWS_HOST) #include /* it isn't pulled in by fcntl.h */ #endif @@ -45,7 +45,7 @@ # include # include # include -#elif defined(__MINGW32__) || defined(_MSC_VER) +#elif defined(ECL_MS_WINDOWS_HOST) # include # include # define STDIN_FILENO 0 @@ -2649,7 +2649,7 @@ static void io_file_clear_input(cl_object strm) { int f = IO_FILE_DESCRIPTOR(strm); -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) if (isatty(f)) { /* Flushes Win32 console */ if (!FlushConsoleInputBuffer((HANDLE)_get_osfhandle(f))) @@ -3308,7 +3308,7 @@ static void io_stream_clear_input(cl_object strm) { FILE *fp = IO_STREAM_FILE(strm); -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) int f = fileno(fp); if (isatty(f)) { /* Flushes Win32 console */ @@ -4475,7 +4475,7 @@ ecl_open_stream(cl_object fn, enum ecl_smmode smm, cl_object if_exists, cl_env_ptr the_env = &cl_env; cl_object x; int f; -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) int mode = _S_IREAD | _S_IWRITE; #else mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; @@ -4685,7 +4685,7 @@ ecl_open_stream(cl_object fn, enum ecl_smmode smm, cl_object if_exists, static int file_listen(int fileno) { -#if !defined(__MINGW32__) && !defined(_MSC_VER) +#if !defined(ECL_MS_WINDOWS_HOST) # if defined(HAVE_SELECT) fd_set fds; int retv, fd; @@ -5058,7 +5058,7 @@ init_file(void) cl_object aux; cl_object null_stream; cl_object external_format = Cnil; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) # ifdef ECL_UNICODE external_format = cl_list(2, @':latin-1', @':crlf'); flags = 0; diff --git a/src/c/gbc.d b/src/c/gbc.d index c4d4801f0..718ab17df 100644 --- a/src/c/gbc.d +++ b/src/c/gbc.d @@ -661,14 +661,14 @@ sweep_phase(void) break; #ifdef ECL_THREADS case t_lock: -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) CloseHandle(x->lock.mutex); #else pthread_mutex_destroy(&x->lock.mutex); #endif break; case t_condition_variable: -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) CloseHandle(x->condition_variable.cv); #else pthread_cond_destroy(&x->condition_variable.cv); diff --git a/src/c/load.d b/src/c/load.d index 5fd54fda7..91b64a1ab 100755 --- a/src/c/load.d +++ b/src/c/load.d @@ -14,9 +14,33 @@ See file '../Copyright' for full details. */ -#include #include #include +#include +/* + * Choosing the interface for loading binary files. Currently we recognize + * three different methods: + * - Windows API, provided by ECL_MS_WINDOWS_HOST + * - dlopen, provided HAVE_DLFCN_H is defined + * - NSLinkModule, provided HAVE_MACH_O_DYLD_H is defined + * They are chosen in this precise order. In order to make the code for these + * methods mutually exclusive, when one method is present, the other macros + * get undefined. Handling of dynamically loaded libraries is constrained to + * this file and thus the changes can be limited to this file. + */ +#ifdef ECL_MS_WINDOWS_HOST +# ifdef HAVE_DLFCN_H +# undef HAVE_DLFCN_H +# endif +# ifdef HAVE_MACH_O_DYLD_H +# undef HAVE_MACH_O_DYLD_H +# endif +#endif +#ifdef HAVE_DLFCN_H +# ifdef HAVE_MACH_O_DYLD_H +# undef HAVE_MACH_O_DYLD_H +# endif +#endif #ifdef ENABLE_DLOPEN # ifdef cygwin # include @@ -24,22 +48,18 @@ # ifdef HAVE_DLFCN_H # include # define INIT_PREFIX "init_fas_" -# endif -# ifdef HAVE_MACH_O_DYLD_H -# ifndef HAVE_DLFCN_H -# include -# define INIT_PREFIX "_init_fas_" -# else -# undef HAVE_MACH_O_DYLD_H -# endif # ifdef bool # undef bool # endif # endif +# ifdef HAVE_MACH_O_DYLD_H +# include +# define INIT_PREFIX "_init_fas_" +# endif # ifdef HAVE_LINK_H # include # endif -# if defined(__MINGW32__) || defined(_MSC_VER) +# if defined(ECL_MS_WINDOWS_HOST) # include # include # include @@ -48,7 +68,7 @@ # else # include # endif -#endif +#endif /* ENABLE_DLOPEN */ #include #include #include @@ -72,7 +92,7 @@ copy_object_file(cl_object original) * file we load later on (case of Windows, which locks files that are loaded). * The symlinks do not seem to work in latest versions of Linux. */ -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) ecl_disable_interrupts(); err = !CopyFile(original->base_string.self, copy->base_string.self, 0); ecl_enable_interrupts(); @@ -164,7 +184,7 @@ ecl_library_open(cl_object filename, bool force_reload) { * _always_ made because otherwise it cannot be * overwritten. In Unix we need only do that when the * file has been previously loaded. */ -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(cygwin) +#if defined(ECL_MS_WINDOWS_HOST) || defined(cygwin) filename = copy_object_file(filename); self_destruct = 1; #else @@ -214,7 +234,7 @@ ecl_library_open(cl_object filename, bool force_reload) { block->cblock.handle = out; }} #endif -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) block->cblock.handle = LoadLibrary(filename_string); #endif ecl_enable_interrupts(); @@ -256,7 +276,7 @@ ecl_library_symbol(cl_object block, const char *symbol, bool lock) { if (p) return p; } ecl_disable_interrupts(); -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) { HANDLE hndSnap = NULL; HANDLE hnd = NULL; @@ -279,7 +299,7 @@ ecl_library_symbol(cl_object block, const char *symbol, bool lock) { #ifdef HAVE_DLFCN_H p = dlsym(0, symbol); #endif -#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(HAVE_DLFCN_H) +#if !defined(ECL_MS_WINDOWS_HOST) && !defined(HAVE_DLFCN_H) p = 0; #endif ecl_enable_interrupts(); @@ -288,7 +308,7 @@ ecl_library_symbol(cl_object block, const char *symbol, bool lock) { #ifdef HAVE_DLFCN_H p = dlsym(block->cblock.handle, symbol); #endif -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) { HMODULE h = (HMODULE)(block->cblock.handle); p = GetProcAddress(h, symbol); @@ -331,7 +351,7 @@ ecl_library_error(cl_object block) { output = make_base_string_copy(message); } #endif -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) { const char *message; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | @@ -365,7 +385,7 @@ ecl_library_close(cl_object block) { #ifdef HAVE_MACH_O_DYLD_H NSUnLinkModule(block->cblock.handle, NSUNLINKMODULE_OPTION_NONE); #endif -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) FreeLibrary(block->cblock.handle); #endif ecl_enable_interrupts(); @@ -584,7 +604,7 @@ NOT_A_FILENAME: if (!Null(function)) { ok = funcall(5, function, filename, verbose, print, external_format); } else { -#if 0 /* defined(ENABLE_DLOPEN) && !defined(__MINGW32__) && !defined(_MSC_VER)*/ +#if 0 /* defined(ENABLE_DLOPEN) && !defined(ECL_MS_WINDOWS_HOST)*/ /* * DISABLED BECAUSE OF SECURITY ISSUES! * In systems where we can do this, we try to load the file diff --git a/src/c/main.d b/src/c/main.d index fcde9b7ca..debda2697 100644 --- a/src/c/main.d +++ b/src/c/main.d @@ -19,7 +19,7 @@ #include #include -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) # include # include # define MAXPATHLEN 512 @@ -819,7 +819,7 @@ si_setenv(cl_object var, cl_object value) * the right thing. */ unsetenv((char*)var->base_string.self); #else -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) si_setenv(var, make_simple_base_string("")); #else putenv((char*)var->base_string.self); @@ -857,7 +857,7 @@ si_environ(void) } output = cl_nreverse(output); #else -# if defined(_MSC_VER) || defined(__MINGW32__) +# if defined(ECL_MS_WINDOWS_HOST) LPTCH p; for (p = GetEnvironmentStrings(); *p; ) { output = CONS(make_constant_base_string(p), output); @@ -876,7 +876,7 @@ si_pointer(cl_object x) @(return ecl_make_unsigned_integer((cl_index)x)) } -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) void ecl_get_commandline_args(int* argc, char*** argv) { LPWSTR *wArgs; diff --git a/src/c/num_rand.d b/src/c/num_rand.d index 447856e90..08d26079e 100644 --- a/src/c/num_rand.d +++ b/src/c/num_rand.d @@ -67,7 +67,7 @@ init_random_state() cl_object a = ecl_alloc_simple_base_string(bytes); ulong *mt = (ulong*)a->base_string.self; int j; -#if !defined(_MSC_VER) && !defined(__MINGW32__) +#if !defined(ECL_MS_WINDOWS_HOST) FILE *fp = fopen("/dev/urandom","r"); if (fp) { fread(mt, sizeof(*mt), MT_N, fp); diff --git a/src/c/pathname.d b/src/c/pathname.d index 9c36f4b47..5801010cc 100644 --- a/src/c/pathname.d +++ b/src/c/pathname.d @@ -607,7 +607,7 @@ ecl_parse_namestring(cl_object s, cl_index start, cl_index end, cl_index *ep, * we need "//FOO/" to be separately handled, for it is a shared * resource. */ -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) if ((start+1 <= end) && is_slash(ecl_char(s, start))) { device = Cnil; goto maybe_parse_host; @@ -813,7 +813,7 @@ coerce_to_file_pathname(cl_object pathname) pathname = coerce_to_physical_pathname(pathname); pathname = cl_merge_pathnames(1, pathname); #if 0 -#if !defined(cygwin) && !defined(__MINGW32__) && !defined(_MSC_VER) +#if !defined(cygwin) && !defined(ECL_MS_WINDOWS_HOST) if (pathname->pathname.device != Cnil) FEerror("Device ~S not yet supported.", 1, pathname->pathname.device); @@ -964,7 +964,7 @@ ecl_namestring(cl_object x, int flags) writestr_stream(":", buffer); } if (host != Cnil) { -#if !defined(_MSC_VER) && !defined(__MINGW32__) +#if !defined(ECL_MS_WINDOWS_HOST) if (y == Cnil) { writestr_stream("file:", buffer); } diff --git a/src/c/print.d b/src/c/print.d index f033bf32a..15e1ac68f 100644 --- a/src/c/print.d +++ b/src/c/print.d @@ -551,7 +551,7 @@ int edit_double(int n, DBL_TYPE d, int *sp, char *s, int *ep) { char *exponent, buff[DBL_SIZE + 1]; int length; -#if defined(HAVE_FENV_H) || defined(_MSC_VER) || defined(__MINGW32__) +#if defined(HAVE_FENV_H) || defined(ECL_MS_WINDOWS_HOST) fenv_t env; feholdexcept(&env); #endif @@ -605,7 +605,7 @@ int edit_double(int n, DBL_TYPE d, int *sp, char *s, int *ep) s[i] = '0'; } s[n] = '\0'; -#if defined(HAVE_FENV_H) || defined(_MSC_VER) || defined(__MINGW32__) +#if defined(HAVE_FENV_H) || defined(ECL_MS_WINDOWS_HOST) feupdateenv(&env); #endif return length; @@ -615,7 +615,7 @@ static void write_double(DBL_TYPE d, int e, int n, cl_object stream, cl_object o) { int exp; -#if defined(HAVE_FENV_H) || defined(_MSC_VER) || defined(__MINGW32__) +#if defined(HAVE_FENV_H) || defined(ECL_MS_WINDOWS_HOST) fenv_t env; feholdexcept(&env); #endif @@ -696,7 +696,7 @@ write_double(DBL_TYPE d, int e, int n, cl_object stream, cl_object o) } write_decimal(exp, stream); } -#if defined(HAVE_FENV_H) || defined(_MSC_VER) || defined(__MINGW32__) +#if defined(HAVE_FENV_H) || defined(ECL_MS_WINDOWS_HOST) feupdateenv(&env); #endif } diff --git a/src/c/symbols_list.h b/src/c/symbols_list.h index b5908a51f..4f85f3071 100755 --- a/src/c/symbols_list.h +++ b/src/c/symbols_list.h @@ -1874,7 +1874,7 @@ cl_symbols[] = { {EXT_ "EXTERNAL-PROCESS-WAIT", EXT_ORDINARY, si_external_process_wait, -1, OBJNULL}, -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) {SYS_ "CLOSE-WINDOWS-HANDLE", SI_ORDINARY, si_close_windows_handle, 1, OBJNULL}, #endif diff --git a/src/c/symbols_list2.h b/src/c/symbols_list2.h index aaf11dece..dd4baa98c 100755 --- a/src/c/symbols_list2.h +++ b/src/c/symbols_list2.h @@ -1874,7 +1874,7 @@ cl_symbols[] = { {EXT_ "EXTERNAL-PROCESS-WAIT","si_external_process_wait"}, -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) {SYS_ "CLOSE-WINDOWS-HANDLE","si_close_windows_handle"}, #endif diff --git a/src/c/tcp.d b/src/c/tcp.d index 9579e2a48..c4b8d0231 100644 --- a/src/c/tcp.d +++ b/src/c/tcp.d @@ -18,7 +18,7 @@ #include #include -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) #include #else extern int errno; @@ -32,7 +32,7 @@ extern int errno; #endif #include -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) #include #else #include @@ -41,7 +41,7 @@ extern int errno; /* Maximum length for a unix socket pathname */ #define UNIX_MAX_PATH 107 -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) WSADATA wsadata; int wsock_initialized = 0; #define INIT_TCP \ @@ -59,7 +59,7 @@ int wsock_initialized = 0; void ecl_tcp_close_all(void) { -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) if ( wsock_initialized ) { WSACleanup(); @@ -83,7 +83,7 @@ int connect_to_server(char *host, int port) struct sockaddr *addr; /* address to connect to */ struct hostent *host_ptr; int addrlen; /* length of address */ -#if !defined(_MSC_VER) && !defined(__MINGW32__) +#if !defined(ECL_MS_WINDOWS_HOST) extern char *getenv(); extern struct hostent *gethostbyname(); #endif @@ -101,7 +101,7 @@ int connect_to_server(char *host, int port) /* Check the address type for an internet host. */ if (host_ptr->h_addrtype != AF_INET) { /* Not an Internet host! */ -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) errno = WSAEPROTOTYPE; #else errno = EPROTOTYPE; @@ -129,7 +129,7 @@ int connect_to_server(char *host, int port) ecl_disable_interrupts(); #ifdef TCP_NODELAY /* make sure to turn off TCP coalescence */ -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) { char mi; setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof (char)); } @@ -140,7 +140,7 @@ int connect_to_server(char *host, int port) #endif #endif if (connect(fd, addr, addrlen) == -1) { -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) closesocket(fd); #else (void) close (fd); @@ -179,7 +179,7 @@ create_server_port(int port) #ifdef SO_REUSEADDR /* Necesary to restart the server without a reboot */ -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) { char one = 1; setsockopt(request, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(char)); @@ -193,7 +193,7 @@ create_server_port(int port) #endif /* SO_REUSEADDR */ #ifdef TCP_NODELAY /* make sure to turn off TCP coalescence */ -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) { char mi; setsockopt(request, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof (char)); } @@ -207,7 +207,7 @@ create_server_port(int port) /* Set up the socket data. */ memset((char *)&inaddr, 0, sizeof(inaddr)); inaddr.sin_family = AF_INET; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) inaddr.sin_port = htons((unsigned short)port); #else inaddr.sin_port = htons(port); @@ -291,7 +291,7 @@ si_open_client_stream(cl_object host, cl_object port) if (fd == 0) @(return Cnil) -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) stream = ecl_make_stream_from_fd(host, fd, smm_io_wsock, 8, 0, Cnil); #else stream = ecl_make_stream_from_fd(host, fd, smm_io, 8, 0, Cnil); @@ -328,7 +328,7 @@ si_open_server_stream(cl_object port) cl_object si_open_unix_socket_stream(cl_object path) { -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) FEerror("UNIX socket not supported under Win32 platform", 0); #else int fd; /* file descriptor */ diff --git a/src/c/threads.d b/src/c/threads.d index 9d5a6e45d..e1ee87b67 100644 --- a/src/c/threads.d +++ b/src/c/threads.d @@ -16,7 +16,7 @@ #ifndef __sun__ /* See unixinit.d for this */ #define _XOPEN_SOURCE 600 /* For pthread mutex attributes */ #endif -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) # include #else # include diff --git a/src/c/threads_mutex.d b/src/c/threads_mutex.d index c06528026..ab0649e9a 100644 --- a/src/c/threads_mutex.d +++ b/src/c/threads_mutex.d @@ -16,7 +16,7 @@ #ifndef __sun__ /* See unixinit.d for this */ #define _XOPEN_SOURCE 600 /* For pthread mutex attributes */ #endif -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) # include #else # include diff --git a/src/c/time.d b/src/c/time.d index 51b4ee682..802f4b264 100644 --- a/src/c/time.d +++ b/src/c/time.d @@ -32,12 +32,12 @@ # include #endif #include -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) #include #include #endif -#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_GETRUSAGE) && !defined(__MINGW32__) && !defined(_MSC_VER) +#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_GETRUSAGE) && !defined(ECL_MS_WINDOWS_HOST) struct timeval { long tv_sec; long tv_usec; @@ -53,7 +53,7 @@ get_real_time(struct timeval *tv) struct timezone tz; gettimeofday(tv, &tz); #else -# if defined(__MINGW32__) || defined(_MSC_VER) +# if defined(ECL_MS_WINDOWS_HOST) DWORD x = GetTickCount(); tv->tv_sec = x / 1000; tv->tv_usec = (x % 1000) * 1000; @@ -79,7 +79,7 @@ get_run_time(struct timeval *tv) tv->tv_sec = buf.tms_utime / CLK_TCK; tv->tv_usec = (buf.tms_utime % CLK_TCK) * 1000000; # else -# if defined(__MINGW32__) || defined(_MSC_VER) +# if defined(ECL_MS_WINDOWS_HOST) FILETIME creation_time; FILETIME exit_time; FILETIME kernel_time; @@ -135,7 +135,7 @@ cl_sleep(cl_object z) nanosleep(&tm, NULL); } #else -#if defined (__MINGW32__) || defined(_MSC_VER) +#if defined (ECL_MS_WINDOWS_HOST) { double r = ecl_to_double(z) * 1000; SleepEx((long)r, TRUE); diff --git a/src/c/unixfsys.d b/src/c/unixfsys.d index c5c5c6585..56b5b7a8d 100644 --- a/src/c/unixfsys.d +++ b/src/c/unixfsys.d @@ -41,7 +41,7 @@ # include # endif #endif -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) # include # undef ERROR #endif @@ -86,7 +86,7 @@ safe_lstat(const char *path, struct stat *sb) } #endif -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) static cl_object drive_host_prefix(cl_object pathname) { @@ -169,7 +169,7 @@ current_dir(void) { static cl_object file_kind(char *filename, bool follow_links) { cl_object output; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) DWORD dw; ecl_disable_interrupts(); dw = GetFileAttributes( filename ); @@ -208,7 +208,7 @@ si_file_kind(cl_object filename, cl_object follow_links) { @(return file_kind((char*)filename->base_string.self, !Null(follow_links))) } -#if defined(HAVE_LSTAT) && !defined(__MINGW32__) && !defined(_MSV_VER) +#if defined(HAVE_LSTAT) && !defined(ECL_MS_WINDOWS_HOST) static cl_object si_readlink(cl_object filename) { /* Given a filename which is a symlink, this routine returns @@ -407,7 +407,7 @@ ecl_backup_open(const char *filename, int option, int mode) strcat(strcpy(backupfilename, filename), ".BAK"); ecl_disable_interrupts(); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) /* Windows' rename doesn't replace an existing file */ if (access(backupfilename, F_OK) == 0 && unlink(backupfilename)) { ecl_enable_interrupts(); @@ -475,7 +475,7 @@ ecl_file_len(int f) } { ecl_disable_interrupts(); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) error = SetErrorMode(0); if (MoveFile((char*)old_filename->base_string.self, (char*)new_filename->base_string.self)) { @@ -902,7 +902,7 @@ si_get_library_pathname(void) goto OUTPUT; } } -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) { char *buffer; HMODULE hnd; @@ -981,7 +981,7 @@ si_mkdir(cl_object directory, cl_object mode) filename->base_string.self[--filename->base_string.fillp] = 0; ecl_disable_interrupts(); -#if defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) ok = mkdir((char*)filename->base_string.self); #else ok = mkdir((char*)filename->base_string.self, modeint); @@ -1000,7 +1000,7 @@ si_mkstemp(cl_object template) cl_index l; int fd; -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) cl_object phys, dir, file; char strTempDir[MAX_PATH]; char strTempFileName[MAX_PATH]; diff --git a/src/c/unixint.d b/src/c/unixint.d index 528afecd3..39fd500eb 100644 --- a/src/c/unixint.d +++ b/src/c/unixint.d @@ -88,7 +88,7 @@ # endif # include #endif -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) # include #endif #if !defined(_MSC_VER) @@ -254,7 +254,7 @@ handler_fn_protype(lisp_signal_handler, int sig, siginfo_t *info, void *aux) /* The lisp environment might not be installed. */ if (the_env == NULL) return; -#if defined(ECL_THREADS) && !defined(_MSC_VER) && !defined(__MINGW32__) +#if defined(ECL_THREADS) && !defined(ECL_MS_WINDOWS_HOST) if (sig == ecl_get_option(ECL_OPT_THREAD_INTERRUPT_SIGNAL)) { return pop_signal(the_env); } @@ -669,7 +669,7 @@ si_catch_signal(cl_object code, cl_object boolean) 0); # endif #endif -#if defined(ECL_THREADS) && !defined(_MSC_VER) && !defined(__MINGW32__) +#if defined(ECL_THREADS) && !defined(ECL_MS_WINDOWS_HOST) if (code_int == ecl_get_option(ECL_OPT_THREAD_INTERRUPT_SIGNAL)) { FEerror("It is not allowed to change the behavior of ~D", 1, MAKE_FIXNUM(code_int)); @@ -958,7 +958,7 @@ si_trap_fpe(cl_object condition, cl_object flag) # ifdef HAVE_FENV_H feclearexcept(all); # endif -# if defined(_MSC_VER) || defined(__MINGW32__) +# if defined(ECL_MS_WINDOWS_HOST) _fpreset(); # endif # ifdef HAVE_FEENABLEEXCEPT @@ -1066,7 +1066,7 @@ install_process_interrupt_handler() #else # define DEFAULT_THREAD_INTERRUPT_SIGNAL SIGUSR1 #endif -#if defined(ECL_THREADS) && !defined(_MSC_VER) && !defined(__MINGW32__) +#if defined(ECL_THREADS) && !defined(ECL_MS_WINDOWS_HOST) if (ecl_get_option(ECL_OPT_TRAP_INTERRUPT_SIGNAL)) { int signal = ecl_get_option(ECL_OPT_THREAD_INTERRUPT_SIGNAL); if (signal == 0) { diff --git a/src/c/unixsys.d b/src/c/unixsys.d index 35d218c0f..92322d9e3 100755 --- a/src/c/unixsys.d +++ b/src/c/unixsys.d @@ -21,7 +21,7 @@ #include #include #include -#if defined(__MINGW32__) || defined (_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) #include #endif #ifdef HAVE_UNISTD_H @@ -57,7 +57,7 @@ si_getpid(void) cl_object si_getuid(void) { -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) @(return MAKE_FIXNUM(0)); #else @(return ecl_make_integer(getuid())); @@ -69,7 +69,7 @@ si_make_pipe() { cl_object output; int fds[2], ret; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) ret = _pipe(fds, 4096, _O_BINARY); #else ret = pipe(fds); @@ -141,7 +141,7 @@ make_external_process(cl_object pid, cl_object input, cl_object output) return cl_funcall(4, @'ext::make-external-process', pid, input, output); } -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) cl_object si_close_windows_handle(cl_object h) { @@ -185,7 +185,7 @@ make_windows_handle(HANDLE h) 4, code); } else { cl_object exit_status = Cnil; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) HANDLE *hProcess = ecl_foreign_data_pointer_safe(process_or_pid); DWORD exitcode; int ok; @@ -243,7 +243,7 @@ make_windows_handle(HANDLE h) @ command = si_copy_to_simple_base_string(command); argv = cl_mapcar(2, @'si::copy-to-simple-base-string', argv); -#if defined(__MINGW32__) || defined (_MSC_VER) +#if defined(ECL_MS_WINDOWS_HOST) { BOOL ok; STARTUPINFO st_info; diff --git a/src/h/config.h.in b/src/h/config.h.in index 8261663d5..2f5a7df25 100644 --- a/src/h/config.h.in +++ b/src/h/config.h.in @@ -13,6 +13,10 @@ See file '../Copyright' for full details. */ +#if defined(_MSC_VER) || defined(__MINGW32__) || __WIN32__ || __WING64__ +#define ECL_MS_WINDOWS_HOST +#endif + /* * If ECL_API has been predefined, that means we are building the core * library and, under windows, we must tell the compiler to export @@ -21,7 +25,7 @@ * uses ECL and, under windows, we must tell the compiler that certain * will be imported from a DLL. */ -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(cygwin) +#if defined(ECL_MS_WINDOWS_HOST) || defined(cygwin) # define ECL_DLLEXPORT __declspec(dllexport) # ifdef ECL_API # undef \ @@ -59,7 +63,7 @@ /* Userland threads? */ #undef ECL_THREADS #ifdef ECL_THREADS -# if defined(_MSC_VER) || defined(__MINGW32__) +# if defined(ECL_MS_WINDOWS_HOST) # define ECL_WINDOWS_THREADS # endif /* # udef ECL_SEMAPHORES */ @@ -80,7 +84,7 @@ # include "@ECL_BOEHM_GC_HEADER@" /* GC >= 7.2 defines these macros to intercept thread functions, but * in doing so it breaks mingw. */ -# if defined(__MINGW32__) && defined(_beginthreadex) +# if defined(ECL_MS_WINDOWS_HOST) && defined(_beginthreadex) # undef _beginthread # undef _endthread # undef _beginthreadex @@ -90,7 +94,7 @@ /* Network streams */ #undef TCP -#if defined(TCP) && (defined(_MSC_VER) || defined(__MINGW32__)) +#if defined(TCP) && defined(ECL_MS_WINDOWS_HOST) # define ECL_WSOCK #endif @@ -120,7 +124,7 @@ /* Use mprotect for fast interrupt dispatch */ #undef ECL_USE_MPROTECT -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) # define ECL_USE_GUARD_PAGE #endif @@ -455,7 +459,7 @@ typedef unsigned @CL_FIXNUM_TYPE@ cl_hashkey; # define FILE_CNT(fp) ((fp)->_cnt) #endif -#if defined(cygwin) || defined(__MINGW32__) || defined(_MSC_VER) +#if defined(cygwin) || defined(ECL_MS_WINDOWS_HOST) # define IS_DIR_SEPARATOR(x) ((x=='/')||(x=='\\')) # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ';' diff --git a/src/h/ecl.h b/src/h/ecl.h index 227b36b05..8ef745819 100644 --- a/src/h/ecl.h +++ b/src/h/ecl.h @@ -51,7 +51,7 @@ #endif #endif -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1 /* Do not include winsock.h */ # include @@ -70,7 +70,7 @@ # else # error "The Windows ports cannot be built without threads." # endif /* ECL_THREADS */ -#endif /* _MSC_VER || __MINGW32__ */ +#endif /* ECL_MS_WINDOWS_HOST */ #ifdef ECL_SSE2 #include diff --git a/src/h/external.h b/src/h/external.h index 8f55326bc..7834499db 100755 --- a/src/h/external.h +++ b/src/h/external.h @@ -577,7 +577,7 @@ extern ECL_API void FEinvalid_function_name(cl_object obj) ecl_attr_noreturn; extern ECL_API cl_object CEerror(cl_object c, const char *err_str, int narg, ...); extern ECL_API void FEillegal_index(cl_object x, cl_object i) ecl_attr_noreturn; extern ECL_API void FElibc_error(const char *msg, int narg, ...) ecl_attr_noreturn; -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(cygwin) +#if defined(ECL_MS_WINDOWS_HOST) || defined(cygwin) extern ECL_API void FEwin32_error(const char *msg, int narg, ...) ecl_attr_noreturn; #endif extern ECL_API cl_object si_signal_type_error(cl_object value, cl_object type) ecl_attr_noreturn; @@ -971,7 +971,7 @@ extern ECL_API void ecl_set_option(int option, cl_fixnum value); extern ECL_API cl_fixnum ecl_get_option(int option); extern ECL_API int cl_boot(int argc, char **argv); extern ECL_API void cl_shutdown(void); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) extern ECL_API void ecl_get_commandline_args(int* argc, char*** argv); #endif @@ -1802,7 +1802,7 @@ extern ECL_API cl_object si_check_pending_interrupts(void); extern ECL_API cl_object si_disable_interrupts(void); extern ECL_API cl_object si_enable_interrupts(void); extern ECL_API cl_object si_trap_fpe(cl_object condition, cl_object flag); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(ECL_MS_WINDOWS_HOST) extern ECL_API LONG WINAPI _ecl_w32_exception_filter(struct _EXCEPTION_POINTERS*); #endif extern ECL_API void ecl_check_pending_interrupts(void); diff --git a/src/h/internal.h b/src/h/internal.h index 5ec21b1be..d702d5cf8 100644 --- a/src/h/internal.h +++ b/src/h/internal.h @@ -359,7 +359,7 @@ extern cl_fixnum ecl_runtime(void); /* unixint.d */ #ifdef ECL_DEFINE_FENV_CONSTANTS -# if defined(_MSC_VER) || defined(__MINGW32__) +# if defined(ECL_MS_WINDOWS_HOST) # define HAVE_FEENABLEEXCEPT # include # if defined(_MSC_VER)