When compiling for the Windows API, define ECL_MS_WINDOWS_HOST instead of checking for mingw or _MSC_VER separately (Gabriel Dos Reis)

This commit is contained in:
Juan Jose Garcia Ripoll 2010-08-22 22:29:21 +02:00
parent fb2c950202
commit 5c63cd8345
23 changed files with 127 additions and 100 deletions

View file

@ -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);

View file

@ -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

View file

@ -21,7 +21,7 @@
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(cygwin)
#if defined(ECL_MS_WINDOWS_HOST) || defined(cygwin)
#include <windows.h>
#endif
#include <ecl/internal.h>
@ -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, ...)
{

View file

@ -29,7 +29,7 @@
# include <unistd.h>
#endif
#include <fcntl.h>
#if !defined(__MINGW32__) && !defined(_MSC_VER)
#if !defined(ECL_MS_WINDOWS_HOST)
#include <sys/stat.h>
/* it isn't pulled in by fcntl.h */
#endif
@ -45,7 +45,7 @@
# include <sys/time.h>
# include <sys/types.h>
# include <unistd.h>
#elif defined(__MINGW32__) || defined(_MSC_VER)
#elif defined(ECL_MS_WINDOWS_HOST)
# include <winsock.h>
# include <sys/stat.h>
# 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;

View file

@ -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);

View file

@ -14,9 +14,33 @@
See file '../Copyright' for full details.
*/
#include <ecl/ecl.h>
#include <string.h>
#include <stdio.h>
#include <ecl/ecl.h>
/*
* 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 <w32api/windows.h>
@ -24,22 +48,18 @@
# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
# define INIT_PREFIX "init_fas_"
# endif
# ifdef HAVE_MACH_O_DYLD_H
# ifndef HAVE_DLFCN_H
# include <mach-o/dyld.h>
# 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 <mach-o/dyld.h>
# define INIT_PREFIX "_init_fas_"
# endif
# ifdef HAVE_LINK_H
# include <link.h>
# endif
# if defined(__MINGW32__) || defined(_MSC_VER)
# if defined(ECL_MS_WINDOWS_HOST)
# include <windows.h>
# include <windef.h>
# include <winbase.h>
@ -48,7 +68,7 @@
# else
# include <unistd.h>
# endif
#endif
#endif /* ENABLE_DLOPEN */
#include <ecl/ecl-inl.h>
#include <ecl/internal.h>
#include <sys/stat.h>
@ -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

View file

@ -19,7 +19,7 @@
#include <ecl/ecl.h>
#include <limits.h>
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(ECL_MS_WINDOWS_HOST)
# include <windows.h>
# include <shellapi.h>
# 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;

View file

@ -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);

View file

@ -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);
}

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -18,7 +18,7 @@
#include <sys/types.h>
#include <errno.h>
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(ECL_MS_WINDOWS_HOST)
#include <winsock.h>
#else
extern int errno;
@ -32,7 +32,7 @@ extern int errno;
#endif
#include <string.h>
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(ECL_MS_WINDOWS_HOST)
#include <io.h>
#else
#include <sys/ioctl.h>
@ -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 */

View file

@ -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 <windows.h>
#else
# include <pthread.h>

View file

@ -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 <windows.h>
#else
# include <pthread.h>

View file

@ -32,12 +32,12 @@
# include <unistd.h>
#endif
#include <ecl/internal.h>
#if defined(__MINGW32__) || defined(_MSC_VER)
#if defined(ECL_MS_WINDOWS_HOST)
#include <windows.h>
#include <WinSock.h>
#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);

View file

@ -41,7 +41,7 @@
# include <sys/dir.h>
# endif
#endif
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(ECL_MS_WINDOWS_HOST)
# include <windows.h>
# 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];

View file

@ -88,7 +88,7 @@
# endif
# include <sys/mman.h>
#endif
#if defined(__MINGW32__) || defined(_MSC_VER)
#if defined(ECL_MS_WINDOWS_HOST)
# include <windows.h>
#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) {

View file

@ -21,7 +21,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <ecl/internal.h>
#if defined(__MINGW32__) || defined (_MSC_VER)
#if defined(ECL_MS_WINDOWS_HOST)
#include <windows.h>
#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;

View file

@ -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 ';'

View file

@ -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 <windows.h>
@ -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 <xmmintrin.h>

View file

@ -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);

View file

@ -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 <float.h>
# if defined(_MSC_VER)