From: Stefan Jahn Date: Sun, 4 Nov 2001 15:52:30 +0000 (+0000) Subject: 2001-11-04 Stefan Jahn X-Git-Url: http://git.hcoop.net/bpt/guile.git/commitdiff_plain/8f99e3f38b575f8001cdc92241959c30930c6828?hp=836b65573dc133159a9635b0387e679d7efc101e 2001-11-04 Stefan Jahn * NEWS: Corrected remarks about SCM_API. * configure.in: Defining USE_DLL_IMPORT definition to indicate usage of DLL import macros in `libguile/__scm.h'. (LIBOBJS): Removed `fileblocks.o' from the list of object files. Somehow Jim Blandy's patch from 1997 did not survive. 2001-11-04 Stefan Jahn * configure.in (EXTRA_DEFS): Follow-up patch. Using SCM_IMPORT instead of __SCM_IMPORT__. * readline.c (scm_readline_init_ports): Disable input/output stream redirection for Win32. The readline package for Win32 does not support this. The guile-readline library works fine for command line editing. * readline.h (SCM_RL_API): Renamed __FOO__ macros into FOO. 2001-11-04 Stefan Jahn * Makefile.am (libguile_la_LIBADD): Added $(THREAD_LIBS_LOCAL) here (was at guile_LDADD) which describes the dependency correctly and allows a clean build on Win32. * __scm.h (SCM_API): Follow-up patch. Renamed __FOO__ macros into FOO. * __scm.h: USE_DLL_IMPORT indicates the usage of the DLL import macros for external libraries (libcrypt, libqthreads, libreadline and libregex). * coop-defs.h: Include for `struct timeval'. * posix.c (flock): Added support for flock() in M$-Windows. * guile.c (SCM_IMPORT): Follow-up patch. Use SCM_IMPORT instead of __SCM_IMPORT__. * fports.c (getflags): Differentiate reading and writing pipes descriptors. * filesys.c (S_IS*): Redefine all of the S_IS*() macros for M$-Windows. * coop.c (coop_condition_variable_timed_wait_mutex): Use conditionalized error code if `ETIMEDOUT' is not available. (scm_thread_usleep): Remove bogus declaration of `struct timeval timeout'. * numbers.c (PTRDIFF_MIN): Moved this definition where it actually belongs. That is because NO_PREPRO_MAGIC gets undefined after each inclusion of `num2integral.i.c'. (SIZE_MAX): Define NO_PREPRO_MAGIC if SIZE_MAX is undefined. 2001-11-04 Stefan Jahn * md/Makefile.am (EXTRA_DIST): Added `i386.asm'. * md/i386.asm: New file. Contains the Intel syntax version for nasm/tasm/masm of the file `i386.s'. * qt.h.in: Definition of QT_API, QT_IMPORT and QT_EXPORT. Prefixed each symbols which is meant to go into a DLL. * Makefile.am (libqthreads_la_LDFLAGS): Put `-no-undefined' into LDFLAGS to support linkers which do not allow unresolved symbols inside shared libraries. (EXTRA_DIST): Add `libqthreads.def', which is an export file definition for M$-Windows. It defines exported symbols. This is necessary because the M$VC linker does not know how to export assembler symbols into a DLL. 2001-11-04 Stefan Jahn * srfi-13.h, srfi-14.h, srfi-4.h: Follow-up patch. Renamed __FOO__ macros into FOO. 2001-11-04 Stefan Jahn * tests/ports.test: Run (close-port) before (delete-file) if necessary/advisory. --- diff --git a/ChangeLog b/ChangeLog index aee0757db..ead195902 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2001-11-04 Stefan Jahn + + * NEWS: Corrected remarks about SCM_API. + + * configure.in: Defining USE_DLL_IMPORT definition to indicate + usage of DLL import macros in `libguile/__scm.h'. + (LIBOBJS): Removed `fileblocks.o' from the list of object files. + Somehow Jim Blandy's patch from 1997 did not survive. + 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! @@ -6,9 +15,9 @@ build systems which do not have symbolic links. * configure.in: Define AC_LIBTOOL_WIN32_DLL to build clean dlls on Win32 platforms. - Checking for `ws2_32.dll', `winsock2.h', add `uname.o' and - `dirent.o' and define extra compiler flags necessary to build - clean dlls. + Checking for `ws2_32.dll', `winsock2.h', add `win32-uname.o' + and `win32-dirent.o' and define extra compiler flags necessary + to build clean dlls. Check for `regcomp()' inside `-lregex'. 2001-10-26 Thien-Thi Nguyen diff --git a/NEWS b/NEWS index 75987bfda..f8fb643b7 100644 --- a/NEWS +++ b/NEWS @@ -32,12 +32,12 @@ declaration. This macro can expand into different things, the most common of which is just "extern" for Unix platforms. On Win32, it can be used to control which symbols are exported from a DLL. -If you `#define __SCM_IMPORT__' before including , SCM_API +If you `#define SCM_IMPORT' before including , SCM_API will expand into "__declspec (dllimport) extern", which is needed for linking to the Guile DLL in Windows. -There are also __SCM_RL_IMPORT__, __SCM_SRFI1314_IMPORT__, and -__SCM_SRFI4_IMPORT__, for the corresponding libraries. +There are also SCM_RL_IMPORT, QT_IMPORT, SCM_SRFI1314_IMPORT, and +SCM_SRFI4_IMPORT, for the corresponding libraries. Changes since Guile 1.4: diff --git a/configure.in b/configure.in index 1a95617a9..01f5b6525 100644 --- a/configure.in +++ b/configure.in @@ -228,19 +228,18 @@ dnl dnl Check for Winsock and other functionality on Win32 (*not* CygWin) dnl EXTRA_DEFS="" -EXTRA_LIB_DEFS="" if test "$MINGW32" = "yes" ; then AC_CHECK_HEADER(winsock2.h, [AC_DEFINE([HAVE_WINSOCK2_H], 1, [Define if you have the header file.])]) AC_CHECK_LIB(ws2_32, main) - LIBOBJS="$LIBOBJS uname.o dirent.o" + LIBOBJS="$LIBOBJS win32-uname.o win32-dirent.o" if test $enable_shared = yes ; then - EXTRA_DEFS="-D__SCM_IMPORT__ -D__REGEX_IMPORT__ -D__CRYPT_IMPORT__" - EXTRA_LIB_DEFS="-D__REGEX_IMPORT__ -D__CRYPT_IMPORT__" + EXTRA_DEFS="-DSCM_IMPORT" + AC_DEFINE(USE_DLL_IMPORT, 1, + [Define if you need additional CPP macros on Win32 platforms.]) fi fi AC_SUBST(EXTRA_DEFS) -AC_SUBST(EXTRA_LIB_DEFS) dnl Check for dynamic linking @@ -614,6 +613,10 @@ esac AC_PROG_AWK +## Remove fileblocks.o from the object list. This file gets added by +## the Autoconf macro AC_STRUCT_ST_BLOCKS. But there is no need. +LIBOBJS="`echo ${LIBOBJS} | sed 's/fileblocks\.o//g'`" + ## If we're creating a shared library (using libtool!), then we'll ## need to generate a list of .lo files corresponding to the .o files ## given in LIBOBJS. We'll call it LIBLOBJS. diff --git a/guile-readline/ChangeLog b/guile-readline/ChangeLog index 4c23f0457..1173e7709 100644 --- a/guile-readline/ChangeLog +++ b/guile-readline/ChangeLog @@ -1,3 +1,15 @@ +2001-11-04 Stefan Jahn + + * configure.in (EXTRA_DEFS): Follow-up patch. Using SCM_IMPORT + instead of __SCM_IMPORT__. + + * readline.c (scm_readline_init_ports): Disable input/output + stream redirection for Win32. The readline package for Win32 + does not support this. The guile-readline library works fine + for command line editing. + + * readline.h (SCM_RL_API): Renamed __FOO__ macros into FOO. + 2001-11-02 Marius Vollmer Support for native Win32. Thanks to Stefan Jahn! diff --git a/guile-readline/configure.in b/guile-readline/configure.in index c6162e033..eb7b1b02b 100644 --- a/guile-readline/configure.in +++ b/guile-readline/configure.in @@ -20,7 +20,7 @@ AC_MINGW32 EXTRA_DEFS="" if test "$MINGW32" = "yes" ; then if test $enable_shared = yes ; then - EXTRA_DEFS="-D__SCM_IMPORT__ -D__READLINE_IMPORT__" + EXTRA_DEFS="-DSCM_IMPORT" fi fi AC_SUBST(EXTRA_DEFS) diff --git a/guile-readline/readline.c b/guile-readline/readline.c index 6fcd656bf..0802fa3dc 100644 --- a/guile-readline/readline.c +++ b/guile-readline/readline.c @@ -212,8 +212,10 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0, (void *) SCM_UNPACK (text), handle_error, 0); +#ifndef __MINGW32__ fclose (rl_instream); fclose (rl_outstream); +#endif --in_readline; return ans; @@ -246,8 +248,10 @@ handle_error (void *data, SCM tag, SCM args) rl_free_line_state (); rl_cleanup_after_signal (); fputc ('\n', rl_outstream); /* We don't want next output on this line */ +#ifndef __MINGW32__ fclose (rl_instream); fclose (rl_outstream); +#endif --in_readline; scm_handle_by_throw (data, tag, args); return SCM_UNSPECIFIED; /* never reached */ @@ -317,8 +321,10 @@ scm_readline_init_ports (SCM inp, SCM outp) } input_port = inp; +#ifndef __MINGW32__ rl_instream = stream_from_fport (inp, "r", s_scm_readline); rl_outstream = stream_from_fport (outp, "w", s_scm_readline); +#endif } @@ -482,10 +488,13 @@ find_matching_paren(int k) static int match_paren (int x, int k) { - int tmp, fno; + int tmp; +#ifndef __MINGW32__ + int fno; SELECT_TYPE readset; struct timeval timeout; - +#endif + rl_insert (x, k); if (!SCM_READLINE_BOUNCE_PARENS) return 0; @@ -495,13 +504,15 @@ match_paren (int x, int k) && rl_line_buffer[rl_point - 2] == '\\') return 0; +#ifndef __MINGW32__ tmp = 1000 * SCM_READLINE_BOUNCE_PARENS; timeout.tv_sec = tmp / 1000000; timeout.tv_usec = tmp % 1000000; FD_ZERO (&readset); fno = fileno (rl_instream); FD_SET (fno, &readset); - +#endif + if (rl_point > 1) { tmp = rl_point; @@ -509,7 +520,12 @@ match_paren (int x, int k) if (rl_point > -1) { rl_redisplay (); +#ifndef __MINGW32__ scm_internal_select (fno + 1, &readset, NULL, NULL, &timeout); +#else + WaitForSingleObject (GetStdHandle(STD_INPUT_HANDLE), + SCM_READLINE_BOUNCE_PARENS); +#endif } rl_point = tmp; } @@ -545,7 +561,9 @@ scm_init_readline () #include "guile-readline/readline.x" scm_readline_completion_function_var = scm_c_define ("*readline-completion-function*", SCM_BOOL_F); +#ifndef __MINGW32__ rl_getc_function = current_input_getc; +#endif rl_redisplay_function = redisplay; #if defined (_RL_FUNCTION_TYPEDEF) rl_completion_entry_function = (rl_compentry_func_t*) completion_function; diff --git a/guile-readline/readline.h b/guile-readline/readline.h index 327708270..1fc51de4f 100644 --- a/guile-readline/readline.h +++ b/guile-readline/readline.h @@ -24,10 +24,10 @@ which should be exported or imported in the resulting dynamic link library in the Win32 port. */ -#if defined (__SCM_RL_IMPORT__) -# define SCM_RL_API __declspec (dllimport) -#elif defined (__SCM_RL_EXPORT__) || defined (DLL_EXPORT) -# define SCM_RL_API __declspec (dllexport) +#if defined (SCM_RL_IMPORT) +# define SCM_RL_API __declspec (dllimport) extern +#elif defined (SCM_RL_EXPORT) || defined (DLL_EXPORT) +# define SCM_RL_API __declspec (dllexport) extern #else # define SCM_RL_API extern #endif diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 38f136a3c..e0c7f9996 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,39 @@ +2001-11-04 Stefan Jahn + + * Makefile.am (libguile_la_LIBADD): Added $(THREAD_LIBS_LOCAL) + here (was at guile_LDADD) which describes the dependency + correctly and allows a clean build on Win32. + + * __scm.h (SCM_API): Follow-up patch. Renamed __FOO__ macros + into FOO. + + * __scm.h: USE_DLL_IMPORT indicates the usage of the DLL + import macros for external libraries (libcrypt, libqthreads, + libreadline and libregex). + + * coop-defs.h: Include for `struct timeval'. + + * posix.c (flock): Added support for flock() in M$-Windows. + + * guile.c (SCM_IMPORT): Follow-up patch. Use SCM_IMPORT instead + of __SCM_IMPORT__. + + * fports.c (getflags): Differentiate reading and writing pipes + descriptors. + + * filesys.c (S_IS*): Redefine all of the S_IS*() macros for + M$-Windows. + + * coop.c (coop_condition_variable_timed_wait_mutex): Use + conditionalized error code if `ETIMEDOUT' is not available. + (scm_thread_usleep): Remove bogus declaration of `struct timeval + timeout'. + + * numbers.c (PTRDIFF_MIN): Moved this definition where it actually + belongs. That is because NO_PREPRO_MAGIC gets undefined after + each inclusion of `num2integral.i.c'. + (SIZE_MAX): Define NO_PREPRO_MAGIC if SIZE_MAX is undefined. + 2001-11-03 Marius Vollmer * eval.c (scm_m_begin): Allow `(begin)`, with no subforms. diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 16ab8213d..517bbda74 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -22,7 +22,7 @@ AUTOMAKE_OPTIONS = gnu ## Prevent automake from adding extra -I options -DEFS = @DEFS@ @EXTRA_LIB_DEFS@ +DEFS = @DEFS@ ## Check for headers in $(srcdir)/.., so that #include ## will find MUMBLE.h in this dir when we're ## building. @@ -35,7 +35,7 @@ lib_LTLIBRARIES = libguile.la bin_PROGRAMS = guile guile_filter_doc_snarfage guile_SOURCES = guile.c -guile_LDADD = libguile.la ${THREAD_LIBS_LOCAL} +guile_LDADD = libguile.la guile_LDFLAGS = @DLPREOPEN@ guile_filter_doc_snarfage_SOURCES = c-tokenize.c @@ -115,7 +115,7 @@ noinst_HEADERS = coop-threads.c coop-threads.h coop.c \ num2integral.i.c num2float.i.c win32-uname.h win32-dirent.h libguile_la_DEPENDENCIES = @LIBLOBJS@ -libguile_la_LIBADD = @LIBLOBJS@ $(LIBLTDL) +libguile_la_LIBADD = @LIBLOBJS@ $(LIBLTDL) $(THREAD_LIBS_LOCAL) libguile_la_LDFLAGS = -version-info @LIBGUILE_INTERFACE_CURRENT@:@LIBGUILE_INTERFACE_REVISION@:@LIBGUILE_INTERFACE_AGE@ -export-dynamic -no-undefined # These are headers visible as diff --git a/libguile/__scm.h b/libguile/__scm.h index b24158b51..2ae4cdf29 100644 --- a/libguile/__scm.h +++ b/libguile/__scm.h @@ -159,11 +159,11 @@ /* SCM_API is a macro prepended to all function and data definitions which should be exported or imported in the resulting dynamic link - library in the Win32 port. */ + library (DLL) in the Win32 port. */ -#if defined (__SCM_IMPORT__) +#if defined (SCM_IMPORT) # define SCM_API __declspec (dllimport) extern -#elif defined (__SCM_EXPORT__) || defined (DLL_EXPORT) +#elif defined (SCM_EXPORT) || defined (DLL_EXPORT) # define SCM_API __declspec (dllexport) extern #else # define SCM_API extern @@ -334,6 +334,16 @@ typedef long ptrdiff_t; +/* Define some additional CPP macros on Win32 platforms. */ +#if USE_DLL_IMPORT +# define __REGEX_IMPORT__ 1 +# define __CRYPT_IMPORT__ 1 +# define __READLINE_IMPORT__ 1 +# define QT_IMPORT 1 +#endif + + + #include "libguile/tags.h" diff --git a/libguile/coop-defs.h b/libguile/coop-defs.h index b9c5b4f9c..3863b1690 100644 --- a/libguile/coop-defs.h +++ b/libguile/coop-defs.h @@ -63,6 +63,10 @@ #include "libguile/iselect.h" #endif +#if HAVE_WINSOCK2_H +#include +#endif + #ifdef GUILE_PTHREAD_COMPAT #include #endif diff --git a/libguile/coop.c b/libguile/coop.c index 987a71f9a..ca057b423 100644 --- a/libguile/coop.c +++ b/libguile/coop.c @@ -40,7 +40,7 @@ * If you do not wish that, delete this exception notice. */ -/* $Id: coop.c,v 1.28 2001-10-06 16:30:20 mdj Exp $ */ +/* $Id: coop.c,v 1.29 2001-11-04 15:52:29 ela Exp $ */ /* Cooperative thread library, based on QuickThreads */ @@ -422,7 +422,13 @@ coop_condition_variable_timed_wait_mutex (coop_c *c, const struct timespec *abstime) { coop_t *old, *t; +#ifdef ETIMEDOUT int res = ETIMEDOUT; +#elif defined (WSAETIMEDOUT) + int res = WSAETIMEDOUT; +#else + int res = 0; +#endif /* coop_mutex_unlock (m); */ t = coop_qget (&(m->waiting)); @@ -842,7 +848,6 @@ scm_thread_usleep (unsigned long usec) { /* We're so cheap. */ scm_thread_sleep (usec / 1000000); - struct timeval timeout; return 0; /* Maybe we should calculate actual time slept, but this is faster... :) */ } diff --git a/libguile/filesys.c b/libguile/filesys.c index 93015d8df..806c8c10f 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -128,17 +128,60 @@ /* 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_IFSOCK 0xC000 -# define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK) -#endif -#if defined (__BORLANDC__) || defined (_MSC_VER) -# define _S_IFBLK 0x3000 -# define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK) + +# ifdef _S_IFIFO +# undef _S_IFIFO +# endif +# ifdef _S_IFCHR +# undef _S_IFCHR +# endif +# ifdef _S_IFBLK +# undef _S_IFBLK +# endif +# ifdef _S_IFDIR +# undef _S_IFDIR +# endif +# ifdef _S_IFREG +# undef _S_IFREG +# endif +# ifdef _S_IFSOCK +# undef _S_IFSOCK +# endif + +# define _S_IFIFO 0x1000 /* FIFO */ +# define _S_IFCHR 0x2000 /* Character */ +# define _S_IFBLK 0x3000 /* Block */ +# define _S_IFDIR 0x4000 /* Directory */ +# define _S_IFREG 0x8000 /* Regular */ +# define _S_IFSOCK 0xC000 /* Socket */ + +# ifdef S_ISBLK +# undef S_ISBLK +# endif +# ifdef S_ISFIFO +# undef S_ISFIFO +# endif +# ifdef S_ISCHR +# undef S_ISCHR +# endif +# ifdef S_ISDIR +# undef S_ISDIR +# endif +# ifdef S_ISREG +# undef S_ISREG +# endif +# ifdef S_ISSOCK +# undef S_ISSOCK +# endif + +# define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK) # 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 +# 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) +# define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK) + +#endif /* __MINGW32__ */ /* Some more definitions for the native Windows port. */ #ifdef __MINGW32__ diff --git a/libguile/fports.c b/libguile/fports.c index 6c1106052..426db6f55 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -380,7 +380,8 @@ static int getflags (int fdes) { /* Or an anonymous pipe handle ? */ if (buf.st_mode & _S_IFIFO) - flags = O_RDWR; + flags = PeekNamedPipe ((HANDLE) _get_osfhandle (fdes), NULL, 0, + NULL, NULL, NULL) ? O_RDONLY : O_WRONLY; /* stdin ? */ else if (fdes == fileno (stdin) && isatty (fdes)) flags = O_RDONLY; diff --git a/libguile/guile.c b/libguile/guile.c index 18df2af30..ae17a9606 100644 --- a/libguile/guile.c +++ b/libguile/guile.c @@ -47,7 +47,7 @@ system. For now, please don't put interesting code in here. */ #ifdef __MINGW32__ -# define __SCM_IMPORT__ 1 +# define SCM_IMPORT 1 #endif #include diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index 09a6e03fa..fa1d8c6ec 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -93,13 +93,13 @@ INTEGRAL2NUM (ITYPE n) #define NEED_CHECK #else #ifdef UNSIGNED - /*#if MAX_VALUE > SCM_MOST_POSITIVE_FIXNUM*/ +#if MAX_VALUE>SCM_MOST_POSITIVE_FIXNUM #define NEED_CHECK - /*#endif*/ +#endif #else - /*#if MIN_VALUESCM_MOST_POSITIVE_FIXNUM*/ +#if MIN_VALUESCM_MOST_POSITIVE_FIXNUM #define NEED_CHECK - /*#endif*/ +#endif #endif #endif diff --git a/libguile/numbers.c b/libguile/numbers.c index 0786697b6..e9760b812 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -4258,22 +4258,6 @@ scm_i_big2dbl (SCM b) # endif #endif -#ifndef SIZE_MAX -#define SIZE_MAX ((size_t) (-1)) -#endif - -#ifndef PTRDIFF_MIN -/* the below is not really guaranteed to work (I think), but probably does: */ -#define PTRDIFF_MIN ((ptrdiff_t) ((ptrdiff_t)1 << (sizeof (ptrdiff_t)*8 - 1))) -/* this prevents num2integral.c.i from using PTRDIFF_MIN in - preprocessor expressions. */ -#define NO_PREPRO_MAGIC -#endif - -#ifndef PTRDIFF_MAX -#define PTRDIFF_MAX (~ PTRDIFF_MIN) -#endif - #define NUM2INTEGRAL scm_num2short #define INTEGRAL2NUM scm_short2num #define INTEGRAL2BIG scm_i_short2big @@ -4322,6 +4306,18 @@ scm_i_big2dbl (SCM b) #define MAX_VALUE ULONG_MAX #include "libguile/num2integral.i.c" +#ifndef PTRDIFF_MIN +/* the below is not really guaranteed to work (I think), but probably does: */ +#define PTRDIFF_MIN ((ptrdiff_t) ((ptrdiff_t)1 << (sizeof (ptrdiff_t)*8 - 1))) +/* this prevents num2integral.c.i from using PTRDIFF_MIN in + preprocessor expressions. */ +#define NO_PREPRO_MAGIC +#endif + +#ifndef PTRDIFF_MAX +#define PTRDIFF_MAX (~ PTRDIFF_MIN) +#endif + #define NUM2INTEGRAL scm_num2ptrdiff #define INTEGRAL2NUM scm_ptrdiff2num #define INTEGRAL2BIG scm_i_ptrdiff2big @@ -4330,6 +4326,11 @@ scm_i_big2dbl (SCM b) #define MAX_VALUE PTRDIFF_MAX #include "libguile/num2integral.i.c" +#ifndef SIZE_MAX +#define SIZE_MAX ((size_t) (-1)) +#define NO_PREPRO_MAGIC +#endif + #define NUM2INTEGRAL scm_num2size #define INTEGRAL2NUM scm_size2num #define INTEGRAL2BIG scm_i_size2big diff --git a/libguile/posix.c b/libguile/posix.c index 70b30f6fd..033678947 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -1502,7 +1502,73 @@ SCM_DEFINE (scm_getpass, "getpass", 1, 0, 0, #undef FUNC_NAME #endif /* HAVE_GETPASS */ -#if HAVE_FLOCK +/* Wrapper function for flock() support under M$-Windows. */ +#ifdef __MINGW32__ +# include +# include +# include +# ifndef _LK_UNLCK + /* Current MinGW package fails to define this. *sigh* */ +# define _LK_UNLCK 0 +# endif +# define LOCK_EX 1 +# define LOCK_UN 2 +# define LOCK_SH 4 +# define LOCK_NB 8 + +static int flock (int fd, int operation) +{ + long pos, len; + int ret, err; + + /* Disable invalid arguments. */ + if (((operation & (LOCK_EX | LOCK_SH)) == (LOCK_EX | LOCK_SH)) || + ((operation & (LOCK_EX | LOCK_UN)) == (LOCK_EX | LOCK_UN)) || + ((operation & (LOCK_SH | LOCK_UN)) == (LOCK_SH | LOCK_UN))) + { + errno = EINVAL; + return -1; + } + + /* Determine mode of operation and discard unsupported ones. */ + if (operation == (LOCK_NB | LOCK_EX)) + operation = _LK_NBLCK; + else if (operation & LOCK_UN) + operation = _LK_UNLCK; + else if (operation == LOCK_EX) + operation = _LK_LOCK; + else + { + errno = EINVAL; + return -1; + } + + /* Save current file pointer and seek to beginning. */ + if ((pos = lseek (fd, 0, SEEK_CUR)) == -1 || (len = filelength (fd)) == -1) + return -1; + lseek (fd, 0L, SEEK_SET); + + /* Deadlock if necessary. */ + do + { + ret = _locking (fd, operation, len); + } + while (ret == -1 && errno == EDEADLOCK); + + /* Produce meaningful error message. */ + if (errno == EACCES && operation == _LK_NBLCK) + err = EDEADLOCK; + else + err = errno; + + /* Return to saved file position pointer. */ + lseek (fd, pos, SEEK_SET); + errno = err; + return ret; +} +#endif /* __MINGW32__ */ + +#if HAVE_FLOCK || defined (__MINGW32__) SCM_DEFINE (scm_flock, "flock", 2, 0, 0, (SCM file, SCM operation), "Apply or remove an advisory lock on an open file.\n" diff --git a/qt/ChangeLog b/qt/ChangeLog index 2d8c015e9..be11f91c3 100644 --- a/qt/ChangeLog +++ b/qt/ChangeLog @@ -1,3 +1,21 @@ +2001-11-04 Stefan Jahn + + * md/Makefile.am (EXTRA_DIST): Added `i386.asm'. + + * md/i386.asm: New file. Contains the Intel syntax version for + nasm/tasm/masm of the file `i386.s'. + + * qt.h.in: Definition of QT_API, QT_IMPORT and QT_EXPORT. + Prefixed each symbols which is meant to go into a DLL. + + * Makefile.am (libqthreads_la_LDFLAGS): Put `-no-undefined' + into LDFLAGS to support linkers which do not allow unresolved + symbols inside shared libraries. + (EXTRA_DIST): Add `libqthreads.def', which is an export file + definition for M$-Windows. It defines exported symbols. This is + necessary because the M$VC linker does not know how to export + assembler symbols into a DLL. + 2001-08-25 Marius Vollmer * Makefile.am, md/Makefile.am, time/Makefile.am: diff --git a/qt/Makefile.am b/qt/Makefile.am index 926f15575..25f05a657 100644 --- a/qt/Makefile.am +++ b/qt/Makefile.am @@ -34,7 +34,7 @@ INCLUDES = -I.. -I$(srcdir)/.. libqthreads_la_SOURCES = qt.c copyright.h libqthreads_la_LIBADD = qtmds.lo qtmdc.lo libqthreads_la_DEPENDENCIES = qtmds.lo qtmdc.lo -libqthreads_la_LDFLAGS = -rpath $(libdir) -version-info @LIBGUILEQTHREADS_INTERFACE_CURRENT@:@LIBGUILEQTHREADS_INTERFACE_REVISION@:@LIBGUILEQTHREADS_INTERFACE_AGE@ -export-dynamic +libqthreads_la_LDFLAGS = -rpath $(libdir) -version-info @LIBGUILEQTHREADS_INTERFACE_CURRENT@:@LIBGUILEQTHREADS_INTERFACE_REVISION@:@LIBGUILEQTHREADS_INTERFACE_AGE@ -export-dynamic -no-undefined OMIT_DEPENDENCIES = axp.h hppa.h i386.h ksr.h m88k.h mips.h sparc.h vax.h @@ -48,4 +48,4 @@ qtdmdb.s: ${LN_S} ${srcdir}/${qtdmdb_s} qtdmdb.s EXTRA_DIST = CHANGES README.MISC README.PORT b.h meas.c stp.c stp.h \ - Makefile.base config + Makefile.base config libqthreads.def diff --git a/qt/libqthreads.def b/qt/libqthreads.def new file mode 100644 index 000000000..c7cfcd5f2 --- /dev/null +++ b/qt/libqthreads.def @@ -0,0 +1,10 @@ +LIBRARY libqthreads +DESCRIPTION "libqthreads: QuickThreads Library" +EXPORTS + qt_abort + qt_block + qt_blocki + qt_error + qt_null + qt_vargs + qt_vstart diff --git a/qt/md/Makefile.am b/qt/md/Makefile.am index 66e2ea8bd..46fffd152 100644 --- a/qt/md/Makefile.am +++ b/qt/md/Makefile.am @@ -27,4 +27,4 @@ hppa-cnx.Makefile hppa.Makefile hppa.h hppa.s hppa_b.s i386.README \ i386.h i386.s i386_b.s ksr1.Makefile ksr1.h ksr1.s ksr1_b.s \ m88k.Makefile m88k.c m88k.h m88k.s m88k_b.s mips-irix5.s mips.h mips.s \ mips_b.s null.README null.c solaris.README sparc.h sparc.s sparc_b.s \ -vax.h vax.s vax_b.s +vax.h vax.s vax_b.s i386.asm diff --git a/qt/md/i386.asm b/qt/md/i386.asm new file mode 100644 index 000000000..b79f165df --- /dev/null +++ b/qt/md/i386.asm @@ -0,0 +1,112 @@ +;; i386.asm -- assembly support. + +;; +;; QuickThreads -- Threads-building toolkit. +;; Copyright (c) 2001 Free Software Foundation, Inc. +;; +;; Permission to use, copy, modify and distribute this software and +;; its documentation for any purpose and without fee is hereby +;; granted, provided that the above copyright notice and this notice +;; appear in all copies. This software is provided as a +;; proof-of-concept and for demonstration purposes; there is no +;; representation about the suitability of this software for any +;; purpose. + +;; NOTE: double-labeled `_name' and `name' for System V compatability. +;; NOTE: Comment lines start like this one, or with '//' ONLY. Sorry! + +;; Callee-save: %esi, %edi, %ebx, %ebp +;; Caller-save: %eax, %ecx +;; Can't tell: %edx (seems to work w/o saving it.) +;; +;; Assignment: +;; +;; See ``i386.h'' for the somewhat unconventional stack layout. + + + .386p + .model flat + .code + + public _qt_abort + public qt_abort + public _qt_block + public qt_block + public _qt_blocki + public qt_blocki + +;; These all have the type signature +;; +;; void *blocking (helper, arg0, arg1, new) +;; +;; On procedure entry, the helper is at 4(sp), args at 8(sp) and +;; 12(sp) and the new thread's sp at 16(sp). It *appears* that the +;; calling convention for the 8X86 requires the caller to save all +;; floating-point registers, this makes our life easy. + +;; Halt the currently-running thread. Save it's callee-save regs on +;; to the stack, 32 bytes. Switch to the new stack (next == 16+32(sp)) +;; and call the user function (f == 4+32(sp) with arguments: old sp +;; arg1 (8+32(sp)) and arg2 (12+32(sp)). When the user function is +;; done, restore the new thread's state and return. +;; +;; `qt_abort' is (currently) an alias for `qt_block' because most of +;; the work is shared. We could save the insns up to `qt_common' by +;; replicating, but w/o replicating we need an inital subtract (to +;; offset the stack as if it had been a qt_block) and then a jump +;; to qt_common. For the cost of a jump, we might as well just do +;; all the work. +;; +;; The helper function (4(sp)) can return a void* that is returned +;; by the call to `qt_blockk{,i}'. Since we don't touch %eax in +;; between, we get that ``for free''. + +_qt_abort: +qt_abort: +_qt_block: +qt_block: +_qt_blocki: +qt_blocki: + push ebp ; Save callee-save, sp-=4. + push esi ; Save callee-save, sp-=4. + push edi ; Save callee-save, sp-=4. + push ebx ; Save callee-save, sp-=4. + mov eax, esp ; Remember old stack pointer. + +qt_common: + mov esp, [esp+32] ; Move to new thread. + push [eax+28] ; Push arg 2. + push [eax+24] ; Push arg 1. + push eax ; Push arg 0. + mov ebx, [eax+20] ; Get function to call. + call ebx ; Call f. + add esp, 12 ; Pop args. + + pop ebx ; Restore callee-save, sp+=4. + pop edi ; Restore callee-save, sp+=4. + pop esi ; Restore callee-save, sp+=4. + pop ebp ; Restore callee-save, sp+=4. + ret ; Resume the stopped function. + hlt + + +;; Start a varargs thread. + + public _qt_vstart + public qt_vstart + +_qt_vstart: +qt_vstart: + push edi ; Push `pt' arg to `startup'. + call ebp ; Call `startup'. + pop eax ; Clean up the stack. + + call ebx ; Call the user's function. + + push eax ; Push return from user's. + push edi ; Push `pt' arg to `cleanup'. + call esi ; Call `cleanup'. + + hlt ; `cleanup' never returns. + + end diff --git a/qt/md/i386.h b/qt/md/i386.h index 158fe2703..d7feba010 100644 --- a/qt/md/i386.h +++ b/qt/md/i386.h @@ -58,7 +58,7 @@ typedef unsigned long qt_word_t; /* What to do to start a varargs thread running. */ -extern void qt_vstart (void); +QT_API void qt_vstart (void); /* Hold 4 saved regs plus two return pcs (qt_error, qt_start) plus @@ -101,7 +101,7 @@ extern void qt_vstart (void); pop off (preincrement, postdecrement). */ #define QT_GROW_DOWN -extern void qt_error (void); +QT_API void qt_error (void); /* Push on the error return address. */ #define QT_ARGS_MD(sto) \ diff --git a/qt/qt.h.in b/qt/qt.h.in index bd79e78d0..6399a89d1 100644 --- a/qt/qt.h.in +++ b/qt/qt.h.in @@ -1,6 +1,14 @@ #ifndef QT_H #define QT_H +#if defined (QT_IMPORT) +# define QT_API __declspec (dllimport) extern +#elif defined (QT_EXPORT) || defined (DLL_EXPORT) +# define QT_API __declspec (dllexport) extern +#else +# define QT_API extern +#endif + #ifdef __cplusplus extern "C" { #endif @@ -126,7 +134,7 @@ typedef void (qt_cleanup_t)(void *pt, void *vuserf_return); #define QT_VADJ(sp) (((char *)sp) + QT_VSTKBASE) #endif -extern qt_t *qt_vargs (qt_t *sp, int nbytes, void *vargs, +QT_API qt_t *qt_vargs (qt_t *sp, int nbytes, void *vargs, void *pt, qt_startup_t *startup, qt_vuserf_t *vuserf, qt_cleanup_t *cleanup); @@ -137,8 +145,8 @@ extern qt_t *qt_vargs (qt_t *sp, int nbytes, void *vargs, #endif -extern void qt_null (void); -extern void qt_error (void); +QT_API void qt_null (void); +QT_API void qt_error (void); /* Save the state of the thread and call the helper function using the stack of the new thread. */ @@ -149,7 +157,7 @@ typedef void *(qt_block_t)(qt_helper_t *helper, void *a0, void *a1, /* Rearrange the parameters so that things passed to the helper function are already in the right argument registers. */ #ifndef QT_ABORT -extern void qt_abort (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); +QT_API void qt_abort (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); /* The following does, technically, `return' a value, but the user had better not rely on it, since the function never returns. */ @@ -158,14 +166,14 @@ extern void qt_abort (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); #endif #ifndef QT_BLOCK -extern void *qt_block (qt_helper_t *h, void *a0, void *a1, +QT_API void *qt_block (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); #define QT_BLOCK(h, a0, a1, newthread) \ (qt_block (h, a0, a1, newthread)) #endif #ifndef QT_BLOCKI -extern void *qt_blocki (qt_helper_t *h, void *a0, void *a1, +QT_API void *qt_blocki (qt_helper_t *h, void *a0, void *a1, qt_t *newthread); #define QT_BLOCKI(h, a0, a1, newthread) \ (qt_blocki (h, a0, a1, newthread)) diff --git a/srfi/ChangeLog b/srfi/ChangeLog index 3504a15b0..34bd08a47 100644 --- a/srfi/ChangeLog +++ b/srfi/ChangeLog @@ -1,3 +1,8 @@ +2001-11-04 Stefan Jahn + + * srfi-13.h, srfi-14.h, srfi-4.h: Follow-up patch. Renamed + __FOO__ macros into FOO. + 2001-11-03 Marius Vollmer * Makefile.am (libguile_srfi_srfi_4_la_LIBADD, diff --git a/srfi/srfi-13.h b/srfi/srfi-13.h index 0c81a43a5..1127cde26 100644 --- a/srfi/srfi-13.h +++ b/srfi/srfi-13.h @@ -50,9 +50,9 @@ which should be exported or imported in the resulting dynamic link library in the Win32 port. */ -#if defined (__SCM_SRFI1314_IMPORT__) +#if defined (SCM_SRFI1314_IMPORT) # define SCM_SRFI1314_API __declspec (dllimport) extern -#elif defined (__SCM_SRFI1314_EXPORT__) || defined (DLL_EXPORT) +#elif defined (SCM_SRFI1314_EXPORT) || defined (DLL_EXPORT) # define SCM_SRFI1314_API __declspec (dllexport) extern #else # define SCM_SRFI1314_API extern @@ -137,8 +137,4 @@ SCM_SRFI1314_API SCM scm_string_tokenize (SCM s, SCM token_char, SCM start, SCM SCM_SRFI1314_API SCM scm_string_filter (SCM s, SCM char_pred, SCM start, SCM end); SCM_SRFI1314_API SCM scm_string_delete (SCM s, SCM char_pred, SCM start, SCM end); - - - - #endif /* SCM_SRFI_13_H */ diff --git a/srfi/srfi-14.h b/srfi/srfi-14.h index fbf935e30..816ef0aa3 100644 --- a/srfi/srfi-14.h +++ b/srfi/srfi-14.h @@ -50,9 +50,9 @@ which should be exported or imported in the resulting dynamic link library in the Win32 port. */ -#if defined (__SCM_SRFI1314_IMPORT__) +#if defined (SCM_SRFI1314_IMPORT) # define SCM_SRFI1314_API __declspec (dllimport) extern -#elif defined (__SCM_SRFI1314_EXPORT__) || defined (DLL_EXPORT) +#elif defined (SCM_SRFI1314_EXPORT) || defined (DLL_EXPORT) # define SCM_SRFI1314_API __declspec (dllexport) extern #else # define SCM_SRFI1314_API extern diff --git a/srfi/srfi-4.h b/srfi/srfi-4.h index f53784d60..0a522991e 100644 --- a/srfi/srfi-4.h +++ b/srfi/srfi-4.h @@ -50,9 +50,9 @@ which should be exported or imported in the resulting dynamic link library in the Win32 port. */ -#if defined (__SCM_SRFI4_IMPORT__) +#if defined (SCM_SRFI4_IMPORT) # define SCM_SRFI4_API __declspec (dllimport) extern -#elif defined (__SCM_SRFI4_EXPORT__) || defined (DLL_EXPORT) +#elif defined (SCM_SRFI4_EXPORT) || defined (DLL_EXPORT) # define SCM_SRFI4_API __declspec (dllexport) extern #else # define SCM_SRFI4_API extern diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 5fae02107..b91212dad 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,8 @@ +2001-11-04 Stefan Jahn + + * tests/ports.test: Run (close-port) before (delete-file) if + necessary/advisory. + 2001-10-26 Dirk Herrmann * tests/eval.test: Added tests for promises. diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test index 956aac191..cc46ee855 100644 --- a/test-suite/tests/ports.test +++ b/test-suite/tests/ports.test @@ -91,6 +91,7 @@ (seek port -2 SEEK_END) (pass-if "file: r/w 4" (char=? (read-char port) #\s)) + (close-port port) (delete-file filename)) ;;; Unbuffered input/output port with seeking. @@ -110,6 +111,7 @@ (seek port -2 SEEK_END) (pass-if "file: ub r/w 4" (char=? (read-char port) #\s)) + (close-port port) (delete-file filename)) ;;; Buffered output-only and input-only ports with seeking. @@ -155,7 +157,8 @@ (pass-if "file: read back NUL 2" (char=? (string-ref line 3) #\nul)) (pass-if "file: EOF" - (eof-object? (read-char port)))) + (eof-object? (read-char port))) + (close-port port)) (delete-file filename)) ;;; line buffering mode.