summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-05-08 23:28:42 +0000
committerJim Meyering <jim@meyering.net>1999-05-08 23:28:42 +0000
commit4905751e2f5bbc6d412f221151ab58f938697a2c (patch)
tree2b009826d64fecd3a24b03b5fec9cef40cdebb72 /src
parentd103085de3752c50318391f8e1b395f1e2ca991d (diff)
downloadcoreutils-4905751e2f5bbc6d412f221151ab58f938697a2c.tar.xz
* src/system.h (CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM,
and all the *_MIN and *_MAX symbols): Remove definitions. * src/sys2.h: Put the definitions here instead (this file is shared between all three *utils packages, while system.h is not).
Diffstat (limited to 'src')
-rw-r--r--src/sys2.h72
1 files changed, 64 insertions, 8 deletions
diff --git a/src/sys2.h b/src/sys2.h
index bd367800e..9207a08f7 100644
--- a/src/sys2.h
+++ b/src/sys2.h
@@ -3,14 +3,6 @@
more time, I'll merge the remaining things in system.h and everything
in this file will go back there. */
-#ifndef UID_T_MAX
-# define UID_T_MAX TYPE_MAXIMUM (uid_t)
-#endif
-
-#ifndef GID_T_MAX
-# define GID_T_MAX TYPE_MAXIMUM (gid_t)
-#endif
-
#ifndef RETSIGTYPE
# define RETSIGTYPE void
#endif
@@ -290,3 +282,67 @@ char *base_name PARAMS ((char const *));
#ifndef MIN
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
+
+#ifndef CHAR_BIT
+# define CHAR_BIT 8
+#endif
+
+/* The extra casts work around common compiler bugs. */
+#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
+ It is necessary at least when t == time_t. */
+#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
+ ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
+#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
+
+#ifndef CHAR_MIN
+# define CHAR_MIN TYPE_MINIMUM (char)
+#endif
+
+#ifndef CHAR_MAX
+# define CHAR_MAX TYPE_MAXIMUM (char)
+#endif
+
+#ifndef SCHAR_MIN
+# define SCHAR_MIN (-1 - SCHAR_MAX)
+#endif
+
+#ifndef SCHAR_MAX
+# define SCHAR_MAX (CHAR_MAX == UCHAR_MAX ? CHAR_MAX / 2 : CHAR_MAX)
+#endif
+
+#ifndef UCHAR_MAX
+# define UCHAR_MAX TYPE_MAXIMUM (unsigned char)
+#endif
+
+#ifndef SHRT_MIN
+# define SHRT_MIN TYPE_MINIMUM (short int)
+#endif
+
+#ifndef SHRT_MAX
+# define SHRT_MAX TYPE_MAXIMUM (short int)
+#endif
+
+#ifndef INT_MAX
+# define INT_MAX TYPE_MAXIMUM (int)
+#endif
+
+#ifndef UINT_MAX
+# define UINT_MAX TYPE_MAXIMUM (unsigned int)
+#endif
+
+#ifndef LONG_MAX
+# define LONG_MAX TYPE_MAXIMUM (long)
+#endif
+
+#ifndef ULONG_MAX
+# define ULONG_MAX TYPE_MAXIMUM (unsigned long)
+#endif
+
+#ifndef UID_T_MAX
+# define UID_T_MAX TYPE_MAXIMUM (uid_t)
+#endif
+
+#ifndef GID_T_MAX
+# define GID_T_MAX TYPE_MAXIMUM (gid_t)
+#endif