From 700df4394ec8739943966d8860913cc9363741cf Mon Sep 17 00:00:00 2001 From: hniksic Date: Thu, 25 Sep 2003 15:39:37 -0700 Subject: [PATCH] [svn] Fixes to support out of the box compilation on various Windows compilers. By Gisle Vanem. --- ChangeLog | 8 ++++++++ src/ChangeLog | 9 +++++++++ src/mswindows.c | 8 ++++++-- src/mswindows.h | 12 +++++++++++- windows/config.h.ms | 19 +++++++++++++++---- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6bcc6e6..9aa11327 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-09-26 Gisle Vanem + + * windows/config.h.ms: Don't declare alloca under compilers that + support it. + + * windows/config.h.ms: Define HAVE_SNPRINTF, HAVE_VSNPRINTF, and + HAVE_MEMMOVE. + 2003-09-25 Herold Heiko * windows/Makefile.src: Updated OBJ list. diff --git a/src/ChangeLog b/src/ChangeLog index 78c86a9b..ed573983 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2003-09-26 Gisle Vanem + + * mswindows.c (read_registry): Fix invocation of registry + functions. + + * mswindows.c (read_registry): Condition definitions of sleep and + usleep with not HAVE_SLEEP and HAVE_USLEEP respectively. Define + HAVE_SLEEP and HAVE_USLEEP under __DMC__. + 2003-09-24 Hrvoje Niksic * url.c (url_escape_1): Revert unintentional change to lowercase diff --git a/src/mswindows.c b/src/mswindows.c index 6cfc0555..0b5242f1 100644 --- a/src/mswindows.c +++ b/src/mswindows.c @@ -63,6 +63,7 @@ void log_request_redirect_output PARAMS ((const char *)); static int windows_nt_p; +#ifndef HAVE_SLEEP /* Emulation of Unix sleep. */ unsigned int @@ -70,7 +71,9 @@ sleep (unsigned seconds) { return SleepEx (1000 * seconds, TRUE) ? 0U : 1000 * seconds; } +#endif +#ifndef HAVE_USLEEP /* Emulation of Unix usleep(). This has a granularity of milliseconds, but that's ok because: @@ -87,6 +90,7 @@ usleep (unsigned long usec) SleepEx (usec / 1000, TRUE); return 0; } +#endif /* HAVE_USLEEP */ static char * read_registry (HKEY hkey, char *subkey, char *valuename, char *buf, int *len) @@ -94,9 +98,9 @@ read_registry (HKEY hkey, char *subkey, char *valuename, char *buf, int *len) HKEY result; DWORD size = *len; DWORD type = REG_SZ; - if (RegOpenKeyEx (hkey, subkey, NULL, KEY_READ, &result) != ERROR_SUCCESS) + if (RegOpenKeyEx (hkey, subkey, 0, KEY_READ, &result) != ERROR_SUCCESS) return NULL; - if (RegQueryValueEx (result, valuename, NULL, &type, buf, &size) != ERROR_SUCCESS) + if (RegQueryValueEx (result, valuename, NULL, &type, (LPBYTE)buf, &size) != ERROR_SUCCESS) buf = NULL; *len = size; RegCloseKey (result); diff --git a/src/mswindows.h b/src/mswindows.h index 72fe8e96..4f505d80 100644 --- a/src/mswindows.h +++ b/src/mswindows.h @@ -125,14 +125,24 @@ so, delete this exception statement from your version. */ #define ESTALE WSAESTALE #define EREMOTE WSAEREMOTE +#ifdef __DMC__ +# define HAVE_SLEEP 1 +# define HAVE_USLEEP 1 +#endif + /* Public functions. */ +#ifndef HAVE_SLEEP unsigned int sleep (unsigned); +#endif +#ifndef HAVE_USLEEP +int usleep (unsigned long); +#endif + void ws_startup (void); void ws_changetitle (char*, int); char *ws_mypath (void); void ws_help (const char *); void windows_main_junk (int *, char **, char **); -int usleep (unsigned long); #endif /* MSWINDOWS_H */ diff --git a/windows/config.h.ms b/windows/config.h.ms index 32e94dfe..8db2a46e 100644 --- a/windows/config.h.ms +++ b/windows/config.h.ms @@ -32,8 +32,10 @@ /* Define if you have the header file. */ #undef HAVE_ALLOCA_H +#if !defined(__GNUC__) && !defined(__DMC__) && !defined(__WATCOMC__) /* Microsoft and Watcom libraries have an alloca function. */ char *alloca (); +#endif /* Define to empty if the keyword does not work. */ /* #undef const */ @@ -97,10 +99,10 @@ char *alloca (); #define HAVE_STRERROR 1 /* Define if you have the snprintf function. */ -#undef HAVE_SNPRINTF +#define HAVE_SNPRINTF /* Define if you have the vsnprintf function. */ -#undef HAVE_VSNPRINTF +#define HAVE_VSNPRINTF /* Define if you have the strstr function. */ #define HAVE_STRSTR 1 @@ -133,8 +135,14 @@ char *alloca (); #define HAVE_STRING_H 1 /* Define if you have the header file. */ -/* #define HAVE_UNISTD_H 1 */ +#if !defined(_MSC_VER) #undef HAVE_UNISTD_H +#endif + +/* None except Digital Mars have usleep function */ +#if defined(__DMC__) +#define HAVE_USLEEP +#endif /* Define if you have the header file. */ #undef HAVE_UTIME_H @@ -149,7 +157,7 @@ char *alloca (); #undef HAVE_PWD_H /* Define if you have the header file. */ -#undef HAVE_SIGNAL_H +#define HAVE_SIGNAL_H /* Define to be the name of the operating system. */ #define OS_TYPE "Windows" @@ -178,5 +186,8 @@ char *alloca (); /* Define if you have the isatty function. */ #define HAVE_ISATTY 1 +/* Define if you have the memmove function */ +#define HAVE_MEMMOVE 1 + #endif /* CONFIG_H */ -- 2.39.2