summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2020-12-06 15:51:17 -0500
committerChet Ramey <chet.ramey@case.edu>2020-12-06 15:51:17 -0500
commit8868edaf2250e09c4e9a1c75ffe3274f28f38581 (patch)
treed9a7812ab6cd2f45c5021755c4c094b19dab1b51 /include
parent36f2c406ff27995392a9247dfa90672fdaf7dc43 (diff)
downloadbash-8868edaf2250e09c4e9a1c75ffe3274f28f38581.tar.gz
bash-5.1 distribution sources and documentationbash-5.1
Diffstat (limited to 'include')
-rw-r--r--include/posixdir.h2
-rw-r--r--include/posixstat.h22
-rw-r--r--include/posixtime.h12
-rw-r--r--include/posixwait.h6
-rw-r--r--include/shmbutil.h11
-rw-r--r--include/shtty.h42
-rw-r--r--include/stdc.h12
-rw-r--r--include/systimes.h4
-rw-r--r--include/typemax.h19
9 files changed, 88 insertions, 42 deletions
diff --git a/include/posixdir.h b/include/posixdir.h
index 0921c5d7..af5be801 100644
--- a/include/posixdir.h
+++ b/include/posixdir.h
@@ -46,7 +46,7 @@
# define D_NAMLEN(d) ((d)->d_namlen)
#endif /* !HAVE_DIRENT_H */
-/* The bash code fairly consistenly uses d_fileno; make sure it's available */
+/* The bash code fairly consistently uses d_fileno; make sure it's available */
#if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (HAVE_STRUCT_DIRENT_D_FILENO)
# define d_fileno d_ino
#endif
diff --git a/include/posixstat.h b/include/posixstat.h
index 3eb7f290..b6077860 100644
--- a/include/posixstat.h
+++ b/include/posixstat.h
@@ -1,7 +1,7 @@
/* posixstat.h -- Posix stat(2) definitions for systems that
don't have them. */
-/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -132,6 +132,26 @@
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
+#else /* !S_IRWXU */
+ /* S_IRWXU is defined, but "group" and "other" bits might not be
+ (happens in certain versions of MinGW). */
+# if !defined (S_IRGRP)
+# define S_IRGRP (S_IREAD >> 3) /* read, group */
+# define S_IWGRP (S_IWRITE >> 3) /* write, group */
+# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
+# endif /* !S_IRGRP */
+
+# if !defined (S_IROTH)
+# define S_IROTH (S_IREAD >> 6) /* read, other */
+# define S_IWOTH (S_IWRITE >> 6) /* write, other */
+# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
+# endif /* !S_IROTH */
+# if !defined (S_IRWXG)
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
+# endif
+# if !defined (S_IRWXO)
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
+# endif
#endif /* !S_IRWXU */
/* These are non-standard, but are used in builtins.c$symbolic_umask() */
diff --git a/include/posixtime.h b/include/posixtime.h
index 31bdddf8..a83e436b 100644
--- a/include/posixtime.h
+++ b/include/posixtime.h
@@ -46,4 +46,16 @@
# endif /* !CLK_TCK */
#endif /* !HAVE_SYSCONF && !_SC_CLK_TCK */
+#if !HAVE_TIMEVAL
+struct timeval
+{
+ time_t tv_sec;
+ long int tv_usec;
+};
+#endif
+
+#if !HAVE_GETTIMEOFDAY
+extern int gettimeofday PARAMS((struct timeval *, void *));
+#endif
+
#endif /* _POSIXTIME_H_ */
diff --git a/include/posixwait.h b/include/posixwait.h
index 815ea229..63b59c24 100644
--- a/include/posixwait.h
+++ b/include/posixwait.h
@@ -77,7 +77,11 @@ typedef int WAIT;
# endif /* !WIFSIGNALED */
# if !defined (WIFCORED)
-# define WIFCORED(s) ((s) & 0200)
+# if defined (WCOREDUMP)
+# define WIFCORED(s) (WCOREDUMP(s))
+# else
+# define WIFCORED(s) ((s) & 0200)
+# endif
# endif /* !WIFCORED */
#else /* !_POSIX_VERSION */
diff --git a/include/shmbutil.h b/include/shmbutil.h
index 36902f16..835fb80c 100644
--- a/include/shmbutil.h
+++ b/include/shmbutil.h
@@ -1,6 +1,6 @@
/* shmbutil.h -- utility functions for multibyte characters. */
-/* Copyright (C) 2002-2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -29,12 +29,13 @@
#if defined (HANDLE_MULTIBYTE)
#include "shmbchar.h"
-extern size_t xmbsrtowcs __P((wchar_t *, const char **, size_t, mbstate_t *));
-extern size_t xdupmbstowcs __P((wchar_t **, char ***, const char *));
+extern size_t xwcsrtombs PARAMS((char *, const wchar_t **, size_t, mbstate_t *));
+extern size_t xmbsrtowcs PARAMS((wchar_t *, const char **, size_t, mbstate_t *));
+extern size_t xdupmbstowcs PARAMS((wchar_t **, char ***, const char *));
-extern size_t mbstrlen __P((const char *));
+extern size_t mbstrlen PARAMS((const char *));
-extern char *xstrchr __P((const char *, int));
+extern char *xstrchr PARAMS((const char *, int));
extern int locale_mb_cur_max; /* XXX */
extern int locale_utf8locale; /* XXX */
diff --git a/include/shtty.h b/include/shtty.h
index 66500d93..fdf379b8 100644
--- a/include/shtty.h
+++ b/include/shtty.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc. */
+/* Copyright (C) 1999-2020 Free Software Foundation, Inc. */
/* This file is part of GNU Bash, the Bourne Again SHell.
@@ -67,24 +67,24 @@
/* Get and set terminal attributes for the file descriptor passed as
an argument. */
-extern int ttgetattr __P((int, TTYSTRUCT *));
-extern int ttsetattr __P((int, TTYSTRUCT *));
+extern int ttgetattr PARAMS((int, TTYSTRUCT *));
+extern int ttsetattr PARAMS((int, TTYSTRUCT *));
/* Save and restore the terminal's attributes from static storage. */
-extern void ttsave __P((void));
-extern void ttrestore __P((void));
+extern void ttsave PARAMS((void));
+extern void ttrestore PARAMS((void));
/* Return the attributes corresponding to the file descriptor (0 or 1)
passed as an argument. */
-extern TTYSTRUCT *ttattr __P((int));
+extern TTYSTRUCT *ttattr PARAMS((int));
/* These functions only operate on the passed TTYSTRUCT; they don't
actually change anything with the kernel's current tty settings. */
-extern int tt_setonechar __P((TTYSTRUCT *));
-extern int tt_setnoecho __P((TTYSTRUCT *));
-extern int tt_seteightbit __P((TTYSTRUCT *));
-extern int tt_setnocanon __P((TTYSTRUCT *));
-extern int tt_setcbreak __P((TTYSTRUCT *));
+extern int tt_setonechar PARAMS((TTYSTRUCT *));
+extern int tt_setnoecho PARAMS((TTYSTRUCT *));
+extern int tt_seteightbit PARAMS((TTYSTRUCT *));
+extern int tt_setnocanon PARAMS((TTYSTRUCT *));
+extern int tt_setcbreak PARAMS((TTYSTRUCT *));
/* These functions are all generally mutually exclusive. If you call
more than one (bracketed with calls to ttsave and ttrestore, of
@@ -94,19 +94,19 @@ extern int tt_setcbreak __P((TTYSTRUCT *));
/* These functions work with a given file descriptor and set terminal
attributes */
-extern int ttfd_onechar __P((int, TTYSTRUCT *));
-extern int ttfd_noecho __P((int, TTYSTRUCT *));
-extern int ttfd_eightbit __P((int, TTYSTRUCT *));
-extern int ttfd_nocanon __P((int, TTYSTRUCT *));
+extern int ttfd_onechar PARAMS((int, TTYSTRUCT *));
+extern int ttfd_noecho PARAMS((int, TTYSTRUCT *));
+extern int ttfd_eightbit PARAMS((int, TTYSTRUCT *));
+extern int ttfd_nocanon PARAMS((int, TTYSTRUCT *));
-extern int ttfd_cbreak __P((int, TTYSTRUCT *));
+extern int ttfd_cbreak PARAMS((int, TTYSTRUCT *));
/* These functions work with fd 0 and the TTYSTRUCT saved with ttsave () */
-extern int ttonechar __P((void));
-extern int ttnoecho __P((void));
-extern int tteightbit __P((void));
-extern int ttnocanon __P((void));
+extern int ttonechar PARAMS((void));
+extern int ttnoecho PARAMS((void));
+extern int tteightbit PARAMS((void));
+extern int ttnocanon PARAMS((void));
-extern int ttcbreak __P((void));
+extern int ttcbreak PARAMS((void));
#endif
diff --git a/include/stdc.h b/include/stdc.h
index c66492f0..7b9282cc 100644
--- a/include/stdc.h
+++ b/include/stdc.h
@@ -26,18 +26,8 @@
/* A function can be defined using prototypes and compile on both ANSI C
and traditional C compilers with something like this:
- extern char *func __P((char *, char *, int)); */
+ extern char *func PARAMS((char *, char *, int)); */
-#if !defined (__P)
-# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) || defined (PROTOTYPES)
-# define __P(protos) protos
-# else
-# define __P(protos) ()
-# endif
-#endif
-
-/* New definition to use, moving away from __P since it's part of a reserved
- namespace */
#if !defined (PARAMS)
# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) || defined (PROTOTYPES)
# define PARAMS(protos) protos
diff --git a/include/systimes.h b/include/systimes.h
index ec2d92f5..aefcab7f 100644
--- a/include/systimes.h
+++ b/include/systimes.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1996, 2008,2009 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -49,7 +49,7 @@ struct tms
Return the elapsed real time from an arbitrary point in the
past (the bash emulation uses the epoch), or (clock_t) -1 for
errors. All times are in CLK_TCKths of a second. */
-extern clock_t times __P((struct tms *buffer));
+extern clock_t times PARAMS((struct tms *buffer));
#endif /* !HAVE_SYS_TIMES_H */
#endif /* _BASH_SYSTIMES_H */
diff --git a/include/typemax.h b/include/typemax.h
index 0f696388..9853d567 100644
--- a/include/typemax.h
+++ b/include/typemax.h
@@ -109,4 +109,23 @@ static const unsigned long long int maxquad = ULLONG_MAX;
# define SIZE_MAX 65535 /* POSIX minimum max */
#endif
+#ifndef sh_imaxabs
+# define sh_imaxabs(x) (((x) >= 0) ? (x) : -(x))
+#endif
+
+/* Handle signed arithmetic overflow and underflow. Have to do it this way
+ to avoid compilers optimizing out simpler overflow checks. */
+
+/* Make sure that a+b does not exceed MAXV or is smaller than MINV (if b < 0).
+ Assumes that b > 0 if a > 0 and b < 0 if a < 0 */
+#define ADDOVERFLOW(a,b,minv,maxv) \
+ ((((a) > 0) && ((b) > ((maxv) - (a)))) || \
+ (((a) < 0) && ((b) < ((minv) - (a)))))
+
+/* Make sure that a-b is not smaller than MINV or exceeds MAXV (if b < 0).
+ Assumes that b > 0 if a > 0 and b < 0 if a < 0 */
+#define SUBOVERFLOW(a,b,minv,maxv) \
+ ((((b) > 0) && ((a) < ((minv) + (b)))) || \
+ (((b) < 0) && ((a) > ((maxv) + (b)))))
+
#endif /* _SH_TYPEMAX_H */