gnulib: upgrade and install the mkstemp module.
gnulib 9e117ae955a5c6a0406140e62b76c3ef50e3bc2b. * lib/fcntl.in.h, lib/gettimeofday.c, lib/lstat.c, lib/mkstemp.c, lib/pathmax.h, lib/stat.c, lib/sys_stat.in.h, lib/sys_time.in.h, lib/tempname.c, lib/tempname.h, lib/time.in.h, lib/xsize.c, m4/extern-inline.m4, m4/fcntl-o.m4, m4/fcntl_h.m4, m4/gettimeofday.m4, m4/largefile.m4, m4/lstat.m4, m4/mkstemp.m4, m4/pathmax.m4, m4/stat.m4, m4/sys_stat_h.m4, m4/sys_time_h.m4, m4/tempname.m4, m4/time_h.m4: New files. * lib/xsize.h, m4/gnulib-cache.m4, m4/gnulib-comp.m4, m4/xsize.m4, lib/Makefile.am: Upgrade.
This commit is contained in:
parent
8ecf2ab1fd
commit
f38405002a
30 changed files with 3855 additions and 10 deletions
228
lib/Makefile.am
228
lib/Makefile.am
|
|
@ -21,7 +21,7 @@
|
|||
# the same distribution terms as the rest of that program.
|
||||
#
|
||||
# Generated by gnulib-tool.
|
||||
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=tools --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error progname
|
||||
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=tools --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files --no-libtool --no-vc-files argp error mkstemp progname
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.5 gnits
|
||||
|
||||
|
|
@ -149,6 +149,41 @@ EXTRA_libgnu_a_SOURCES += error.c
|
|||
|
||||
## end gnulib module error
|
||||
|
||||
## begin gnulib module fcntl-h
|
||||
|
||||
BUILT_SOURCES += fcntl.h
|
||||
|
||||
# We need the following in order to create <fcntl.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
|
||||
-e 's/@''GNULIB_FCNTL''@/$(GNULIB_FCNTL)/g' \
|
||||
-e 's/@''GNULIB_NONBLOCKING''@/$(GNULIB_NONBLOCKING)/g' \
|
||||
-e 's/@''GNULIB_OPEN''@/$(GNULIB_OPEN)/g' \
|
||||
-e 's/@''GNULIB_OPENAT''@/$(GNULIB_OPENAT)/g' \
|
||||
-e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
|
||||
-e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
|
||||
-e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
|
||||
-e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
|
||||
-e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
|
||||
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
|
||||
< $(srcdir)/fcntl.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += fcntl.h fcntl.h-t
|
||||
|
||||
EXTRA_DIST += fcntl.in.h
|
||||
|
||||
## end gnulib module fcntl-h
|
||||
|
||||
## begin gnulib module float
|
||||
|
||||
BUILT_SOURCES += $(FLOAT_H)
|
||||
|
|
@ -213,6 +248,15 @@ libgnu_a_SOURCES += gettext.h
|
|||
|
||||
## end gnulib module gettext-h
|
||||
|
||||
## begin gnulib module gettimeofday
|
||||
|
||||
|
||||
EXTRA_DIST += gettimeofday.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += gettimeofday.c
|
||||
|
||||
## end gnulib module gettimeofday
|
||||
|
||||
## begin gnulib module intprops
|
||||
|
||||
|
||||
|
|
@ -220,6 +264,15 @@ EXTRA_DIST += intprops.h
|
|||
|
||||
## end gnulib module intprops
|
||||
|
||||
## begin gnulib module lstat
|
||||
|
||||
|
||||
EXTRA_DIST += lstat.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += lstat.c
|
||||
|
||||
## end gnulib module lstat
|
||||
|
||||
## begin gnulib module malloc-gnu
|
||||
|
||||
|
||||
|
|
@ -256,6 +309,15 @@ EXTRA_libgnu_a_SOURCES += mempcpy.c
|
|||
|
||||
## end gnulib module mempcpy
|
||||
|
||||
## begin gnulib module mkstemp
|
||||
|
||||
|
||||
EXTRA_DIST += mkstemp.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += mkstemp.c
|
||||
|
||||
## end gnulib module mkstemp
|
||||
|
||||
## begin gnulib module msvc-inval
|
||||
|
||||
|
||||
|
|
@ -274,6 +336,13 @@ EXTRA_libgnu_a_SOURCES += msvc-nothrow.c
|
|||
|
||||
## end gnulib module msvc-nothrow
|
||||
|
||||
## begin gnulib module pathmax
|
||||
|
||||
|
||||
EXTRA_DIST += pathmax.h
|
||||
|
||||
## end gnulib module pathmax
|
||||
|
||||
## begin gnulib module progname
|
||||
|
||||
libgnu_a_SOURCES += progname.h progname.c
|
||||
|
|
@ -385,6 +454,15 @@ EXTRA_DIST += $(top_srcdir)/tools/snippet/warn-on-use.h
|
|||
|
||||
## end gnulib module snippet/warn-on-use
|
||||
|
||||
## begin gnulib module stat
|
||||
|
||||
|
||||
EXTRA_DIST += stat.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += stat.c
|
||||
|
||||
## end gnulib module stat
|
||||
|
||||
## begin gnulib module stdalign
|
||||
|
||||
BUILT_SOURCES += $(STDALIGN_H)
|
||||
|
|
@ -924,6 +1002,102 @@ EXTRA_libgnu_a_SOURCES += strnlen.c
|
|||
|
||||
## end gnulib module strnlen
|
||||
|
||||
## begin gnulib module sys_stat
|
||||
|
||||
BUILT_SOURCES += sys/stat.h
|
||||
|
||||
# We need the following in order to create <sys/stat.h> when the system
|
||||
# has one that is incomplete.
|
||||
sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
||||
$(AM_V_at)$(MKDIR_P) sys
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
|
||||
-e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
|
||||
-e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
|
||||
-e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
|
||||
-e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
|
||||
-e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \
|
||||
-e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \
|
||||
-e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \
|
||||
-e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \
|
||||
-e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \
|
||||
-e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \
|
||||
-e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \
|
||||
-e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
|
||||
-e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
|
||||
-e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
|
||||
-e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
|
||||
-e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
|
||||
-e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
|
||||
-e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
|
||||
-e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
|
||||
-e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
|
||||
-e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
|
||||
-e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
|
||||
-e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
|
||||
-e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
|
||||
-e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
|
||||
-e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
|
||||
-e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
|
||||
-e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
|
||||
-e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
|
||||
-e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
|
||||
-e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
|
||||
-e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
|
||||
-e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
|
||||
-e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
|
||||
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
|
||||
< $(srcdir)/sys_stat.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
|
||||
MOSTLYCLEANDIRS += sys
|
||||
|
||||
EXTRA_DIST += sys_stat.in.h
|
||||
|
||||
## end gnulib module sys_stat
|
||||
|
||||
## begin gnulib module sys_time
|
||||
|
||||
BUILT_SOURCES += sys/time.h
|
||||
|
||||
# We need the following in order to create <sys/time.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
||||
$(AM_V_at)$(MKDIR_P) sys
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||
-e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \
|
||||
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
|
||||
-e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
|
||||
-e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
|
||||
-e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \
|
||||
-e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
|
||||
-e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
|
||||
-e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \
|
||||
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
|
||||
< $(srcdir)/sys_time.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += sys/time.h sys/time.h-t
|
||||
|
||||
EXTRA_DIST += sys_time.in.h
|
||||
|
||||
## end gnulib module sys_time
|
||||
|
||||
## begin gnulib module sys_types
|
||||
|
||||
BUILT_SOURCES += sys/types.h
|
||||
|
|
@ -978,6 +1152,56 @@ EXTRA_DIST += sysexits.in.h
|
|||
|
||||
## end gnulib module sysexits
|
||||
|
||||
## begin gnulib module tempname
|
||||
|
||||
libgnu_a_SOURCES += tempname.c
|
||||
|
||||
EXTRA_DIST += tempname.h
|
||||
|
||||
## end gnulib module tempname
|
||||
|
||||
## begin gnulib module time
|
||||
|
||||
BUILT_SOURCES += time.h
|
||||
|
||||
# We need the following in order to create <time.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
|
||||
-e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
|
||||
-e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
|
||||
-e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
|
||||
-e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
|
||||
-e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
|
||||
-e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
|
||||
-e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
|
||||
-e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
|
||||
-e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
|
||||
-e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
|
||||
-e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
|
||||
-e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
|
||||
-e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
|
||||
-e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
|
||||
-e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
|
||||
-e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
|
||||
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
|
||||
< $(srcdir)/time.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += time.h time.h-t
|
||||
|
||||
EXTRA_DIST += time.in.h
|
||||
|
||||
## end gnulib module time
|
||||
|
||||
## begin gnulib module unistd
|
||||
|
||||
BUILT_SOURCES += unistd.h
|
||||
|
|
@ -1276,7 +1500,7 @@ EXTRA_DIST += wchar.in.h
|
|||
|
||||
## begin gnulib module xsize
|
||||
|
||||
libgnu_a_SOURCES += xsize.h
|
||||
libgnu_a_SOURCES += xsize.h xsize.c
|
||||
|
||||
## end gnulib module xsize
|
||||
|
||||
|
|
|
|||
335
lib/fcntl.in.h
Normal file
335
lib/fcntl.in.h
Normal file
|
|
@ -0,0 +1,335 @@
|
|||
/* Like <fcntl.h>, but with non-working flags defined to 0.
|
||||
|
||||
Copyright (C) 2006-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Paul Eggert */
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined __need_system_fcntl_h
|
||||
/* Special invocation convention. */
|
||||
|
||||
/* Needed before <sys/stat.h>.
|
||||
May also define off_t to a 64-bit type on native Windows. */
|
||||
#include <sys/types.h>
|
||||
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
|
||||
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
|
||||
But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
|
||||
extern "C" { ... } block, which leads to errors in C++ mode with the
|
||||
overridden <sys/stat.h> from gnulib. These errors are known to be gone
|
||||
with g++ version >= 4.3. */
|
||||
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
|
||||
|
||||
#else
|
||||
/* Normal invocation convention. */
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_FCNTL_H
|
||||
|
||||
/* Needed before <sys/stat.h>.
|
||||
May also define off_t to a 64-bit type on native Windows. */
|
||||
#include <sys/types.h>
|
||||
/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
|
||||
<fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
|
||||
But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
|
||||
extern "C" { ... } block, which leads to errors in C++ mode with the
|
||||
overridden <sys/stat.h> from gnulib. These errors are known to be gone
|
||||
with g++ version >= 4.3. */
|
||||
#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_FCNTL_H
|
||||
#define _@GUARD_PREFIX@_FCNTL_H
|
||||
|
||||
#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* Native Windows platforms declare open(), creat() in <io.h>. */
|
||||
#if (@GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
|
||||
&& ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
|
||||
/* Declare overridden functions. */
|
||||
|
||||
#if @GNULIB_FCNTL@
|
||||
# if @REPLACE_FCNTL@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef fcntl
|
||||
# define fcntl rpl_fcntl
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
|
||||
_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
|
||||
# else
|
||||
# if !@HAVE_FCNTL@
|
||||
_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (fcntl);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fcntl
|
||||
# if HAVE_RAW_DECL_FCNTL
|
||||
_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
|
||||
"use gnulib module fcntl for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_OPEN@
|
||||
# if @REPLACE_OPEN@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef open
|
||||
# define open rpl_open
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
|
||||
# endif
|
||||
/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
|
||||
default argument. _GL_CXXALIASWARN does not work in this case. */
|
||||
# if !defined __hpux
|
||||
_GL_CXXALIASWARN (open);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef open
|
||||
/* Assume open is always declared. */
|
||||
_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
|
||||
"use gnulib module open for portability");
|
||||
#endif
|
||||
|
||||
#if @GNULIB_OPENAT@
|
||||
# if @REPLACE_OPENAT@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef openat
|
||||
# define openat rpl_openat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...));
|
||||
# else
|
||||
# if !@HAVE_OPENAT@
|
||||
_GL_FUNCDECL_SYS (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (openat);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef openat
|
||||
# if HAVE_RAW_DECL_OPENAT
|
||||
_GL_WARN_ON_USE (openat, "openat is not portable - "
|
||||
"use gnulib module openat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Fix up the FD_* macros, only known to be missing on mingw. */
|
||||
|
||||
#ifndef FD_CLOEXEC
|
||||
# define FD_CLOEXEC 1
|
||||
#endif
|
||||
|
||||
/* Fix up the supported F_* macros. Intentionally leave other F_*
|
||||
macros undefined. Only known to be missing on mingw. */
|
||||
|
||||
#ifndef F_DUPFD_CLOEXEC
|
||||
# define F_DUPFD_CLOEXEC 0x40000000
|
||||
/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
|
||||
# define GNULIB_defined_F_DUPFD_CLOEXEC 1
|
||||
#else
|
||||
# define GNULIB_defined_F_DUPFD_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
#ifndef F_DUPFD
|
||||
# define F_DUPFD 1
|
||||
#endif
|
||||
|
||||
#ifndef F_GETFD
|
||||
# define F_GETFD 2
|
||||
#endif
|
||||
|
||||
/* Fix up the O_* macros. */
|
||||
|
||||
#if !defined O_DIRECT && defined O_DIRECTIO
|
||||
/* Tru64 spells it 'O_DIRECTIO'. */
|
||||
# define O_DIRECT O_DIRECTIO
|
||||
#endif
|
||||
|
||||
#if !defined O_CLOEXEC && defined O_NOINHERIT
|
||||
/* Mingw spells it 'O_NOINHERIT'. */
|
||||
# define O_CLOEXEC O_NOINHERIT
|
||||
#endif
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
# define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
#ifndef O_DIRECT
|
||||
# define O_DIRECT 0
|
||||
#endif
|
||||
|
||||
#ifndef O_DIRECTORY
|
||||
# define O_DIRECTORY 0
|
||||
#endif
|
||||
|
||||
#ifndef O_DSYNC
|
||||
# define O_DSYNC 0
|
||||
#endif
|
||||
|
||||
#ifndef O_EXEC
|
||||
# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
|
||||
#endif
|
||||
|
||||
#ifndef O_NDELAY
|
||||
# define O_NDELAY 0
|
||||
#endif
|
||||
|
||||
#ifndef O_NOATIME
|
||||
# define O_NOATIME 0
|
||||
#endif
|
||||
|
||||
#ifndef O_NONBLOCK
|
||||
# define O_NONBLOCK O_NDELAY
|
||||
#endif
|
||||
|
||||
/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
|
||||
value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
|
||||
or to 0 as fallback. */
|
||||
#if @GNULIB_NONBLOCKING@
|
||||
# if O_NONBLOCK
|
||||
# define GNULIB_defined_O_NONBLOCK 0
|
||||
# else
|
||||
# define GNULIB_defined_O_NONBLOCK 1
|
||||
# undef O_NONBLOCK
|
||||
# define O_NONBLOCK 0x40000000
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef O_NOCTTY
|
||||
# define O_NOCTTY 0
|
||||
#endif
|
||||
|
||||
#ifndef O_NOFOLLOW
|
||||
# define O_NOFOLLOW 0
|
||||
#endif
|
||||
|
||||
#ifndef O_NOLINKS
|
||||
# define O_NOLINKS 0
|
||||
#endif
|
||||
|
||||
#ifndef O_RSYNC
|
||||
# define O_RSYNC 0
|
||||
#endif
|
||||
|
||||
#ifndef O_SEARCH
|
||||
# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
|
||||
#endif
|
||||
|
||||
#ifndef O_SYNC
|
||||
# define O_SYNC 0
|
||||
#endif
|
||||
|
||||
#ifndef O_TTY_INIT
|
||||
# define O_TTY_INIT 0
|
||||
#endif
|
||||
|
||||
#if O_ACCMODE != (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
|
||||
# undef O_ACCMODE
|
||||
# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
|
||||
#endif
|
||||
|
||||
/* For systems that distinguish between text and binary I/O.
|
||||
O_BINARY is usually declared in fcntl.h */
|
||||
#if !defined O_BINARY && defined _O_BINARY
|
||||
/* For MSC-compatible compilers. */
|
||||
# define O_BINARY _O_BINARY
|
||||
# define O_TEXT _O_TEXT
|
||||
#endif
|
||||
|
||||
#if defined __BEOS__ || defined __HAIKU__
|
||||
/* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
|
||||
# undef O_BINARY
|
||||
# undef O_TEXT
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
# define O_TEXT 0
|
||||
#endif
|
||||
|
||||
/* Fix up the AT_* macros. */
|
||||
|
||||
/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
|
||||
value exceeds INT_MAX, so its use as an int doesn't conform to the
|
||||
C standard, and GCC and Sun C complain in some cases. If the bug
|
||||
is present, undef AT_FDCWD here, so it can be redefined below. */
|
||||
#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
|
||||
# undef AT_FDCWD
|
||||
#endif
|
||||
|
||||
/* Use the same bit pattern as Solaris 9, but with the proper
|
||||
signedness. The bit pattern is important, in case this actually is
|
||||
Solaris with the above workaround. */
|
||||
#ifndef AT_FDCWD
|
||||
# define AT_FDCWD (-3041965)
|
||||
#endif
|
||||
|
||||
/* Use the same values as Solaris 9. This shouldn't matter, but
|
||||
there's no real reason to differ. */
|
||||
#ifndef AT_SYMLINK_NOFOLLOW
|
||||
# define AT_SYMLINK_NOFOLLOW 4096
|
||||
#endif
|
||||
|
||||
#ifndef AT_REMOVEDIR
|
||||
# define AT_REMOVEDIR 1
|
||||
#endif
|
||||
|
||||
/* Solaris 9 lacks these two, so just pick unique values. */
|
||||
#ifndef AT_SYMLINK_FOLLOW
|
||||
# define AT_SYMLINK_FOLLOW 2
|
||||
#endif
|
||||
|
||||
#ifndef AT_EACCESS
|
||||
# define AT_EACCESS 4
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _@GUARD_PREFIX@_FCNTL_H */
|
||||
#endif /* _@GUARD_PREFIX@_FCNTL_H */
|
||||
#endif
|
||||
154
lib/gettimeofday.c
Normal file
154
lib/gettimeofday.c
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/* Provide gettimeofday for systems that don't have it or for which it's broken.
|
||||
|
||||
Copyright (C) 2001-2003, 2005-2007, 2009-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if HAVE_SYS_TIMEB_H
|
||||
# include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
|
||||
|
||||
/* Work around the bug in some systems whereby gettimeofday clobbers
|
||||
the static buffer that localtime uses for its return value. The
|
||||
gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has
|
||||
this problem. The tzset replacement is necessary for at least
|
||||
Solaris 2.5, 2.5.1, and 2.6. */
|
||||
|
||||
static struct tm tm_zero_buffer;
|
||||
static struct tm *localtime_buffer_addr = &tm_zero_buffer;
|
||||
|
||||
# undef localtime
|
||||
extern struct tm *localtime (time_t const *);
|
||||
|
||||
# undef gmtime
|
||||
extern struct tm *gmtime (time_t const *);
|
||||
|
||||
/* This is a wrapper for localtime. It is used only on systems for which
|
||||
gettimeofday clobbers the static buffer used for localtime's result.
|
||||
|
||||
On the first call, record the address of the static buffer that
|
||||
localtime uses for its result. */
|
||||
|
||||
struct tm *
|
||||
rpl_localtime (time_t const *timep)
|
||||
{
|
||||
struct tm *tm = localtime (timep);
|
||||
|
||||
if (localtime_buffer_addr == &tm_zero_buffer)
|
||||
localtime_buffer_addr = tm;
|
||||
|
||||
return tm;
|
||||
}
|
||||
|
||||
/* Same as above, since gmtime and localtime use the same buffer. */
|
||||
struct tm *
|
||||
rpl_gmtime (time_t const *timep)
|
||||
{
|
||||
struct tm *tm = gmtime (timep);
|
||||
|
||||
if (localtime_buffer_addr == &tm_zero_buffer)
|
||||
localtime_buffer_addr = tm;
|
||||
|
||||
return tm;
|
||||
}
|
||||
|
||||
#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */
|
||||
|
||||
#if TZSET_CLOBBERS_LOCALTIME
|
||||
|
||||
# undef tzset
|
||||
extern void tzset (void);
|
||||
|
||||
/* This is a wrapper for tzset, for systems on which tzset may clobber
|
||||
the static buffer used for localtime's result. */
|
||||
void
|
||||
rpl_tzset (void)
|
||||
{
|
||||
/* Save and restore the contents of the buffer used for localtime's
|
||||
result around the call to tzset. */
|
||||
struct tm save = *localtime_buffer_addr;
|
||||
tzset ();
|
||||
*localtime_buffer_addr = save;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This is a wrapper for gettimeofday. It is used only on systems
|
||||
that lack this function, or whose implementation of this function
|
||||
causes problems. */
|
||||
|
||||
int
|
||||
gettimeofday (struct timeval *restrict tv, void *restrict tz)
|
||||
{
|
||||
#undef gettimeofday
|
||||
#if HAVE_GETTIMEOFDAY
|
||||
# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
|
||||
/* Save and restore the contents of the buffer used for localtime's
|
||||
result around the call to gettimeofday. */
|
||||
struct tm save = *localtime_buffer_addr;
|
||||
# endif
|
||||
|
||||
# if defined timeval /* 'struct timeval' overridden by gnulib? */
|
||||
# undef timeval
|
||||
struct timeval otv;
|
||||
int result = gettimeofday (&otv, (struct timezone *) tz);
|
||||
if (result == 0)
|
||||
{
|
||||
tv->tv_sec = otv.tv_sec;
|
||||
tv->tv_usec = otv.tv_usec;
|
||||
}
|
||||
# else
|
||||
int result = gettimeofday (tv, (struct timezone *) tz);
|
||||
# endif
|
||||
|
||||
# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
|
||||
*localtime_buffer_addr = save;
|
||||
# endif
|
||||
|
||||
return result;
|
||||
|
||||
#else
|
||||
|
||||
# if HAVE__FTIME
|
||||
|
||||
struct _timeb timebuf;
|
||||
_ftime (&timebuf);
|
||||
tv->tv_sec = timebuf.time;
|
||||
tv->tv_usec = timebuf.millitm * 1000;
|
||||
|
||||
# else
|
||||
|
||||
# if !defined OK_TO_USE_1S_CLOCK
|
||||
# error "Only 1-second nominal clock resolution found. Is that intended?" \
|
||||
"If so, compile with the -DOK_TO_USE_1S_CLOCK option."
|
||||
# endif
|
||||
tv->tv_sec = time (NULL);
|
||||
tv->tv_usec = 0;
|
||||
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
}
|
||||
97
lib/lstat.c
Normal file
97
lib/lstat.c
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/* Work around a bug of lstat on some systems
|
||||
|
||||
Copyright (C) 1997-2006, 2008-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering */
|
||||
|
||||
/* If the user's config.h happens to include <sys/stat.h>, let it include only
|
||||
the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to
|
||||
rpl_lstat. */
|
||||
#define __need_system_sys_stat_h
|
||||
#include <config.h>
|
||||
|
||||
#if !HAVE_LSTAT
|
||||
/* On systems that lack symlinks, our replacement <sys/stat.h> already
|
||||
defined lstat as stat, so there is nothing further to do other than
|
||||
avoid an empty file. */
|
||||
typedef int dummy;
|
||||
#else /* HAVE_LSTAT */
|
||||
|
||||
/* Get the original definition of lstat. It might be defined as a macro. */
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# undef __need_system_sys_stat_h
|
||||
|
||||
static inline int
|
||||
orig_lstat (const char *filename, struct stat *buf)
|
||||
{
|
||||
return lstat (filename, buf);
|
||||
}
|
||||
|
||||
/* Specification. */
|
||||
/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
|
||||
eliminates this include because of the preliminary #include <sys/stat.h>
|
||||
above. */
|
||||
# include "sys/stat.h"
|
||||
|
||||
# include <string.h>
|
||||
# include <errno.h>
|
||||
|
||||
/* lstat works differently on Linux and Solaris systems. POSIX (see
|
||||
"pathname resolution" in the glossary) requires that programs like
|
||||
'ls' take into consideration the fact that FILE has a trailing slash
|
||||
when FILE is a symbolic link. On Linux and Solaris 10 systems, the
|
||||
lstat function already has the desired semantics (in treating
|
||||
'lstat ("symlink/", sbuf)' just like 'lstat ("symlink/.", sbuf)',
|
||||
but on Solaris 9 and earlier it does not.
|
||||
|
||||
If FILE has a trailing slash and specifies a symbolic link,
|
||||
then use stat() to get more info on the referent of FILE.
|
||||
If the referent is a non-directory, then set errno to ENOTDIR
|
||||
and return -1. Otherwise, return stat's result. */
|
||||
|
||||
int
|
||||
rpl_lstat (const char *file, struct stat *sbuf)
|
||||
{
|
||||
size_t len;
|
||||
int lstat_result = orig_lstat (file, sbuf);
|
||||
|
||||
if (lstat_result != 0)
|
||||
return lstat_result;
|
||||
|
||||
/* This replacement file can blindly check against '/' rather than
|
||||
using the ISSLASH macro, because all platforms with '\\' either
|
||||
lack symlinks (mingw) or have working lstat (cygwin) and thus do
|
||||
not compile this file. 0 len should have already been filtered
|
||||
out above, with a failure return of ENOENT. */
|
||||
len = strlen (file);
|
||||
if (file[len - 1] != '/' || S_ISDIR (sbuf->st_mode))
|
||||
return 0;
|
||||
|
||||
/* At this point, a trailing slash is only permitted on
|
||||
symlink-to-dir; but it should have found information on the
|
||||
directory, not the symlink. Call stat() to get info about the
|
||||
link's referent. Our replacement stat guarantees valid results,
|
||||
even if the symlink is not pointing to a directory. */
|
||||
if (!S_ISLNK (sbuf->st_mode))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
return stat (file, sbuf);
|
||||
}
|
||||
|
||||
#endif /* HAVE_LSTAT */
|
||||
50
lib/mkstemp.c
Normal file
50
lib/mkstemp.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2012 Free Software
|
||||
Foundation, Inc.
|
||||
This file is derived from the one in the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#if !_LIBC
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !_LIBC
|
||||
# include "tempname.h"
|
||||
# define __gen_tempname gen_tempname
|
||||
# ifndef __GT_FILE
|
||||
# define __GT_FILE GT_FILE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef __GT_FILE
|
||||
# define __GT_FILE 0
|
||||
#endif
|
||||
|
||||
/* Generate a unique temporary file name from XTEMPLATE.
|
||||
The last six characters of XTEMPLATE must be "XXXXXX";
|
||||
they are replaced with a string that makes the file name unique.
|
||||
Then open the file and return a fd.
|
||||
|
||||
If you are creating temporary files which will later be removed,
|
||||
consider using the clean-temp module, which avoids several pitfalls
|
||||
of using mkstemp directly. */
|
||||
int
|
||||
mkstemp (char *xtemplate)
|
||||
{
|
||||
return __gen_tempname (xtemplate, 0, 0, __GT_FILE);
|
||||
}
|
||||
83
lib/pathmax.h
Normal file
83
lib/pathmax.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/* Define PATH_MAX somehow. Requires sys/types.h.
|
||||
Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2012 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _PATHMAX_H
|
||||
# define _PATHMAX_H
|
||||
|
||||
/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
|
||||
including the terminating NUL byte.
|
||||
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
|
||||
PATH_MAX is not defined on systems which have no limit on filename length,
|
||||
such as GNU/Hurd.
|
||||
|
||||
This file does *not* define PATH_MAX always. Programs that use this file
|
||||
can handle the GNU/Hurd case in several ways:
|
||||
- Either with a package-wide handling, or with a per-file handling,
|
||||
- Either through a
|
||||
#ifdef PATH_MAX
|
||||
or through a fallback like
|
||||
#ifndef PATH_MAX
|
||||
# define PATH_MAX 8192
|
||||
#endif
|
||||
or through a fallback like
|
||||
#ifndef PATH_MAX
|
||||
# define PATH_MAX pathconf ("/", _PC_PATH_MAX)
|
||||
#endif
|
||||
*/
|
||||
|
||||
# include <unistd.h>
|
||||
|
||||
# include <limits.h>
|
||||
|
||||
# ifndef _POSIX_PATH_MAX
|
||||
# define _POSIX_PATH_MAX 256
|
||||
# endif
|
||||
|
||||
/* Don't include sys/param.h if it already has been. */
|
||||
# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
|
||||
# include <sys/param.h>
|
||||
# endif
|
||||
|
||||
# if !defined PATH_MAX && defined MAXPATHLEN
|
||||
# define PATH_MAX MAXPATHLEN
|
||||
# endif
|
||||
|
||||
# ifdef __hpux
|
||||
/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
|
||||
*not* including the terminating NUL byte, and is set to 1023.
|
||||
Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
|
||||
not defined at all any more. */
|
||||
# undef PATH_MAX
|
||||
# define PATH_MAX 1024
|
||||
# endif
|
||||
|
||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
|
||||
section "Maximum Path Length Limitation",
|
||||
<http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
|
||||
explains that the maximum size of a filename, including the terminating
|
||||
NUL byte, is 260 = 3 + 256 + 1.
|
||||
This is the same value as
|
||||
- FILENAME_MAX in <stdio.h>,
|
||||
- _MAX_PATH in <stdlib.h>,
|
||||
- MAX_PATH in <windef.h>.
|
||||
Undefine the original value, because mingw's <limits.h> gets it wrong. */
|
||||
# undef PATH_MAX
|
||||
# define PATH_MAX 260
|
||||
# endif
|
||||
|
||||
#endif /* _PATHMAX_H */
|
||||
138
lib/stat.c
Normal file
138
lib/stat.c
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* Work around platform bugs in stat.
|
||||
Copyright (C) 2009-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Eric Blake */
|
||||
|
||||
/* If the user's config.h happens to include <sys/stat.h>, let it include only
|
||||
the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
|
||||
rpl_stat. */
|
||||
#define __need_system_sys_stat_h
|
||||
#include <config.h>
|
||||
|
||||
/* Get the original definition of stat. It might be defined as a macro. */
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#undef __need_system_sys_stat_h
|
||||
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
# if _GL_WINDOWS_64_BIT_ST_SIZE
|
||||
# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */
|
||||
# define stat _stati64
|
||||
# define REPLACE_FUNC_STAT_DIR 1
|
||||
# undef REPLACE_FUNC_STAT_FILE
|
||||
# elif REPLACE_FUNC_STAT_FILE
|
||||
/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a.
|
||||
Bypass it. */
|
||||
# define stat _stat
|
||||
# define REPLACE_FUNC_STAT_DIR 1
|
||||
# undef REPLACE_FUNC_STAT_FILE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static inline int
|
||||
orig_stat (const char *filename, struct stat *buf)
|
||||
{
|
||||
return stat (filename, buf);
|
||||
}
|
||||
|
||||
/* Specification. */
|
||||
/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
|
||||
eliminates this include because of the preliminary #include <sys/stat.h>
|
||||
above. */
|
||||
#include "sys/stat.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "dosname.h"
|
||||
#include "verify.h"
|
||||
|
||||
#if REPLACE_FUNC_STAT_DIR
|
||||
# include "pathmax.h"
|
||||
/* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
|
||||
have a constant PATH_MAX. */
|
||||
# ifndef PATH_MAX
|
||||
# error "Please port this replacement to your platform"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Store information about NAME into ST. Work around bugs with
|
||||
trailing slashes. Mingw has other bugs (such as st_ino always
|
||||
being 0 on success) which this wrapper does not work around. But
|
||||
at least this implementation provides the ability to emulate fchdir
|
||||
correctly. */
|
||||
|
||||
int
|
||||
rpl_stat (char const *name, struct stat *st)
|
||||
{
|
||||
int result = orig_stat (name, st);
|
||||
#if REPLACE_FUNC_STAT_FILE
|
||||
/* Solaris 9 mistakenly succeeds when given a non-directory with a
|
||||
trailing slash. */
|
||||
if (result == 0 && !S_ISDIR (st->st_mode))
|
||||
{
|
||||
size_t len = strlen (name);
|
||||
if (ISSLASH (name[len - 1]))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif /* REPLACE_FUNC_STAT_FILE */
|
||||
#if REPLACE_FUNC_STAT_DIR
|
||||
|
||||
if (result == -1 && errno == ENOENT)
|
||||
{
|
||||
/* Due to mingw's oddities, there are some directories (like
|
||||
c:\) where stat() only succeeds with a trailing slash, and
|
||||
other directories (like c:\windows) where stat() only
|
||||
succeeds without a trailing slash. But we want the two to be
|
||||
synonymous, since chdir() manages either style. Likewise, Mingw also
|
||||
reports ENOENT for names longer than PATH_MAX, when we want
|
||||
ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR.
|
||||
Fortunately, mingw PATH_MAX is small enough for stack
|
||||
allocation. */
|
||||
char fixed_name[PATH_MAX + 1] = {0};
|
||||
size_t len = strlen (name);
|
||||
bool check_dir = false;
|
||||
verify (PATH_MAX <= 4096);
|
||||
if (PATH_MAX <= len)
|
||||
errno = ENAMETOOLONG;
|
||||
else if (len)
|
||||
{
|
||||
strcpy (fixed_name, name);
|
||||
if (ISSLASH (fixed_name[len - 1]))
|
||||
{
|
||||
check_dir = true;
|
||||
while (len && ISSLASH (fixed_name[len - 1]))
|
||||
fixed_name[--len] = '\0';
|
||||
if (!len)
|
||||
fixed_name[0] = '/';
|
||||
}
|
||||
else
|
||||
fixed_name[len++] = '/';
|
||||
result = orig_stat (fixed_name, st);
|
||||
if (result == 0 && check_dir && !S_ISDIR (st->st_mode))
|
||||
{
|
||||
result = -1;
|
||||
errno = ENOTDIR;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* REPLACE_FUNC_STAT_DIR */
|
||||
return result;
|
||||
}
|
||||
728
lib/sys_stat.in.h
Normal file
728
lib/sys_stat.in.h
Normal file
|
|
@ -0,0 +1,728 @@
|
|||
/* Provide a more complete sys/stat header file.
|
||||
Copyright (C) 2005-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
|
||||
|
||||
/* This file is supposed to be used on platforms where <sys/stat.h> is
|
||||
incomplete. It is intended to provide definitions and prototypes
|
||||
needed by an application. Start with what the system provides. */
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined __need_system_sys_stat_h
|
||||
/* Special invocation convention. */
|
||||
|
||||
#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
|
||||
|
||||
#else
|
||||
/* Normal invocation convention. */
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_SYS_STAT_H
|
||||
|
||||
/* Get nlink_t.
|
||||
May also define off_t to a 64-bit type on native Windows. */
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Get struct timespec. */
|
||||
#include <time.h>
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
|
||||
|
||||
#ifndef _@GUARD_PREFIX@_SYS_STAT_H
|
||||
#define _@GUARD_PREFIX@_SYS_STAT_H
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
|
||||
headers that may declare mkdir(). Native Windows platforms declare mkdir
|
||||
in <io.h> and/or <direct.h>, not in <unistd.h>. */
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
# include <io.h> /* mingw32, mingw64 */
|
||||
# include <direct.h> /* mingw64, MSVC 9 */
|
||||
#endif
|
||||
|
||||
/* Native Windows platforms declare umask() in <io.h>. */
|
||||
#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
/* Large File Support on native Windows. */
|
||||
#if @WINDOWS_64_BIT_ST_SIZE@
|
||||
# define stat _stati64
|
||||
#endif
|
||||
|
||||
#ifndef S_IFIFO
|
||||
# ifdef _S_IFIFO
|
||||
# define S_IFIFO _S_IFIFO
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_IFMT
|
||||
# define S_IFMT 0170000
|
||||
#endif
|
||||
|
||||
#if STAT_MACROS_BROKEN
|
||||
# undef S_ISBLK
|
||||
# undef S_ISCHR
|
||||
# undef S_ISDIR
|
||||
# undef S_ISFIFO
|
||||
# undef S_ISLNK
|
||||
# undef S_ISNAM
|
||||
# undef S_ISMPB
|
||||
# undef S_ISMPC
|
||||
# undef S_ISNWK
|
||||
# undef S_ISREG
|
||||
# undef S_ISSOCK
|
||||
#endif
|
||||
|
||||
#ifndef S_ISBLK
|
||||
# ifdef S_IFBLK
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
# else
|
||||
# define S_ISBLK(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISCHR
|
||||
# ifdef S_IFCHR
|
||||
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
# else
|
||||
# define S_ISCHR(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISDIR
|
||||
# ifdef S_IFDIR
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# else
|
||||
# define S_ISDIR(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISDOOR /* Solaris 2.5 and up */
|
||||
# define S_ISDOOR(m) 0
|
||||
#endif
|
||||
|
||||
#ifndef S_ISFIFO
|
||||
# ifdef S_IFIFO
|
||||
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
# else
|
||||
# define S_ISFIFO(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISLNK
|
||||
# ifdef S_IFLNK
|
||||
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
# else
|
||||
# define S_ISLNK(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISMPB /* V7 */
|
||||
# ifdef S_IFMPB
|
||||
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
|
||||
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
|
||||
# else
|
||||
# define S_ISMPB(m) 0
|
||||
# define S_ISMPC(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISNAM /* Xenix */
|
||||
# ifdef S_IFNAM
|
||||
# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
|
||||
# else
|
||||
# define S_ISNAM(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISNWK /* HP/UX */
|
||||
# ifdef S_IFNWK
|
||||
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
|
||||
# else
|
||||
# define S_ISNWK(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISPORT /* Solaris 10 and up */
|
||||
# define S_ISPORT(m) 0
|
||||
#endif
|
||||
|
||||
#ifndef S_ISREG
|
||||
# ifdef S_IFREG
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
# else
|
||||
# define S_ISREG(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISSOCK
|
||||
# ifdef S_IFSOCK
|
||||
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
# else
|
||||
# define S_ISSOCK(m) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef S_TYPEISMQ
|
||||
# define S_TYPEISMQ(p) 0
|
||||
#endif
|
||||
|
||||
#ifndef S_TYPEISTMO
|
||||
# define S_TYPEISTMO(p) 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef S_TYPEISSEM
|
||||
# ifdef S_INSEM
|
||||
# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
|
||||
# else
|
||||
# define S_TYPEISSEM(p) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef S_TYPEISSHM
|
||||
# ifdef S_INSHD
|
||||
# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
|
||||
# else
|
||||
# define S_TYPEISSHM(p) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* high performance ("contiguous data") */
|
||||
#ifndef S_ISCTG
|
||||
# define S_ISCTG(p) 0
|
||||
#endif
|
||||
|
||||
/* Cray DMF (data migration facility): off line, with data */
|
||||
#ifndef S_ISOFD
|
||||
# define S_ISOFD(p) 0
|
||||
#endif
|
||||
|
||||
/* Cray DMF (data migration facility): off line, with no data */
|
||||
#ifndef S_ISOFL
|
||||
# define S_ISOFL(p) 0
|
||||
#endif
|
||||
|
||||
/* 4.4BSD whiteout */
|
||||
#ifndef S_ISWHT
|
||||
# define S_ISWHT(m) 0
|
||||
#endif
|
||||
|
||||
/* If any of the following are undefined,
|
||||
define them to their de facto standard values. */
|
||||
#if !S_ISUID
|
||||
# define S_ISUID 04000
|
||||
#endif
|
||||
#if !S_ISGID
|
||||
# define S_ISGID 02000
|
||||
#endif
|
||||
|
||||
/* S_ISVTX is a common extension to POSIX. */
|
||||
#ifndef S_ISVTX
|
||||
# define S_ISVTX 01000
|
||||
#endif
|
||||
|
||||
#if !S_IRUSR && S_IREAD
|
||||
# define S_IRUSR S_IREAD
|
||||
#endif
|
||||
#if !S_IRUSR
|
||||
# define S_IRUSR 00400
|
||||
#endif
|
||||
#if !S_IRGRP
|
||||
# define S_IRGRP (S_IRUSR >> 3)
|
||||
#endif
|
||||
#if !S_IROTH
|
||||
# define S_IROTH (S_IRUSR >> 6)
|
||||
#endif
|
||||
|
||||
#if !S_IWUSR && S_IWRITE
|
||||
# define S_IWUSR S_IWRITE
|
||||
#endif
|
||||
#if !S_IWUSR
|
||||
# define S_IWUSR 00200
|
||||
#endif
|
||||
#if !S_IWGRP
|
||||
# define S_IWGRP (S_IWUSR >> 3)
|
||||
#endif
|
||||
#if !S_IWOTH
|
||||
# define S_IWOTH (S_IWUSR >> 6)
|
||||
#endif
|
||||
|
||||
#if !S_IXUSR && S_IEXEC
|
||||
# define S_IXUSR S_IEXEC
|
||||
#endif
|
||||
#if !S_IXUSR
|
||||
# define S_IXUSR 00100
|
||||
#endif
|
||||
#if !S_IXGRP
|
||||
# define S_IXGRP (S_IXUSR >> 3)
|
||||
#endif
|
||||
#if !S_IXOTH
|
||||
# define S_IXOTH (S_IXUSR >> 6)
|
||||
#endif
|
||||
|
||||
#if !S_IRWXU
|
||||
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
|
||||
#endif
|
||||
#if !S_IRWXG
|
||||
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
||||
#endif
|
||||
#if !S_IRWXO
|
||||
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
||||
#endif
|
||||
|
||||
/* S_IXUGO is a common extension to POSIX. */
|
||||
#if !S_IXUGO
|
||||
# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
|
||||
#endif
|
||||
|
||||
#ifndef S_IRWXUGO
|
||||
# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
|
||||
#endif
|
||||
|
||||
/* Macros for futimens and utimensat. */
|
||||
#ifndef UTIME_NOW
|
||||
# define UTIME_NOW (-1)
|
||||
# define UTIME_OMIT (-2)
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_FCHMODAT@
|
||||
# if !@HAVE_FCHMODAT@
|
||||
_GL_FUNCDECL_SYS (fchmodat, int,
|
||||
(int fd, char const *file, mode_t mode, int flag)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (fchmodat, int,
|
||||
(int fd, char const *file, mode_t mode, int flag));
|
||||
_GL_CXXALIASWARN (fchmodat);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fchmodat
|
||||
# if HAVE_RAW_DECL_FCHMODAT
|
||||
_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
|
||||
"use gnulib module openat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_FSTAT@
|
||||
# if @REPLACE_FSTAT@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef fstat
|
||||
# define fstat rpl_fstat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (fstat);
|
||||
#elif @WINDOWS_64_BIT_ST_SIZE@
|
||||
/* Above, we define stat to _stati64. */
|
||||
# define fstat _fstati64
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fstat
|
||||
# if HAVE_RAW_DECL_FSTAT
|
||||
_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
|
||||
"use gnulib module fstat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_FSTATAT@
|
||||
# if @REPLACE_FSTATAT@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef fstatat
|
||||
# define fstatat rpl_fstatat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (fstatat, int,
|
||||
(int fd, char const *name, struct stat *st, int flags)
|
||||
_GL_ARG_NONNULL ((2, 3)));
|
||||
_GL_CXXALIAS_RPL (fstatat, int,
|
||||
(int fd, char const *name, struct stat *st, int flags));
|
||||
# else
|
||||
# if !@HAVE_FSTATAT@
|
||||
_GL_FUNCDECL_SYS (fstatat, int,
|
||||
(int fd, char const *name, struct stat *st, int flags)
|
||||
_GL_ARG_NONNULL ((2, 3)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (fstatat, int,
|
||||
(int fd, char const *name, struct stat *st, int flags));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (fstatat);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fstatat
|
||||
# if HAVE_RAW_DECL_FSTATAT
|
||||
_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
|
||||
"use gnulib module openat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_FUTIMENS@
|
||||
/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
|
||||
implementation relies on futimesat, which on Solaris 10 makes an invocation
|
||||
to futimens that is meant to invoke the libc's futimens(), not gnulib's
|
||||
futimens(). */
|
||||
# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef futimens
|
||||
# define futimens rpl_futimens
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
|
||||
_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
|
||||
# else
|
||||
# if !@HAVE_FUTIMENS@
|
||||
_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
|
||||
# endif
|
||||
# if @HAVE_FUTIMENS@
|
||||
_GL_CXXALIASWARN (futimens);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef futimens
|
||||
# if HAVE_RAW_DECL_FUTIMENS
|
||||
_GL_WARN_ON_USE (futimens, "futimens is not portable - "
|
||||
"use gnulib module futimens for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_LCHMOD@
|
||||
/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
|
||||
denotes a symbolic link. */
|
||||
# if !@HAVE_LCHMOD@
|
||||
/* The lchmod replacement follows symbolic links. Callers should take
|
||||
this into account; lchmod should be applied only to arguments that
|
||||
are known to not be symbolic links. On hosts that lack lchmod,
|
||||
this can lead to race conditions between the check and the
|
||||
invocation of lchmod, but we know of no workarounds that are
|
||||
reliable in general. You might try requesting support for lchmod
|
||||
from your operating system supplier. */
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define lchmod chmod
|
||||
# endif
|
||||
/* Need to cast, because on mingw, the second parameter of chmod is
|
||||
int mode. */
|
||||
_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
|
||||
(const char *filename, mode_t mode));
|
||||
# else
|
||||
# if 0 /* assume already declared */
|
||||
_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
|
||||
# endif
|
||||
# if @HAVE_LCHMOD@
|
||||
_GL_CXXALIASWARN (lchmod);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef lchmod
|
||||
# if HAVE_RAW_DECL_LCHMOD
|
||||
_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
|
||||
"use gnulib module lchmod for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_LSTAT@
|
||||
# if ! @HAVE_LSTAT@
|
||||
/* mingw does not support symlinks, therefore it does not have lstat. But
|
||||
without links, stat does just fine. */
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define lstat stat
|
||||
# endif
|
||||
_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
|
||||
# elif @REPLACE_LSTAT@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef lstat
|
||||
# define lstat rpl_lstat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
|
||||
_GL_ARG_NONNULL ((1, 2)));
|
||||
_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
|
||||
# endif
|
||||
# if @HAVE_LSTAT@
|
||||
_GL_CXXALIASWARN (lstat);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef lstat
|
||||
# if HAVE_RAW_DECL_LSTAT
|
||||
_GL_WARN_ON_USE (lstat, "lstat is unportable - "
|
||||
"use gnulib module lstat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @REPLACE_MKDIR@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef mkdir
|
||||
# define mkdir rpl_mkdir
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
|
||||
#else
|
||||
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
|
||||
Additionally, it declares _mkdir (and depending on compile flags, an
|
||||
alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
|
||||
which are included above. */
|
||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
|
||||
# if !GNULIB_defined_rpl_mkdir
|
||||
static inline int
|
||||
rpl_mkdir (char const *name, mode_t mode)
|
||||
{
|
||||
return _mkdir (name);
|
||||
}
|
||||
# define GNULIB_defined_rpl_mkdir 1
|
||||
# endif
|
||||
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define mkdir rpl_mkdir
|
||||
# endif
|
||||
_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
|
||||
# endif
|
||||
#endif
|
||||
_GL_CXXALIASWARN (mkdir);
|
||||
|
||||
|
||||
#if @GNULIB_MKDIRAT@
|
||||
# if !@HAVE_MKDIRAT@
|
||||
_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
|
||||
_GL_CXXALIASWARN (mkdirat);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkdirat
|
||||
# if HAVE_RAW_DECL_MKDIRAT
|
||||
_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
|
||||
"use gnulib module openat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_MKFIFO@
|
||||
# if @REPLACE_MKFIFO@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef mkfifo
|
||||
# define mkfifo rpl_mkfifo
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
|
||||
# else
|
||||
# if !@HAVE_MKFIFO@
|
||||
_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (mkfifo);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkfifo
|
||||
# if HAVE_RAW_DECL_MKFIFO
|
||||
_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
|
||||
"use gnulib module mkfifo for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_MKFIFOAT@
|
||||
# if !@HAVE_MKFIFOAT@
|
||||
_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
|
||||
_GL_CXXALIASWARN (mkfifoat);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkfifoat
|
||||
# if HAVE_RAW_DECL_MKFIFOAT
|
||||
_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
|
||||
"use gnulib module mkfifoat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_MKNOD@
|
||||
# if @REPLACE_MKNOD@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef mknod
|
||||
# define mknod rpl_mknod
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
|
||||
# else
|
||||
# if !@HAVE_MKNOD@
|
||||
_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
# endif
|
||||
/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
|
||||
_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (mknod);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mknod
|
||||
# if HAVE_RAW_DECL_MKNOD
|
||||
_GL_WARN_ON_USE (mknod, "mknod is not portable - "
|
||||
"use gnulib module mknod for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_MKNODAT@
|
||||
# if !@HAVE_MKNODAT@
|
||||
_GL_FUNCDECL_SYS (mknodat, int,
|
||||
(int fd, char const *file, mode_t mode, dev_t dev)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (mknodat, int,
|
||||
(int fd, char const *file, mode_t mode, dev_t dev));
|
||||
_GL_CXXALIASWARN (mknodat);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mknodat
|
||||
# if HAVE_RAW_DECL_MKNODAT
|
||||
_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
|
||||
"use gnulib module mkfifoat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_STAT@
|
||||
# if @REPLACE_STAT@
|
||||
/* We can't use the object-like #define stat rpl_stat, because of
|
||||
struct stat. This means that rpl_stat will not be used if the user
|
||||
does (stat)(a,b). Oh well. */
|
||||
# if defined _AIX && defined stat && defined _LARGE_FILES
|
||||
/* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
|
||||
so we have to replace stat64() instead of stat(). */
|
||||
# undef stat64
|
||||
# define stat64(name, st) rpl_stat (name, st)
|
||||
# elif @WINDOWS_64_BIT_ST_SIZE@
|
||||
/* Above, we define stat to _stati64. */
|
||||
# if defined __MINGW32__ && defined _stati64
|
||||
# ifndef _USE_32BIT_TIME_T
|
||||
/* The system headers define _stati64 to _stat64. */
|
||||
# undef _stat64
|
||||
# define _stat64(name, st) rpl_stat (name, st)
|
||||
# endif
|
||||
# elif defined _MSC_VER && defined _stati64
|
||||
# ifdef _USE_32BIT_TIME_T
|
||||
/* The system headers define _stati64 to _stat32i64. */
|
||||
# undef _stat32i64
|
||||
# define _stat32i64(name, st) rpl_stat (name, st)
|
||||
# else
|
||||
/* The system headers define _stati64 to _stat64. */
|
||||
# undef _stat64
|
||||
# define _stat64(name, st) rpl_stat (name, st)
|
||||
# endif
|
||||
# else
|
||||
# undef _stati64
|
||||
# define _stati64(name, st) rpl_stat (name, st)
|
||||
# endif
|
||||
# elif defined __MINGW32__ && defined stat
|
||||
# ifdef _USE_32BIT_TIME_T
|
||||
/* The system headers define stat to _stat32i64. */
|
||||
# undef _stat32i64
|
||||
# define _stat32i64(name, st) rpl_stat (name, st)
|
||||
# else
|
||||
/* The system headers define stat to _stat64. */
|
||||
# undef _stat64
|
||||
# define _stat64(name, st) rpl_stat (name, st)
|
||||
# endif
|
||||
# elif defined _MSC_VER && defined stat
|
||||
# ifdef _USE_32BIT_TIME_T
|
||||
/* The system headers define stat to _stat32. */
|
||||
# undef _stat32
|
||||
# define _stat32(name, st) rpl_stat (name, st)
|
||||
# else
|
||||
/* The system headers define stat to _stat64i32. */
|
||||
# undef _stat64i32
|
||||
# define _stat64i32(name, st) rpl_stat (name, st)
|
||||
# endif
|
||||
# else /* !(_AIX ||__MINGW32__ || _MSC_VER) */
|
||||
# undef stat
|
||||
# define stat(name, st) rpl_stat (name, st)
|
||||
# endif /* !_LARGE_FILES */
|
||||
_GL_EXTERN_C int stat (const char *name, struct stat *buf)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef stat
|
||||
# if HAVE_RAW_DECL_STAT
|
||||
_GL_WARN_ON_USE (stat, "stat is unportable - "
|
||||
"use gnulib module stat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_UTIMENSAT@
|
||||
/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
|
||||
implementation relies on futimesat, which on Solaris 10 makes an invocation
|
||||
to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
|
||||
utimensat(). */
|
||||
# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef utimensat
|
||||
# define utimensat rpl_utimensat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
|
||||
struct timespec const times[2], int flag)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
|
||||
struct timespec const times[2], int flag));
|
||||
# else
|
||||
# if !@HAVE_UTIMENSAT@
|
||||
_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
|
||||
struct timespec const times[2], int flag)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
|
||||
struct timespec const times[2], int flag));
|
||||
# endif
|
||||
# if @HAVE_UTIMENSAT@
|
||||
_GL_CXXALIASWARN (utimensat);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef utimensat
|
||||
# if HAVE_RAW_DECL_UTIMENSAT
|
||||
_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
|
||||
"use gnulib module utimensat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
|
||||
#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
|
||||
#endif
|
||||
205
lib/sys_time.in.h
Normal file
205
lib/sys_time.in.h
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
/* Provide a more complete sys/time.h.
|
||||
|
||||
Copyright (C) 2007-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined _@GUARD_PREFIX@_SYS_TIME_H
|
||||
|
||||
/* Simply delegate to the system's header, without adding anything. */
|
||||
# if @HAVE_SYS_TIME_H@
|
||||
# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
# define _@GUARD_PREFIX@_SYS_TIME_H
|
||||
|
||||
# if @HAVE_SYS_TIME_H@
|
||||
# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
|
||||
/* On native Windows with MSVC, get the 'struct timeval' type.
|
||||
Also, on native Windows with a 64-bit time_t, where we are overriding the
|
||||
'struct timeval' type, get all declarations of system functions whose
|
||||
signature contains 'struct timeval'. */
|
||||
# if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
|
||||
# define _GL_INCLUDING_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
# undef _GL_INCLUDING_WINSOCK2_H
|
||||
# endif
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
|
||||
|
||||
# if @REPLACE_STRUCT_TIMEVAL@
|
||||
# define timeval rpl_timeval
|
||||
# endif
|
||||
|
||||
# if !GNULIB_defined_struct_timeval
|
||||
struct timeval
|
||||
{
|
||||
time_t tv_sec;
|
||||
long int tv_usec;
|
||||
};
|
||||
# define GNULIB_defined_struct_timeval 1
|
||||
# endif
|
||||
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
# if @GNULIB_GETTIMEOFDAY@
|
||||
# if @REPLACE_GETTIMEOFDAY@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef gettimeofday
|
||||
# define gettimeofday rpl_gettimeofday
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (gettimeofday, int,
|
||||
(struct timeval *restrict, void *restrict)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (gettimeofday, int,
|
||||
(struct timeval *restrict, void *restrict));
|
||||
# else
|
||||
# if !@HAVE_GETTIMEOFDAY@
|
||||
_GL_FUNCDECL_SYS (gettimeofday, int,
|
||||
(struct timeval *restrict, void *restrict)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
# endif
|
||||
/* Need to cast, because on glibc systems, by default, the second argument is
|
||||
struct timezone *. */
|
||||
_GL_CXXALIAS_SYS_CAST (gettimeofday, int,
|
||||
(struct timeval *restrict, void *restrict));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (gettimeofday);
|
||||
# elif defined GNULIB_POSIXCHECK
|
||||
# undef gettimeofday
|
||||
# if HAVE_RAW_DECL_GETTIMEOFDAY
|
||||
_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
|
||||
"use gnulib module gettimeofday for portability");
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Hide some function declarations from <winsock2.h>. */
|
||||
|
||||
# if defined _MSC_VER && @HAVE_WINSOCK2_H@
|
||||
# if !defined _@GUARD_PREFIX@_UNISTD_H
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef close
|
||||
# define close close_used_without_including_unistd_h
|
||||
# else
|
||||
_GL_WARN_ON_USE (close,
|
||||
"close() used without including <unistd.h>");
|
||||
# endif
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef gethostname
|
||||
# define gethostname gethostname_used_without_including_unistd_h
|
||||
# else
|
||||
_GL_WARN_ON_USE (gethostname,
|
||||
"gethostname() used without including <unistd.h>");
|
||||
# endif
|
||||
# endif
|
||||
# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef socket
|
||||
# define socket socket_used_without_including_sys_socket_h
|
||||
# undef connect
|
||||
# define connect connect_used_without_including_sys_socket_h
|
||||
# undef accept
|
||||
# define accept accept_used_without_including_sys_socket_h
|
||||
# undef bind
|
||||
# define bind bind_used_without_including_sys_socket_h
|
||||
# undef getpeername
|
||||
# define getpeername getpeername_used_without_including_sys_socket_h
|
||||
# undef getsockname
|
||||
# define getsockname getsockname_used_without_including_sys_socket_h
|
||||
# undef getsockopt
|
||||
# define getsockopt getsockopt_used_without_including_sys_socket_h
|
||||
# undef listen
|
||||
# define listen listen_used_without_including_sys_socket_h
|
||||
# undef recv
|
||||
# define recv recv_used_without_including_sys_socket_h
|
||||
# undef send
|
||||
# define send send_used_without_including_sys_socket_h
|
||||
# undef recvfrom
|
||||
# define recvfrom recvfrom_used_without_including_sys_socket_h
|
||||
# undef sendto
|
||||
# define sendto sendto_used_without_including_sys_socket_h
|
||||
# undef setsockopt
|
||||
# define setsockopt setsockopt_used_without_including_sys_socket_h
|
||||
# undef shutdown
|
||||
# define shutdown shutdown_used_without_including_sys_socket_h
|
||||
# else
|
||||
_GL_WARN_ON_USE (socket,
|
||||
"socket() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (connect,
|
||||
"connect() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (accept,
|
||||
"accept() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (bind,
|
||||
"bind() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (getpeername,
|
||||
"getpeername() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (getsockname,
|
||||
"getsockname() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (getsockopt,
|
||||
"getsockopt() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (listen,
|
||||
"listen() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (recv,
|
||||
"recv() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (send,
|
||||
"send() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (recvfrom,
|
||||
"recvfrom() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (sendto,
|
||||
"sendto() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (setsockopt,
|
||||
"setsockopt() used without including <sys/socket.h>");
|
||||
_GL_WARN_ON_USE (shutdown,
|
||||
"shutdown() used without including <sys/socket.h>");
|
||||
# endif
|
||||
# endif
|
||||
# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef select
|
||||
# define select select_used_without_including_sys_select_h
|
||||
# else
|
||||
_GL_WARN_ON_USE (select,
|
||||
"select() used without including <sys/select.h>");
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
|
||||
309
lib/tempname.c
Normal file
309
lib/tempname.c
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
/* tempname.c - generate the name of a temporary file.
|
||||
|
||||
Copyright (C) 1991-2003, 2005-2007, 2009-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Extracted from glibc sysdeps/posix/tempname.c. See also tmpdir.c. */
|
||||
|
||||
#if !_LIBC
|
||||
# include <config.h>
|
||||
# include "tempname.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(Val) errno = (Val)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef P_tmpdir
|
||||
# define P_tmpdir "/tmp"
|
||||
#endif
|
||||
#ifndef TMP_MAX
|
||||
# define TMP_MAX 238328
|
||||
#endif
|
||||
#ifndef __GT_FILE
|
||||
# define __GT_FILE 0
|
||||
# define __GT_DIR 1
|
||||
# define __GT_NOCREATE 2
|
||||
#endif
|
||||
#if !_LIBC && (GT_FILE != __GT_FILE || GT_DIR != __GT_DIR \
|
||||
|| GT_NOCREATE != __GT_NOCREATE)
|
||||
# error report this to bug-gnulib@gnu.org
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if _LIBC
|
||||
# define struct_stat64 struct stat64
|
||||
#else
|
||||
# define struct_stat64 struct stat
|
||||
# define __gen_tempname gen_tempname
|
||||
# define __getpid getpid
|
||||
# define __gettimeofday gettimeofday
|
||||
# define __mkdir mkdir
|
||||
# define __open open
|
||||
# define __lxstat64(version, file, buf) lstat (file, buf)
|
||||
#endif
|
||||
|
||||
#if ! (HAVE___SECURE_GETENV || _LIBC)
|
||||
# define __secure_getenv getenv
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <hp-timing.h>
|
||||
# if HP_TIMING_AVAIL
|
||||
# define RANDOM_BITS(Var) \
|
||||
if (__builtin_expect (value == UINT64_C (0), 0)) \
|
||||
{ \
|
||||
/* If this is the first time this function is used initialize \
|
||||
the variable we accumulate the value in to some somewhat \
|
||||
random value. If we'd not do this programs at startup time \
|
||||
might have a reduced set of possible names, at least on slow \
|
||||
machines. */ \
|
||||
struct timeval tv; \
|
||||
__gettimeofday (&tv, NULL); \
|
||||
value = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; \
|
||||
} \
|
||||
HP_TIMING_NOW (Var)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Use the widest available unsigned type if uint64_t is not
|
||||
available. The algorithm below extracts a number less than 62**6
|
||||
(approximately 2**35.725) from uint64_t, so ancient hosts where
|
||||
uintmax_t is only 32 bits lose about 3.725 bits of randomness,
|
||||
which is better than not having mkstemp at all. */
|
||||
#if !defined UINT64_MAX && !defined uint64_t
|
||||
# define uint64_t uintmax_t
|
||||
#endif
|
||||
|
||||
#if _LIBC
|
||||
/* Return nonzero if DIR is an existent directory. */
|
||||
static int
|
||||
direxists (const char *dir)
|
||||
{
|
||||
struct_stat64 buf;
|
||||
return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
|
||||
}
|
||||
|
||||
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
|
||||
non-null and exists, uses it; otherwise uses the first of $TMPDIR,
|
||||
P_tmpdir, /tmp that exists. Copies into TMPL a template suitable
|
||||
for use with mk[s]temp. Will fail (-1) if DIR is non-null and
|
||||
doesn't exist, none of the searched dirs exists, or there's not
|
||||
enough space in TMPL. */
|
||||
int
|
||||
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
|
||||
int try_tmpdir)
|
||||
{
|
||||
const char *d;
|
||||
size_t dlen, plen;
|
||||
|
||||
if (!pfx || !pfx[0])
|
||||
{
|
||||
pfx = "file";
|
||||
plen = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
plen = strlen (pfx);
|
||||
if (plen > 5)
|
||||
plen = 5;
|
||||
}
|
||||
|
||||
if (try_tmpdir)
|
||||
{
|
||||
d = __secure_getenv ("TMPDIR");
|
||||
if (d != NULL && direxists (d))
|
||||
dir = d;
|
||||
else if (dir != NULL && direxists (dir))
|
||||
/* nothing */ ;
|
||||
else
|
||||
dir = NULL;
|
||||
}
|
||||
if (dir == NULL)
|
||||
{
|
||||
if (direxists (P_tmpdir))
|
||||
dir = P_tmpdir;
|
||||
else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
|
||||
dir = "/tmp";
|
||||
else
|
||||
{
|
||||
__set_errno (ENOENT);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dlen = strlen (dir);
|
||||
while (dlen > 1 && dir[dlen - 1] == '/')
|
||||
dlen--; /* remove trailing slashes */
|
||||
|
||||
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
|
||||
if (tmpl_len < dlen + 1 + plen + 6 + 1)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
|
||||
return 0;
|
||||
}
|
||||
#endif /* _LIBC */
|
||||
|
||||
/* These are the characters used in temporary file names. */
|
||||
static const char letters[] =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
/* Generate a temporary file name based on TMPL. TMPL must match the
|
||||
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
|
||||
The name constructed does not exist at the time of the call to
|
||||
__gen_tempname. TMPL is overwritten with the result.
|
||||
|
||||
KIND may be one of:
|
||||
__GT_NOCREATE: simply verify that the name does not exist
|
||||
at the time of the call.
|
||||
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
|
||||
and return a read-write fd. The file is mode 0600.
|
||||
__GT_DIR: create a directory, which will be mode 0700.
|
||||
|
||||
We use a clever algorithm to get hard-to-predict names. */
|
||||
int
|
||||
__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||
{
|
||||
int len;
|
||||
char *XXXXXX;
|
||||
static uint64_t value;
|
||||
uint64_t random_time_bits;
|
||||
unsigned int count;
|
||||
int fd = -1;
|
||||
int save_errno = errno;
|
||||
struct_stat64 st;
|
||||
|
||||
/* A lower bound on the number of temporary files to attempt to
|
||||
generate. The maximum total number of temporary file names that
|
||||
can exist for a given template is 62**6. It should never be
|
||||
necessary to try all of these combinations. Instead if a reasonable
|
||||
number of names is tried (we define reasonable as 62**3) fail to
|
||||
give the system administrator the chance to remove the problems. */
|
||||
#define ATTEMPTS_MIN (62 * 62 * 62)
|
||||
|
||||
/* The number of times to attempt to generate a temporary file. To
|
||||
conform to POSIX, this must be no smaller than TMP_MAX. */
|
||||
#if ATTEMPTS_MIN < TMP_MAX
|
||||
unsigned int attempts = TMP_MAX;
|
||||
#else
|
||||
unsigned int attempts = ATTEMPTS_MIN;
|
||||
#endif
|
||||
|
||||
len = strlen (tmpl);
|
||||
if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6))
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This is where the Xs start. */
|
||||
XXXXXX = &tmpl[len - 6 - suffixlen];
|
||||
|
||||
/* Get some more or less random data. */
|
||||
#ifdef RANDOM_BITS
|
||||
RANDOM_BITS (random_time_bits);
|
||||
#else
|
||||
{
|
||||
struct timeval tv;
|
||||
__gettimeofday (&tv, NULL);
|
||||
random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
|
||||
}
|
||||
#endif
|
||||
value += random_time_bits ^ __getpid ();
|
||||
|
||||
for (count = 0; count < attempts; value += 7777, ++count)
|
||||
{
|
||||
uint64_t v = value;
|
||||
|
||||
/* Fill in the random bits. */
|
||||
XXXXXX[0] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[1] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[2] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[3] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[4] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[5] = letters[v % 62];
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
case __GT_FILE:
|
||||
fd = __open (tmpl,
|
||||
(flags & ~O_ACCMODE)
|
||||
| O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
break;
|
||||
|
||||
case __GT_DIR:
|
||||
fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
break;
|
||||
|
||||
case __GT_NOCREATE:
|
||||
/* This case is backward from the other three. __gen_tempname
|
||||
succeeds if __xstat fails because the name does not exist.
|
||||
Note the continue to bypass the common logic at the bottom
|
||||
of the loop. */
|
||||
if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
/* Give up now. */
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
|
||||
default:
|
||||
assert (! "invalid KIND in __gen_tempname");
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
return fd;
|
||||
}
|
||||
else if (errno != EEXIST)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We got out of the loop because we ran out of combinations to try. */
|
||||
__set_errno (EEXIST);
|
||||
return -1;
|
||||
}
|
||||
50
lib/tempname.h
Normal file
50
lib/tempname.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* Create a temporary file or directory.
|
||||
|
||||
Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* header written by Eric Blake */
|
||||
|
||||
#ifndef GL_TEMPNAME_H
|
||||
# define GL_TEMPNAME_H
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
# ifdef __GT_FILE
|
||||
# define GT_FILE __GT_FILE
|
||||
# define GT_DIR __GT_DIR
|
||||
# define GT_NOCREATE __GT_NOCREATE
|
||||
# else
|
||||
# define GT_FILE 0
|
||||
# define GT_DIR 1
|
||||
# define GT_NOCREATE 2
|
||||
# endif
|
||||
|
||||
/* Generate a temporary file name based on TMPL. TMPL must match the
|
||||
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
|
||||
The name constructed does not exist at the time of the call to
|
||||
gen_tempname. TMPL is overwritten with the result.
|
||||
|
||||
KIND may be one of:
|
||||
GT_NOCREATE: simply verify that the name does not exist
|
||||
at the time of the call.
|
||||
GT_FILE: create a large file using open(O_CREAT|O_EXCL)
|
||||
and return a read-write fd. The file is mode 0600.
|
||||
GT_DIR: create a directory, which will be mode 0700.
|
||||
|
||||
We use a clever algorithm to get hard-to-predict names. */
|
||||
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
|
||||
|
||||
#endif /* GL_TEMPNAME_H */
|
||||
248
lib/time.in.h
Normal file
248
lib/time.in.h
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
/* A more-standard <time.h>.
|
||||
|
||||
Copyright (C) 2007-2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* Don't get in the way of glibc when it includes time.h merely to
|
||||
declare a few standard symbols, rather than to declare all the
|
||||
symbols. Also, Solaris 8 <time.h> eventually includes itself
|
||||
recursively; if that is happening, just include the system <time.h>
|
||||
without adding our own declarations. */
|
||||
#if (defined __need_time_t || defined __need_clock_t \
|
||||
|| defined __need_timespec \
|
||||
|| defined _@GUARD_PREFIX@_TIME_H)
|
||||
|
||||
# @INCLUDE_NEXT@ @NEXT_TIME_H@
|
||||
|
||||
#else
|
||||
|
||||
# define _@GUARD_PREFIX@_TIME_H
|
||||
|
||||
# @INCLUDE_NEXT@ @NEXT_TIME_H@
|
||||
|
||||
/* NetBSD 5.0 mis-defines NULL. */
|
||||
# include <stddef.h>
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
|
||||
Or they define it with the wrong member names or define it in <sys/time.h>
|
||||
(e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the
|
||||
pthreads-win32 library defines it in <pthread.h>. */
|
||||
# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
|
||||
# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
|
||||
# include <sys/time.h>
|
||||
# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
|
||||
# include <pthread.h>
|
||||
/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */
|
||||
# undef asctime_r
|
||||
# undef ctime_r
|
||||
# undef gmtime_r
|
||||
# undef localtime_r
|
||||
# undef rand_r
|
||||
# undef strtok_r
|
||||
# else
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# if !GNULIB_defined_struct_timespec
|
||||
# undef timespec
|
||||
# define timespec rpl_timespec
|
||||
struct timespec
|
||||
{
|
||||
time_t tv_sec;
|
||||
long int tv_nsec;
|
||||
};
|
||||
# define GNULIB_defined_struct_timespec 1
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if !GNULIB_defined_struct_time_t_must_be_integral
|
||||
/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
|
||||
time_t to be an integer type, even though C99 permits floating
|
||||
point. We don't know of any implementation that uses floating
|
||||
point, and it is much easier to write code that doesn't have to
|
||||
worry about that corner case, so we force the issue. */
|
||||
struct __time_t_must_be_integral {
|
||||
unsigned int __floating_time_t_unsupported : (time_t) 1;
|
||||
};
|
||||
# define GNULIB_defined_struct_time_t_must_be_integral 1
|
||||
# endif
|
||||
|
||||
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
|
||||
return -1 and store the remaining time into RMTP. See
|
||||
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */
|
||||
# if @GNULIB_NANOSLEEP@
|
||||
# if @REPLACE_NANOSLEEP@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define nanosleep rpl_nanosleep
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (nanosleep, int,
|
||||
(struct timespec const *__rqtp, struct timespec *__rmtp)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (nanosleep, int,
|
||||
(struct timespec const *__rqtp, struct timespec *__rmtp));
|
||||
# else
|
||||
# if ! @HAVE_NANOSLEEP@
|
||||
_GL_FUNCDECL_SYS (nanosleep, int,
|
||||
(struct timespec const *__rqtp, struct timespec *__rmtp)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (nanosleep, int,
|
||||
(struct timespec const *__rqtp, struct timespec *__rmtp));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (nanosleep);
|
||||
# endif
|
||||
|
||||
/* Return the 'time_t' representation of TP and normalize TP. */
|
||||
# if @GNULIB_MKTIME@
|
||||
# if @REPLACE_MKTIME@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define mktime rpl_mktime
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (mktime);
|
||||
# endif
|
||||
|
||||
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
|
||||
<http://www.opengroup.org/susv3xsh/localtime_r.html> and
|
||||
<http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
|
||||
# if @GNULIB_TIME_R@
|
||||
# if @REPLACE_LOCALTIME_R@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef localtime_r
|
||||
# define localtime_r rpl_localtime_r
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
|
||||
struct tm *restrict __result)
|
||||
_GL_ARG_NONNULL ((1, 2)));
|
||||
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
|
||||
struct tm *restrict __result));
|
||||
# else
|
||||
# if ! @HAVE_DECL_LOCALTIME_R@
|
||||
_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
|
||||
struct tm *restrict __result)
|
||||
_GL_ARG_NONNULL ((1, 2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
|
||||
struct tm *restrict __result));
|
||||
# endif
|
||||
# if @HAVE_DECL_LOCALTIME_R@
|
||||
_GL_CXXALIASWARN (localtime_r);
|
||||
# endif
|
||||
# if @REPLACE_LOCALTIME_R@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef gmtime_r
|
||||
# define gmtime_r rpl_gmtime_r
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
|
||||
struct tm *restrict __result)
|
||||
_GL_ARG_NONNULL ((1, 2)));
|
||||
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
|
||||
struct tm *restrict __result));
|
||||
# else
|
||||
# if ! @HAVE_DECL_LOCALTIME_R@
|
||||
_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
|
||||
struct tm *restrict __result)
|
||||
_GL_ARG_NONNULL ((1, 2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
|
||||
struct tm *restrict __result));
|
||||
# endif
|
||||
# if @HAVE_DECL_LOCALTIME_R@
|
||||
_GL_CXXALIASWARN (gmtime_r);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
|
||||
the resulting broken-down time into TM. See
|
||||
<http://www.opengroup.org/susv3xsh/strptime.html>. */
|
||||
# if @GNULIB_STRPTIME@
|
||||
# if ! @HAVE_STRPTIME@
|
||||
_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
|
||||
char const *restrict __format,
|
||||
struct tm *restrict __tm)
|
||||
_GL_ARG_NONNULL ((1, 2, 3)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
|
||||
char const *restrict __format,
|
||||
struct tm *restrict __tm));
|
||||
_GL_CXXALIASWARN (strptime);
|
||||
# endif
|
||||
|
||||
/* Convert TM to a time_t value, assuming UTC. */
|
||||
# if @GNULIB_TIMEGM@
|
||||
# if @REPLACE_TIMEGM@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef timegm
|
||||
# define timegm rpl_timegm
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
|
||||
# else
|
||||
# if ! @HAVE_TIMEGM@
|
||||
_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (timegm);
|
||||
# endif
|
||||
|
||||
/* Encourage applications to avoid unsafe functions that can overrun
|
||||
buffers when given outlandish struct tm values. Portable
|
||||
applications should use strftime (or even sprintf) instead. */
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# undef asctime
|
||||
_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
|
||||
"better use strftime (or even sprintf) instead");
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# undef asctime_r
|
||||
_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
|
||||
"better use strftime (or even sprintf) instead");
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# undef ctime
|
||||
_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
|
||||
"better use strftime (or even sprintf) instead");
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# undef ctime_r
|
||||
_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
|
||||
"better use strftime (or even sprintf) instead");
|
||||
# endif
|
||||
|
||||
#endif
|
||||
3
lib/xsize.c
Normal file
3
lib/xsize.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#include <config.h>
|
||||
#define XSIZE_INLINE _GL_EXTERN_INLINE
|
||||
#include "xsize.h"
|
||||
17
lib/xsize.h
17
lib/xsize.h
|
|
@ -27,6 +27,11 @@
|
|||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
#ifndef XSIZE_INLINE
|
||||
# define XSIZE_INLINE _GL_INLINE
|
||||
#endif
|
||||
|
||||
/* The size of memory objects is often computed through expressions of
|
||||
type size_t. Example:
|
||||
void* p = malloc (header_size + n * element_size).
|
||||
|
|
@ -48,7 +53,7 @@
|
|||
((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
|
||||
|
||||
/* Sum of two sizes, with overflow check. */
|
||||
static inline size_t
|
||||
XSIZE_INLINE size_t
|
||||
#if __GNUC__ >= 3
|
||||
__attribute__ ((__pure__))
|
||||
#endif
|
||||
|
|
@ -59,7 +64,7 @@ xsum (size_t size1, size_t size2)
|
|||
}
|
||||
|
||||
/* Sum of three sizes, with overflow check. */
|
||||
static inline size_t
|
||||
XSIZE_INLINE size_t
|
||||
#if __GNUC__ >= 3
|
||||
__attribute__ ((__pure__))
|
||||
#endif
|
||||
|
|
@ -69,7 +74,7 @@ xsum3 (size_t size1, size_t size2, size_t size3)
|
|||
}
|
||||
|
||||
/* Sum of four sizes, with overflow check. */
|
||||
static inline size_t
|
||||
XSIZE_INLINE size_t
|
||||
#if __GNUC__ >= 3
|
||||
__attribute__ ((__pure__))
|
||||
#endif
|
||||
|
|
@ -79,7 +84,7 @@ xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
|
|||
}
|
||||
|
||||
/* Maximum of two sizes, with overflow check. */
|
||||
static inline size_t
|
||||
XSIZE_INLINE size_t
|
||||
#if __GNUC__ >= 3
|
||||
__attribute__ ((__pure__))
|
||||
#endif
|
||||
|
|
@ -92,7 +97,7 @@ xmax (size_t size1, size_t size2)
|
|||
|
||||
/* Multiplication of a count with an element size, with overflow check.
|
||||
The count must be >= 0 and the element size must be > 0.
|
||||
This is a macro, not an inline function, so that it works correctly even
|
||||
This is a macro, not a function, so that it works correctly even
|
||||
when N is of a wider type and N > SIZE_MAX. */
|
||||
#define xtimes(N, ELSIZE) \
|
||||
((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
|
||||
|
|
@ -104,4 +109,6 @@ xmax (size_t size1, size_t size2)
|
|||
#define size_in_bounds_p(SIZE) \
|
||||
((SIZE) != SIZE_MAX)
|
||||
|
||||
_GL_INLINE_HEADER_END
|
||||
|
||||
#endif /* _XSIZE_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue