diff options
Diffstat (limited to 'lib/system.h')
-rw-r--r-- | lib/system.h | 110 |
1 files changed, 77 insertions, 33 deletions
diff --git a/lib/system.h b/lib/system.h index 2deb585..0914195 100644 --- a/lib/system.h +++ b/lib/system.h @@ -1,11 +1,11 @@ /* System dependent definitions for GNU tar. Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, - 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + 2004 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) + the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,7 +15,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ #if HAVE_CONFIG_H # include <config.h> @@ -108,19 +109,10 @@ extern int errno; #ifndef O_TRUNC # define O_TRUNC 32 /* truncate file on open */ #endif - -#ifndef O_BINARY + /* MS-DOG forever, with my love! */ +#ifndef O_BINARY # define O_BINARY 0 #endif -#ifndef O_DIRECTORY -# define O_DIRECTORY 0 -#endif -#ifndef O_NOATIME -# define O_NOATIME 0 -#endif -#ifndef O_NONBLOCK -# define O_NONBLOCK 0 -#endif /* Declare file status routines and bits. */ @@ -260,7 +252,9 @@ extern int errno; #define MODE_ALL (S_ISUID | S_ISGID | S_ISVTX | MODE_RWX) /* Include <unistd.h> before any preprocessor test of _POSIX_VERSION. */ -#include <unistd.h> +#if HAVE_UNISTD_H +# include <unistd.h> +#endif #ifndef SEEK_SET # define SEEK_SET 0 @@ -288,9 +282,6 @@ extern int errno; #if MAJOR_IN_MKDEV # include <sys/mkdev.h> -# if !defined(makedev) && defined(mkdev) -# define makedev(a,b) mkdev((a),(b)) -# endif # define GOT_MAJOR #endif @@ -386,12 +377,45 @@ extern int errno; #endif #ifndef ST_NBLOCKSIZE -# define ST_NBLOCKSIZE 512 +#define ST_NBLOCKSIZE 512 #endif -#define ST_IS_SPARSE(st) \ - (ST_NBLOCKS (st) \ - < ((st).st_size / ST_NBLOCKSIZE + ((st).st_size % ST_NBLOCKSIZE != 0))) +/* This is a real challenge to properly get MTIO* symbols :-(. ISC uses + <sys/gentape.h>. SCO and BSDi uses <sys/tape.h>; BSDi also requires + <sys/tprintf.h> and <sys/device.h> for defining tp_dev and tpr_t. It + seems that the rest use <sys/mtio.h>, which itself requires other files, + depending on systems. Pyramid defines _IOW in <sgtty.h>, for example. */ + +#if HAVE_SYS_GENTAPE_H +# include <sys/gentape.h> +#else +# if HAVE_SYS_TAPE_H +# if HAVE_SYS_DEVICE_H +# include <sys/device.h> +# endif +# if HAVE_SYS_PARAM_H +# include <sys/param.h> +# endif +# if HAVE_SYS_BUF_H +# include <sys/buf.h> +# endif +# if HAVE_SYS_TPRINTF_H +# include <sys/tprintf.h> +# endif +# include <sys/tape.h> +# else +# if HAVE_SYS_MTIO_H +# include <sys/ioctl.h> +# if HAVE_SGTTY_H +# include <sgtty.h> +# endif +# if HAVE_SYS_IO_TRIOCTL_H +# include <sys/io/trioctl.h> +# endif +# include <sys/mtio.h> +# endif +# endif +#endif /* Declare standard functions. */ @@ -411,6 +435,7 @@ char *getenv (); #endif #if WITH_DMALLOC +# undef HAVE_DECL_VALLOC # define DMALLOC_FUNC_CHECK # include <dmalloc.h> #endif @@ -421,11 +446,28 @@ char *getenv (); # define MB_LEN_MAX 1 #endif -#include <inttypes.h> +#if HAVE_INTTYPES_H +# include <inttypes.h> +#endif + +/* These macros work even on ones'-complement hosts (!). + The extra casts work around common compiler bugs. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +#define TYPE_MINIMUM(t) (TYPE_SIGNED (t) \ + ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \ + : (t) 0) +#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) -#include <intprops.h> +/* Bound on length of the string representing an integer value of type t. + Subtract one for the sign bit if t is signed; + 302 / 1000 is log10 (2) rounded up; + add one for integer division truncation; + add one more for a minus sign if t is signed. */ +#define INT_STRLEN_BOUND(t) \ + ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \ + + 1 + TYPE_SIGNED (t)) -#define UINTMAX_STRSIZE_BOUND INT_BUFSIZE_BOUND (uintmax_t) +#define UINTMAX_STRSIZE_BOUND (INT_STRLEN_BOUND (uintmax_t) + 1) /* Prototypes for external functions. */ @@ -437,9 +479,16 @@ char *getenv (); #endif #include <time.h> -#ifdef TIME_WITH_SYS_TIME +#if defined(HAVE_SYS_TIME_H) && defined(TIME_WITH_SYS_TIME) # include <sys/time.h> #endif +#if ! HAVE_DECL_TIME +time_t time (); +#endif + +#ifdef HAVE_UTIME_H +# include <utime.h> +#endif /* Library modules. */ @@ -453,13 +502,6 @@ char *getenv (); #define _(msgid) gettext (msgid) #define N_(msgid) msgid -#ifdef HAVE_PWD_H -# include <pwd.h> -#endif -#ifdef HAVE_GRP_H -# include <grp.h> -#endif - #if MSDOS # include <process.h> # define SET_BINARY_MODE(arc) setmode(arc, O_BINARY) @@ -468,6 +510,8 @@ char *getenv (); # define TTY_NAME "con" # define sys_reset_uid_gid() #else +# include <pwd.h> +# include <grp.h> # define SET_BINARY_MODE(arc) # define ERRNO_IS_EACCES 0 # define TTY_NAME "/dev/tty" |