diff options
-rw-r--r-- | libguile/Makefile.am | 4 | ||||
-rw-r--r-- | libguile/_scm.h | 66 | ||||
-rw-r--r-- | libguile/filesys.c | 1 | ||||
-rw-r--r-- | libguile/fports.c | 1 | ||||
-rw-r--r-- | libguile/i18n.c | 3 | ||||
-rw-r--r-- | libguile/ioext.c | 1 | ||||
-rw-r--r-- | libguile/poll.c | 1 | ||||
-rw-r--r-- | libguile/ports.c | 1 | ||||
-rw-r--r-- | libguile/posix.c | 1 | ||||
-rw-r--r-- | libguile/rw.c | 1 | ||||
-rw-r--r-- | libguile/scmsigs.c | 1 | ||||
-rw-r--r-- | libguile/script.c | 30 | ||||
-rw-r--r-- | libguile/socket.c | 1 | ||||
-rw-r--r-- | libguile/strports.c | 1 | ||||
-rw-r--r-- | libguile/syscalls.h | 100 |
15 files changed, 115 insertions, 98 deletions
diff --git a/libguile/Makefile.am b/libguile/Makefile.am index b27e183ec..3d2eef9f4 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -456,7 +456,9 @@ BUILT_SOURCES = cpp-E.c cpp-SIG.c libpath.h $(BUILT_INCLUDES) \ # Makefile expects it to be built. all-local: guile-procedures.texi -EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = _scm.h \ +EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = \ + _scm.h \ + syscalls.h \ memmove.c strerror.c \ dynl.c regex-posix.c \ posix.c net_db.c socket.c \ diff --git a/libguile/_scm.h b/libguile/_scm.h index d68e9c72d..cf89f2b70 100644 --- a/libguile/_scm.h +++ b/libguile/_scm.h @@ -88,84 +88,18 @@ #include "libguile/inline.h" #include "libguile/strings.h" -/* ASYNC_TICK after finding EINTR in order to handle pending signals, if - any. See comment in scm_syserror. */ -#define SCM_SYSCALL(line) \ - do \ - { \ - errno = 0; \ - line; \ - if (errno == EINTR) \ - { \ - scm_async_tick (); \ - errno = EINTR; \ - } \ - } \ - while (errno == EINTR) - - - /* Return the first integer greater than or equal to LEN such that LEN % ALIGN == 0. Return LEN if ALIGN is zero. */ #define ROUND_UP(len, align) \ ((align) ? (((len) - 1UL) | ((align) - 1UL)) + 1UL : (len)) - -#if defined GUILE_USE_64_CALLS && GUILE_USE_64_CALLS && defined(HAVE_STAT64) -#define CHOOSE_LARGEFILE(foo,foo64) foo64 -#else -#define CHOOSE_LARGEFILE(foo,foo64) foo -#endif - -/* These names are a bit long, but they make it clear what they represent. */ -#if SCM_HAVE_STRUCT_DIRENT64 == 1 -# define dirent_or_dirent64 CHOOSE_LARGEFILE(dirent,dirent64) -#else -# define dirent_or_dirent64 dirent -#endif -#define fstat_or_fstat64 CHOOSE_LARGEFILE(fstat,fstat64) -#define ftruncate_or_ftruncate64 CHOOSE_LARGEFILE(ftruncate,ftruncate64) -#define lseek_or_lseek64 CHOOSE_LARGEFILE(lseek,lseek64) -#define lstat_or_lstat64 CHOOSE_LARGEFILE(lstat,lstat64) -#define off_t_or_off64_t CHOOSE_LARGEFILE(off_t,off64_t) -#define open_or_open64 CHOOSE_LARGEFILE(open,open64) -#define readdir_or_readdir64 CHOOSE_LARGEFILE(readdir,readdir64) -#if SCM_HAVE_READDIR64_R == 1 -# define readdir_r_or_readdir64_r CHOOSE_LARGEFILE(readdir_r,readdir64_r) -#else -# define readdir_r_or_readdir64_r readdir_r -#endif -#define stat_or_stat64 CHOOSE_LARGEFILE(stat,stat64) -#define truncate_or_truncate64 CHOOSE_LARGEFILE(truncate,truncate64) -#define scm_from_off_t_or_off64_t CHOOSE_LARGEFILE(scm_from_off_t,scm_from_int64) -#define scm_from_ino_t_or_ino64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64) -#define scm_from_blkcnt_t_or_blkcnt64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64) -#define scm_to_off_t_or_off64_t CHOOSE_LARGEFILE(scm_to_off_t,scm_to_int64) - -#if SIZEOF_OFF_T == 4 -# define scm_to_off_t scm_to_int32 -# define scm_from_off_t scm_from_int32 -#elif SIZEOF_OFF_T == 8 -# define scm_to_off_t scm_to_int64 -# define scm_from_off_t scm_from_int64 -#else -# error sizeof(off_t) is not 4 or 8. -#endif -#define scm_to_off64_t scm_to_int64 -#define scm_from_off64_t scm_from_int64 - - - - #if (defined __GNUC__) # define SCM_NOINLINE __attribute__ ((__noinline__)) #else # define SCM_NOINLINE /* noinline */ #endif - - #endif /* SCM__SCM_H */ diff --git a/libguile/filesys.c b/libguile/filesys.c index f235ebb97..5778f6594 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -94,6 +94,7 @@ #include "libguile/smob.h" #include "libguile/srfi-13.h" #include "libguile/strings.h" +#include "libguile/syscalls.h" #include "libguile/validate.h" #include "libguile/vectors.h" diff --git a/libguile/fports.c b/libguile/fports.c index 3f976d411..ad040a39e 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -61,6 +61,7 @@ #include "libguile/posix.h" #include "libguile/read.h" #include "libguile/strings.h" +#include "libguile/syscalls.h" #include "libguile/validate.h" #if SIZEOF_OFF_T == SIZEOF_INT diff --git a/libguile/i18n.c b/libguile/i18n.c index 47179d178..0f8b0ea7b 100644 --- a/libguile/i18n.c +++ b/libguile/i18n.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006-2014, 2017 Free Software Foundation, Inc. +/* Copyright (C) 2006-2014,2017-2018 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -29,6 +29,7 @@ #include "libguile/strings.h" #include "libguile/chars.h" #include "libguile/dynwind.h" +#include "libguile/syscalls.h" #include "libguile/validate.h" #include "libguile/values.h" #include "libguile/threads.h" diff --git a/libguile/ioext.c b/libguile/ioext.c index 1528eee62..7ef08eb8f 100644 --- a/libguile/ioext.c +++ b/libguile/ioext.c @@ -39,6 +39,7 @@ #include "libguile/ports-internal.h" #include "libguile/ports.h" #include "libguile/strings.h" +#include "libguile/syscalls.h" #include "libguile/validate.h" #include "libguile/weak-set.h" diff --git a/libguile/poll.c b/libguile/poll.c index 5dae64ac0..df02ab0bd 100644 --- a/libguile/poll.c +++ b/libguile/poll.c @@ -34,6 +34,7 @@ #include "libguile/extensions.h" #include "libguile/numbers.h" #include "libguile/ports-internal.h" +#include "libguile/syscalls.h" #include "libguile/validate.h" #include "libguile/poll.h" diff --git a/libguile/ports.c b/libguile/ports.c index 92aea3f32..555e48a64 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -58,6 +58,7 @@ #include "libguile/ports.h" #include "libguile/ports-internal.h" #include "libguile/private-options.h" +#include "libguile/syscalls.h" #include "libguile/vectors.h" #include "libguile/weak-set.h" #include "libguile/fluids.h" diff --git a/libguile/posix.c b/libguile/posix.c index 3e6d50a78..e83cfc86f 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -74,6 +74,7 @@ #include "libguile/strings.h" #include "libguile/srfi-13.h" #include "libguile/srfi-14.h" +#include "libguile/syscalls.h" #include "libguile/vectors.h" #include "libguile/values.h" diff --git a/libguile/rw.c b/libguile/rw.c index 3b0c4bd68..8387d944b 100644 --- a/libguile/rw.c +++ b/libguile/rw.c @@ -36,6 +36,7 @@ #include "libguile/validate.h" #include "libguile/modules.h" #include "libguile/strports.h" +#include "libguile/syscalls.h" #include "libguile/ports-internal.h" #include <unistd.h> diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index ece81e6e1..b7773d49f 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -48,6 +48,7 @@ #include "libguile/feature.h" #include "libguile/eval.h" #include "libguile/vectors.h" +#include "libguile/syscalls.h" #include "libguile/threads.h" #include "libguile/validate.h" diff --git a/libguile/script.c b/libguile/script.c index f59ad1eef..b24d10aa2 100644 --- a/libguile/script.c +++ b/libguile/script.c @@ -78,36 +78,6 @@ scm_cat_path (char *str1, const char *str2, long n) return str1; } -#if 0 -static char * -scm_try_path (char *path) -{ - FILE *f; - /* fprintf(stderr, "Trying %s\n", path);fflush(stderr); */ - if (!path) - return 0L; - SCM_SYSCALL (f = fopen (path, "r"); - ); - if (f) - { - fclose (f); - return path; - } - free (path); - return 0L; -} - -static char * -scm_sep_init_try (char *path, const char *sep, const char *initname) -{ - if (path) - path = scm_cat_path (path, sep, 0L); - if (path) - path = scm_cat_path (path, initname, 0L); - return scm_try_path (path); -} -#endif - #ifndef LINE_INCREMENTORS #define LINE_INCREMENTORS '\n' #ifdef MSDOS diff --git a/libguile/socket.c b/libguile/socket.c index 13ce514e8..7f21a5996 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -55,6 +55,7 @@ #include "libguile/vectors.h" #include "libguile/dynwind.h" #include "libguile/srfi-13.h" +#include "libguile/syscalls.h" #include "libguile/validate.h" #include "libguile/socket.h" diff --git a/libguile/strports.c b/libguile/strports.c index 84ca0b24e..edd1669ed 100644 --- a/libguile/strports.c +++ b/libguile/strports.c @@ -35,6 +35,7 @@ #include "libguile/ports.h" #include "libguile/read.h" #include "libguile/strings.h" +#include "libguile/syscalls.h" #include "libguile/modules.h" #include "libguile/validate.h" #include "libguile/deprecation.h" diff --git a/libguile/syscalls.h b/libguile/syscalls.h new file mode 100644 index 000000000..13f47d49a --- /dev/null +++ b/libguile/syscalls.h @@ -0,0 +1,100 @@ +/* classes: h_files */ + +#ifndef SCM_SYSCALLS_H +#define SCM_SYSCALLS_H + +/* Copyright (C) 1995-1996,2000-2002,2006,2008-2011,2013-2014,2018 + * Free Software Foundation, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 3 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + + + +#if HAVE_CONFIG_H +# include <config.h> +#endif + + +/* ASYNC_TICK after finding EINTR in order to handle pending signals, if + any. See comment in scm_syserror. */ +#define SCM_SYSCALL(line) \ + do \ + { \ + errno = 0; \ + line; \ + if (errno == EINTR) \ + { \ + scm_async_tick (); \ + errno = EINTR; \ + } \ + } \ + while (errno == EINTR) + + + + +#if defined GUILE_USE_64_CALLS && GUILE_USE_64_CALLS && defined(HAVE_STAT64) +#define CHOOSE_LARGEFILE(foo,foo64) foo64 +#else +#define CHOOSE_LARGEFILE(foo,foo64) foo +#endif + +/* These names are a bit long, but they make it clear what they represent. */ +#if SCM_HAVE_STRUCT_DIRENT64 == 1 +# define dirent_or_dirent64 CHOOSE_LARGEFILE(dirent,dirent64) +#else +# define dirent_or_dirent64 dirent +#endif +#define fstat_or_fstat64 CHOOSE_LARGEFILE(fstat,fstat64) +#define ftruncate_or_ftruncate64 CHOOSE_LARGEFILE(ftruncate,ftruncate64) +#define lseek_or_lseek64 CHOOSE_LARGEFILE(lseek,lseek64) +#define lstat_or_lstat64 CHOOSE_LARGEFILE(lstat,lstat64) +#define off_t_or_off64_t CHOOSE_LARGEFILE(off_t,off64_t) +#define open_or_open64 CHOOSE_LARGEFILE(open,open64) +#define readdir_or_readdir64 CHOOSE_LARGEFILE(readdir,readdir64) +#if SCM_HAVE_READDIR64_R == 1 +# define readdir_r_or_readdir64_r CHOOSE_LARGEFILE(readdir_r,readdir64_r) +#else +# define readdir_r_or_readdir64_r readdir_r +#endif +#define stat_or_stat64 CHOOSE_LARGEFILE(stat,stat64) +#define truncate_or_truncate64 CHOOSE_LARGEFILE(truncate,truncate64) +#define scm_from_off_t_or_off64_t CHOOSE_LARGEFILE(scm_from_off_t,scm_from_int64) +#define scm_from_ino_t_or_ino64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64) +#define scm_from_blkcnt_t_or_blkcnt64_t CHOOSE_LARGEFILE(scm_from_ulong,scm_from_uint64) +#define scm_to_off_t_or_off64_t CHOOSE_LARGEFILE(scm_to_off_t,scm_to_int64) + +#if SIZEOF_OFF_T == 4 +# define scm_to_off_t scm_to_int32 +# define scm_from_off_t scm_from_int32 +#elif SIZEOF_OFF_T == 8 +# define scm_to_off_t scm_to_int64 +# define scm_from_off_t scm_from_int64 +#else +# error sizeof(off_t) is not 4 or 8. +#endif +#define scm_to_off64_t scm_to_int64 +#define scm_from_off64_t scm_from_int64 + + +#endif /* SCM_SYSCALLS_H */ + +/* + Local Variables: + c-file-style: "gnu" + End: +*/ |