diff --git a/ANON-CVS b/ANON-CVS index d782a03b9..baf07412a 100644 --- a/ANON-CVS +++ b/ANON-CVS @@ -46,7 +46,6 @@ To check out a CVS working directory: The modules available for checkout are: guile-core --- The scheme interpreter itself. - guile-doc --- Guile documentation-in-progress. guile-tcltk --- An interface between Guile and Tcl/Tk. guile-scsh --- An incomplete port of SCSH 0.4.4 to Guile. guile-rgx-ctax --- This has been discontinued; use Andrew Archibald's diff --git a/ChangeLog b/ChangeLog index 2a3747154..a3dfa2056 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-06-26 Martin Grabmueller + + * HACKING, ANON-CVS: Removed mentioning of guile-doc CVS module. + + * configure.in: Added some header and function checks. + 2001-06-25 Neil Jerram * autogen.sh: Quoting fix for `--enable-maintainer-mode'. diff --git a/HACKING b/HACKING index f3d60a899..ffbfa6dfe 100644 --- a/HACKING +++ b/HACKING @@ -103,8 +103,6 @@ For more information on SSH, see http://www.cs.hut.fi/ssh. The Guile sources live in several modules: - guile-core --- the interpreter, QuickThreads, and ice-9 - - guile-doc --- documentation in progress. When complete, this will - be incorporated into guile-core. - guile-tcltk --- the Guile/Tk interface - guile-tk --- the new Guile/Tk interface, based on STk's modified Tk - guile-rgx-ctax --- the Guile/Rx interface, and the ctax implementation diff --git a/THANKS b/THANKS index f4eccdddb..6941df180 100644 --- a/THANKS +++ b/THANKS @@ -33,6 +33,7 @@ For fixes or providing information which led to a fix: Utz-Uwe Haus Karl M. Hegbloom Anders Holst + Stefan Jahn Steven G. Johnson Richard Kim Alexander Klimov diff --git a/configure.in b/configure.in index 32c5481e0..f51e4c4ce 100644 --- a/configure.in +++ b/configure.in @@ -192,7 +192,7 @@ AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_TIME AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(io.h libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h sys/utime.h time.h unistd.h utime.h) +AC_CHECK_HEADERS(io.h libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h sys/utime.h time.h unistd.h utime.h pwd.h winsock2.h grp.h sys/utsname.h) GUILE_HEADER_LIBC_WITH_UNISTD AC_TYPE_GETGROUPS @@ -232,7 +232,7 @@ AC_SUBST(INCLTDL) AC_SUBST(LIBLTDL) AC_SUBST(DLPREOPEN) -AC_CHECK_FUNCS(ctermid ftime fchown getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit) +AC_CHECK_FUNCS(ctermid ftime fchown getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork) AC_CHECK_HEADERS(crypt.h sys/resource.h sys/file.h) AC_CHECK_FUNCS(chroot flock getlogin cuserid getpriority setpriority getpass sethostname gethostname) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index cdf0344f2..6ab44667e 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,59 @@ +2001-06-26 Martin Grabmueller + + * ports.c (scm_output_port_p): Use result of SCM_COERCE_OUTPORT. + + The following set of changes makes compiling Guile under various + Windows compilers easier. Compilation under GNU systems should + not be affected at all. + + Thanks to Stefan Jahn for all necessary information, patches and + testing. + + * posix.c: Conditialize getpwent, getgrent, kill, getppid, getuid, + getpgrp, ttyname, primitive-fork and some header inclusion for + Windows. + + * random.c: Define M_PI, if not predefined and use __int64 for + LONG64 under Windows. + + * scmsigs.c: Emulate some functions (alarm, sleep, kill) under + Windows and conditionalize some signal names. + + * socket.c (scm_getsockopt): Added missing comma. + Include socket library header under Windows. + + * stime.c (CLKTCK): Add cast to int, to make it compile under + Windows. + + * ports.c (truncate): New function, compiled only under Windows. + + * net_db.c: Do not declare errno under Windows. + + * iselect.h, inet_aton.c: Include socket library headers under + Windows. + + * guile.c (inner_main): Under Windows, initialize socket library + and initialize gdb_interface data structures. + + * gdb_interface.h: Under Windows, gdb_interface cannot be + initialized statically. Initialize at runtime instead. + + * fports.c (write_all): ssize_t -> size_t. + (fport_print): Conditionalize call to ttyname(). + (getflags): New function, compiled only under Windows. + + * filesys.c: Conditionalize inclusion of . Conditionalize + primitives chown, link, fcntl. + (scm_basename, scm_dirname): Under Windows, handle \ as well as / + as path seperator. + + * backtrace.c: Include under Windows. + + * async.h (ASYNCH, SCM_ASYNC_H): Rename H to SCM__H. + + * _scm.h: Added preprocessor conditional for __MINGW32__ for errno + declaration. + 2001-06-27 Keisuke Nishida * eval.c (scm_call_0, scm_call_1, scm_call_2, scm_call_3, diff --git a/libguile/_scm.h b/libguile/_scm.h index ec9839d80..d155f9441 100644 --- a/libguile/_scm.h +++ b/libguile/_scm.h @@ -111,13 +111,13 @@ # define SCM_SYSCALL(line) line; #endif /* ndef SCM_SYSCALL */ -#ifndef MSDOS +#if !defined (MSDOS) && !defined (__MINGW32__) # ifdef ARM_ULIB extern volatile int errno; # else extern int errno; # endif /* def ARM_ULIB */ -#endif /* ndef MSDOS */ +#endif /* ndef MSDOS && ndef __MINGW32__*/ diff --git a/libguile/async.h b/libguile/async.h index b4fa403cb..ca5b7efce 100644 --- a/libguile/async.h +++ b/libguile/async.h @@ -1,7 +1,7 @@ /* classes: h_files */ -#ifndef ASYNCH -#define ASYNCH +#ifndef SCM_ASYNC_H +#define SCM_ASYNC_H /* Copyright (C) 1995, 96, 97, 98, 2000 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify @@ -70,7 +70,7 @@ extern SCM scm_unmask_signals (void); extern SCM scm_mask_signals (void); extern void scm_init_async (void); -#endif /* ASYNCH */ +#endif /* SCM_ASYNC_H */ /* Local Variables: diff --git a/libguile/backtrace.c b/libguile/backtrace.c index 3ab3a29f4..1687ab88e 100644 --- a/libguile/backtrace.c +++ b/libguile/backtrace.c @@ -54,6 +54,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_IO_H +#include +#endif #include "libguile/stacks.h" #include "libguile/srcprop.h" diff --git a/libguile/filesys.c b/libguile/filesys.c index 1d4afd341..0593414c3 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -93,7 +93,9 @@ #include #include +#ifdef HAVE_PWD_H #include +#endif #if HAVE_DIRENT_H @@ -117,6 +119,26 @@ #if defined (S_IFSOCK) && ! defined (S_ISSOCK) #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) #endif + +/* The MinGW gcc does not define the S_ISSOCK macro. Any other native Windows + compiler like BorlandC or MSVC has none of these macros defined. */ +#ifdef __MINGW32__ +# define S_ISSOCK(mode) (0) +#endif +#if defined (__BORLANDC__) || defined (_MSC_VER) +# define S_ISBLK(mode) (0) +# define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO) +# define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR) +# define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR) +# define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG) +#endif + +/* Some more definitions for the native Windows port. */ +#ifdef __MINGW32__ +# define mkdir(path, mode) mkdir (path) +# define fsync(fd) _commit (fd) +# define fchmod(fd, mode) (-1) +#endif /* __MINGW32__ */ @@ -125,6 +147,7 @@ /* {Permissions} */ +#ifdef HAVE_CHOWN SCM_DEFINE (scm_chown, "chown", 3, 0, 0, (SCM object, SCM owner, SCM group), "Change the ownership and group of the file referred to by @var{object} to\n" @@ -167,6 +190,7 @@ SCM_DEFINE (scm_chown, "chown", 3, 0, 0, return SCM_UNSPECIFIED; } #undef FUNC_NAME +#endif /* HAVE_CHOWN */ SCM_DEFINE (scm_chmod, "chmod", 2, 0, 0, @@ -561,6 +585,7 @@ SCM_DEFINE (scm_stat, "stat", 1, 0, 0, /* {Modifying Directories} */ +#ifdef HAVE_LINK SCM_DEFINE (scm_link, "link", 2, 0, 0, (SCM oldpath, SCM newpath), "Creates a new name @var{newpath} in the file system for the\n" @@ -582,6 +607,7 @@ SCM_DEFINE (scm_link, "link", 2, 0, 0, return SCM_UNSPECIFIED; } #undef FUNC_NAME +#endif /* HAVE_LINK */ @@ -1145,6 +1171,7 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0, +#ifdef HAVE_FCNTL SCM_DEFINE (scm_fcntl, "fcntl", 2, 1, 0, (SCM object, SCM cmd, SCM value), "Apply @var{command} to the specified file descriptor or the underlying\n" @@ -1199,6 +1226,7 @@ SCM_DEFINE (scm_fcntl, "fcntl", 2, 1, 0, return SCM_MAKINUM (rv); } #undef FUNC_NAME +#endif /* HAVE_FCNTL */ SCM_DEFINE (scm_fsync, "fsync", 1, 0, 0, (SCM object), @@ -1368,12 +1396,22 @@ SCM_DEFINE (scm_dirname, "dirname", 1, 0, 0, len = SCM_STRING_LENGTH (filename); i = len - 1; +#ifdef __MINGW32__ + while (i >= 0 && (s[i] == '/' || s[i] == '\\')) --i; + while (i >= 0 && (s[i] != '/' || s[i] != '\\')) --i; + while (i >= 0 && (s[i] == '/' || s[i] == '\\')) --i; +#else while (i >= 0 && s[i] == '/') --i; while (i >= 0 && s[i] != '/') --i; while (i >= 0 && s[i] == '/') --i; +#endif /* ndef __MINGW32__ */ if (i < 0) { +#ifdef __MINGW32__ + if (len > 0 && (s[0] == '/' || s[0] == '\\')) +#else if (len > 0 && s[0] == '/') +#endif /* ndef __MINGW32__ */ return scm_substring (filename, SCM_INUM0, SCM_MAKINUM (1)); else return scm_dot_string; @@ -1407,15 +1445,27 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0, j = SCM_STRING_LENGTH (suffix) - 1; } i = len - 1; +#ifdef __MINGW32__ + while (i >= 0 && (f[i] == '/' || f[i] == '\\')) --i; +#else while (i >= 0 && f[i] == '/') --i; +#endif /* ndef __MINGW32__ */ end = i; while (i >= 0 && j >= 0 && f[i] == s[j]) --i, --j; if (j == -1) end = i; +#ifdef __MINGW32__ + while (i >= 0 && (f[i] != '/' || f[i] != '\\')) --i; +#else while (i >= 0 && f[i] != '/') --i; +#endif /* ndef __MINGW32__ */ if (i == end) { +#ifdef __MINGW32__ + if (len > 0 && (f[0] == '/' || f[i] == '\\')) +#else if (len > 0 && f[0] == '/') +#endif /* ndef __MINGW32__ */ return scm_substring (filename, SCM_INUM0, SCM_MAKINUM (1)); else return scm_dot_string; diff --git a/libguile/fports.c b/libguile/fports.c index 42d8bd843..bc90db6bf 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -68,6 +68,12 @@ size_t fwrite (); #include #include "libguile/iselect.h" +/* Some defines for Windows. */ +#ifdef __MINGW32__ +# include +# include +# define ftruncate(fd, size) chsize (fd, size) +#endif /* __MINGW32__ */ scm_t_bits scm_tc16_fport; @@ -349,6 +355,46 @@ SCM_DEFINE (scm_open_file, "open-file", 2, 0, 0, #undef FUNC_NAME +#ifdef __MINGW32__ +/* + * Try getting the appropiate file flags for a given file descriptor + * under Windows. This incorporates some fancy operations because Windows + * differentiates between file, pipe and socket descriptors. + */ +#ifndef O_ACCMODE +# define O_ACCMODE 0x0003 +#endif + +static int getflags (int fdes) +{ + int flags = 0; + struct stat buf; + int error, optlen = sizeof (int); + + /* Is this a socket ? */ + if (getsockopt (fdes, SOL_SOCKET, SO_ERROR, (void *) &error, &optlen) >= 0) + flags = O_RDWR; + /* Maybe a regular file ? */ + else if (fstat (fdes, &buf) < 0) + flags = -1; + else + { + /* Or an anonymous pipe handle ? */ + if (buf.st_mode & 0x1000 /* _O_SHORT_LIVED */) + flags = O_RDWR; + /* stdin ? */ + else if (fdes == 0 && isatty (fdes)) + flags = O_RDONLY; + /* stdout / stderr ? */ + else if ((fdes == 1 || fdes == 2) && isatty (fdes)) + flags = O_WRONLY; + else + flags = buf.st_mode; + } + return flags; +} +#endif /* __MINGW32__ */ + /* Building Guile ports from a file descriptor. */ /* Build a Scheme port from an open file descriptor `fdes'. @@ -366,7 +412,11 @@ scm_fdes_to_port (int fdes, char *mode, SCM name) int flags; /* test that fdes is valid. */ +#ifdef __MINGW32__ + flags = getflags (fdes); +#else flags = fcntl (fdes, F_GETFL, 0); +#endif if (flags == -1) SCM_SYSERROR; flags &= O_ACCMODE; @@ -456,9 +506,11 @@ fport_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED) scm_putc (' ', port); fdes = (SCM_FSTREAM (exp))->fdes; +#ifdef HAVE_TTYNAME if (isatty (fdes)) scm_puts (ttyname (fdes), port); else +#endif /* HAVE_TTYNAME */ scm_intprint (fdes, 10, port); } else @@ -595,7 +647,7 @@ static void write_all (SCM port, const void *data, size_t remaining) while (remaining > 0) { - ssize_t done; + size_t done; SCM_SYSCALL (done = write (fdes, data, remaining)); diff --git a/libguile/gdb_interface.h b/libguile/gdb_interface.h index ec1bbe43d..fc44bc815 100644 --- a/libguile/gdb_interface.h +++ b/libguile/gdb_interface.h @@ -58,6 +58,7 @@ Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */ interface in your main program. This is necessary if the interface is defined in a library, such as Guile. */ +#ifndef __MINGW32__ #define GDB_INTERFACE \ void *gdb_interface[] = { \ &gdb_options, \ @@ -71,6 +72,27 @@ void *gdb_interface[] = { \ (void *) gdb_print, \ (void *) gdb_binding \ } +#else /* __MINGW32__ */ +/* Because the following functions are imported from a DLL (some kind of + shared library) these are NO static initializers. That is why you need to + define them and assign the functions and data items at run time. */ +#define GDB_INTERFACE \ +void *gdb_interface[] = \ + { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +#define GDB_INTERFACE_INIT \ + do { \ + gdb_interface[0] = &gdb_options; \ + gdb_interface[1] = &gdb_language; \ + gdb_interface[2] = &gdb_result; \ + gdb_interface[3] = &gdb_output; \ + gdb_interface[4] = &gdb_output_length; \ + gdb_interface[5] = (void *) gdb_maybe_valid_type_p; \ + gdb_interface[6] = (void *) gdb_read; \ + gdb_interface[7] = (void *) gdb_eval; \ + gdb_interface[8] = (void *) gdb_print; \ + gdb_interface[9] = (void *) gdb_binding; \ + } while (0); +#endif /* __MINGW32__ */ /* GDB_OPTIONS is a set of flags informing gdb what features are present in the interface. Currently only one option is supported: */ diff --git a/libguile/guile.c b/libguile/guile.c index 21be17871..d25a70d07 100644 --- a/libguile/guile.c +++ b/libguile/guile.c @@ -55,6 +55,10 @@ #include #endif +#ifdef HAVE_WINSOCK2_H +#include +#endif + /* Debugger interface (don't change the order of the following lines) */ #define GDB_TYPE SCM #include @@ -63,8 +67,19 @@ GDB_INTERFACE; static void inner_main (void *closure SCM_UNUSED, int argc, char **argv) { +#ifdef __MINGW32__ + /* This is necessary to startup the Winsock API under Win32. */ + WSADATA WSAData; + WSAStartup (0x0202, &WSAData); + GDB_INTERFACE_INIT; +#endif /* __MINGW32__ */ + /* module initializations would go here */ scm_shell (argc, argv); + +#ifdef __MINGW32__ + WSACleanup (); +#endif /* __MINGW32__ */ } int diff --git a/libguile/inet_aton.c b/libguile/inet_aton.c index 54c76507b..ec00b5a0d 100644 --- a/libguile/inet_aton.c +++ b/libguile/inet_aton.c @@ -40,9 +40,13 @@ static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; #include +#ifdef __MINGW32__ +#include +#else #include #include #include +#endif #if 0 diff --git a/libguile/iselect.h b/libguile/iselect.h index eb87927c0..fdaedcc61 100644 --- a/libguile/iselect.h +++ b/libguile/iselect.h @@ -67,6 +67,10 @@ #include #endif +#ifdef HAVE_WINSOCK2_H +#include +#endif + #ifdef FD_SET #define SELECT_TYPE fd_set diff --git a/libguile/net_db.c b/libguile/net_db.c index 66e327a85..974ba888c 100644 --- a/libguile/net_db.c +++ b/libguile/net_db.c @@ -66,12 +66,17 @@ #endif #include + +#ifdef HAVE_WINSOCK2_H +#include +#else #include #include #include #include +#endif -#ifndef HAVE_H_ERRNO +#if !defined (HAVE_H_ERRNO) && !defined (__MINGW32__) /* h_errno not found in netdb.h, maybe this will help. */ extern int h_errno; #endif diff --git a/libguile/ports.c b/libguile/ports.c index 0dddda802..68951a416 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -77,6 +77,11 @@ #include #endif +#ifdef __MINGW32__ +#include +#define ftruncate(fd, size) chsize (fd, size) +#endif + /* The port kind table --- a dynamically resized array of port types. */ @@ -802,7 +807,7 @@ SCM_DEFINE (scm_output_port_p, "output-port?", 1, 0, 0, "@code{port?}.") #define FUNC_NAME s_scm_output_port_p { - SCM_COERCE_OUTPORT (x); + x = SCM_COERCE_OUTPORT (x); return SCM_BOOL (SCM_OUTPUT_PORT_P (x)); } #undef FUNC_NAME @@ -1325,6 +1330,20 @@ SCM_DEFINE (scm_seek, "seek", 3, 0, 0, } #undef FUNC_NAME +#ifdef __MINGW32__ +/* Define this function since it is not supported under Windows. */ +static int truncate (char *file, int length) +{ + int ret = -1, fdes; + if ((fdes = open (file, O_BINARY | O_WRONLY)) != -1) + { + ret = chsize (fdes, length); + close (fdes); + } + return ret; +} +#endif /* __MINGW32__ */ + SCM_DEFINE (scm_truncate_file, "truncate-file", 1, 1, 0, (SCM object, SCM length), "Truncates the object referred to by @var{object} to at most\n" diff --git a/libguile/posix.c b/libguile/posix.c index 83e8bac10..7379c3780 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -91,7 +91,20 @@ extern char *ttyname(); #include #include +#ifdef HAVE_PWD_H #include +#endif +#ifdef HAVE_IO_H +#include +#endif +#ifdef HAVE_WINSOCK2_H +#include +#endif + +#ifdef __MINGW32__ +/* Some defines for Windows here. */ +# define pipe(fd) _pipe (fd, 256, O_BINARY) +#endif /* __MINGW32__ */ #if HAVE_SYS_WAIT_H # include @@ -107,8 +120,12 @@ extern char *ttyname(); extern char ** environ; +#ifdef HAVE_GRP_H #include +#endif +#ifdef HAVE_SYS_UTSNAME_H #include +#endif #if HAVE_DIRENT_H # include @@ -247,7 +264,7 @@ SCM_DEFINE (scm_getgroups, "getgroups", 0, 0, 0, #undef FUNC_NAME #endif - +#ifdef HAVE_GETPWENT SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, 0, (SCM user), "Look up an entry in the user database. @var{obj} can be an integer,\n" @@ -298,6 +315,7 @@ SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, 0, return result; } #undef FUNC_NAME +#endif /* HAVE_GETPWENT */ #ifdef HAVE_SETPWENT @@ -318,7 +336,7 @@ SCM_DEFINE (scm_setpwent, "setpw", 0, 1, 0, #endif - +#ifdef HAVE_GETGRENT /* Combines getgrgid and getgrnam. */ SCM_DEFINE (scm_getgrgid, "getgr", 0, 1, 0, (SCM name), @@ -375,7 +393,7 @@ SCM_DEFINE (scm_setgrent, "setgr", 0, 1, 0, return SCM_UNSPECIFIED; } #undef FUNC_NAME - +#endif /* HAVE_GETGRENT */ SCM_DEFINE (scm_kill, "kill", 2, 0, 0, @@ -407,8 +425,13 @@ SCM_DEFINE (scm_kill, "kill", 2, 0, 0, SCM_VALIDATE_INUM (1,pid); SCM_VALIDATE_INUM (2,sig); /* Signal values are interned in scm_init_posix(). */ +#ifdef HAVE_KILL if (kill ((int) SCM_INUM (pid), (int) SCM_INUM (sig)) != 0) - SCM_SYSERROR; +#else + if ((int) SCM_INUM (pid) == getpid ()) + if (raise ((int) SCM_INUM (sig)) != 0) +#endif + SCM_SYSERROR; return SCM_UNSPECIFIED; } #undef FUNC_NAME @@ -472,6 +495,7 @@ SCM_DEFINE (scm_waitpid, "waitpid", 1, 1, 0, #undef FUNC_NAME #endif /* HAVE_WAITPID */ +#ifndef __MINGW32__ SCM_DEFINE (scm_status_exit_val, "status:exit-val", 1, 0, 0, (SCM status), "Return the exit status value, as would be set if a process\n" @@ -528,7 +552,9 @@ SCM_DEFINE (scm_status_stop_sig, "status:stop-sig", 1, 0, 0, return SCM_BOOL_F; } #undef FUNC_NAME +#endif /* __MINGW32__ */ +#ifdef HAVE_GETPPID SCM_DEFINE (scm_getppid, "getppid", 0, 0, 0, (), "Return an integer representing the process ID of the parent\n" @@ -538,9 +564,10 @@ SCM_DEFINE (scm_getppid, "getppid", 0, 0, 0, return SCM_MAKINUM (0L + getppid ()); } #undef FUNC_NAME +#endif /* HAVE_GETPPID */ - +#ifndef __MINGW32__ SCM_DEFINE (scm_getuid, "getuid", 0, 0, 0, (), "Return an integer representing the current real user ID.") @@ -549,6 +576,7 @@ SCM_DEFINE (scm_getuid, "getuid", 0, 0, 0, return SCM_MAKINUM (0L + getuid ()); } #undef FUNC_NAME +#endif /* __MINGW32__ */ @@ -580,7 +608,6 @@ SCM_DEFINE (scm_geteuid, "geteuid", 0, 0, 0, #undef FUNC_NAME - SCM_DEFINE (scm_getegid, "getegid", 0, 0, 0, (), "Return an integer representing the current effective group ID.\n" @@ -675,6 +702,8 @@ SCM_DEFINE (scm_setegid, "setegid", 1, 0, 0, #undef FUNC_NAME #endif + +#ifdef HAVE_GETPGRP SCM_DEFINE (scm_getpgrp, "getpgrp", 0, 0, 0, (), "Return an integer representing the current process group ID.\n" @@ -686,6 +715,8 @@ SCM_DEFINE (scm_getpgrp, "getpgrp", 0, 0, 0, return SCM_MAKINUM (fn (0)); } #undef FUNC_NAME +#endif /* HAVE_GETPGRP */ + #ifdef HAVE_SETPGID SCM_DEFINE (scm_setpgid, "setpgid", 2, 0, 0, @@ -724,6 +755,7 @@ SCM_DEFINE (scm_setsid, "setsid", 0, 0, 0, #undef FUNC_NAME #endif /* HAVE_SETSID */ +#ifdef HAVE_TTYNAME SCM_DEFINE (scm_ttyname, "ttyname", 1, 0, 0, (SCM port), "Return a string with the name of the serial terminal device\n" @@ -745,6 +777,7 @@ SCM_DEFINE (scm_ttyname, "ttyname", 1, 0, 0, return (scm_makfrom0str (ans)); } #undef FUNC_NAME +#endif /* HAVE_TTYNAME */ #ifdef HAVE_CTERMID SCM_DEFINE (scm_ctermid, "ctermid", 0, 0, 0, @@ -947,6 +980,7 @@ SCM_DEFINE (scm_execle, "execle", 2, 0, 1, } #undef FUNC_NAME +#ifdef HAVE_FORK SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, (), "Creates a new \"child\" process by duplicating the current \"parent\" process.\n" @@ -963,6 +997,7 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0, return SCM_MAKINUM (0L+pid); } #undef FUNC_NAME +#endif /* HAVE_FORK */ #ifdef HAVE_UNAME SCM_DEFINE (scm_uname, "uname", 0, 0, 0, diff --git a/libguile/random.c b/libguile/random.c index a55d68c31..f367332e5 100644 --- a/libguile/random.c +++ b/libguile/random.c @@ -91,6 +91,10 @@ scm_t_rng scm_the_rng; #define A 2131995753UL +#ifndef M_PI +#define M_PI 3.14159265359 +#endif + #if SIZEOF_LONG > 4 #if SIZEOF_INT > 4 #define LONG32 unsigned short @@ -100,8 +104,12 @@ scm_t_rng scm_the_rng; #define LONG64 unsigned long #else #define LONG32 unsigned long +#ifdef __MINGW32__ +#define LONG64 unsigned __int64 +#else #define LONG64 unsigned long long #endif +#endif #if SIZEOF_LONG > 4 || defined (HAVE_LONG_LONGS) diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index bdbf525e7..ea75a7216 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -74,6 +74,14 @@ int usleep (); #endif +#ifdef __MINGW32__ +#include +#define alarm(sec) (0) +/* This weird comma expression is because Sleep is void under Windows. */ +#define sleep(sec) (Sleep ((sec) * 1000), 0) +#define kill(pid, sig) raise (sig) +#endif + /* SIGRETTYPE is the type that signal handlers return. See */ @@ -298,12 +306,16 @@ SCM_DEFINE (scm_sigaction, "sigaction", 1, 2, 0, case SIGFPE: case SIGILL: case SIGSEGV: +#ifdef SIGBUS case SIGBUS: +#endif case SIGABRT: #if defined(SIGIOT) && (SIGIOT != SIGABRT) case SIGIOT: #endif +#ifdef SIGTRAP case SIGTRAP: +#endif #ifdef SIGEMT case SIGEMT: #endif diff --git a/libguile/socket.c b/libguile/socket.c index 1eacf9fe8..82d03fbc4 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -63,6 +63,9 @@ #include #endif #include +#ifdef HAVE_WINSOCK2_H +#include +#else #include #ifdef HAVE_UNIX_DOMAIN_SOCKETS #include @@ -70,6 +73,7 @@ #include #include #include +#endif #if defined (HAVE_UNIX_DOMAIN_SOCKETS) && !defined (SUN_LEN) #define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ @@ -523,7 +527,7 @@ SCM_DEFINE (scm_getsockopt, "getsockopt", 3, 0, 0, return scm_cons (scm_long2num (ling->l_onoff), scm_long2num (ling->l_linger)); #else - return scm_cons (scm_long2num (*(int *) optval) + return scm_cons (scm_long2num (*(int *) optval), SCM_MAKINUM (0)); #endif } diff --git a/libguile/stime.c b/libguile/stime.c index 5db51a547..fae4beeb8 100644 --- a/libguile/stime.c +++ b/libguile/stime.c @@ -99,10 +99,10 @@ extern char *strptime (); /* This should be figured out by autoconf. */ #if ! defined(CLKTCK) && defined(CLK_TCK) -# define CLKTCK CLK_TCK +# define CLKTCK ((int) CLK_TCK) #endif #if ! defined(CLKTCK) && defined(CLOCKS_PER_SEC) -# define CLKTCK CLOCKS_PER_SEC +# define CLKTCK ((int) CLOCKS_PER_SEC) #endif #if ! defined(CLKTCK) # define CLKTCK 60