mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
Move syscall-related private defines to their own header
* libguile/syscalls.h: New private header. * libguile/Makefile.am (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): Add syscalls.h. * libguile/_scm.h: Remove SCM_SYSCALL and all the bits relating to e.g. stat versus stat64. * libguile/filesys.c: * libguile/fports.c: * libguile/i18n.c: * libguile/ioext.c: * libguile/poll.c: * libguile/ports.c: * libguile/posix.c: * libguile/rw.c: * libguile/scmsigs.c: * libguile/script.c: * libguile/socket.c: * libguile/strports.c: Include syscalls.h.
This commit is contained in:
parent
f84ce5442e
commit
5176db70ca
15 changed files with 115 additions and 98 deletions
|
@ -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 \
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
100
libguile/syscalls.h
Normal file
100
libguile/syscalls.h
Normal file
|
@ -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:
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue