[PATCH v1 02/35] Assume __GNUC__ >= 2
Alejandro Colomar
alx@kernel.org
Sun Nov 9 21:52:49 GMT 2025
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
ctype/ctype.h | 4 +-
include/limits.h | 80 ----------------------------
intl/dcigettext.c | 5 --
libio/oldstdfiles.c | 4 --
misc/sys/cdefs.h | 10 ----
posix/regex_internal.h | 2 +-
stdlib/longlong.h | 9 +---
sysdeps/generic/machine-gmon.h | 6 +--
sysdeps/mach/hurd/x86/sys/io.h | 4 --
sysdeps/unix/sysv/linux/x86/sys/io.h | 4 --
time/strptime_l.c | 6 ---
11 files changed, 6 insertions(+), 128 deletions(-)
diff --git a/ctype/ctype.h b/ctype/ctype.h
index 3864c90617..0da70c8d96 100644
--- a/ctype/ctype.h
+++ b/ctype/ctype.h
@@ -216,7 +216,7 @@ __NTH (toupper (int __c))
}
# endif
-# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
+# if defined __OPTIMIZE__ && !defined __cplusplus
# define tolower(c) __tobody (c, tolower, *__ctype_tolower_loc (), (c))
# define toupper(c) __tobody (c, toupper, *__ctype_toupper_loc (), (c))
# endif /* Optimizing gcc */
@@ -271,7 +271,7 @@ extern int tolower_l (int __c, locale_t __l) __THROW;
extern int __toupper_l (int __c, locale_t __l) __THROW;
extern int toupper_l (int __c, locale_t __l) __THROW;
-# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
+# if defined __OPTIMIZE__ && !defined __cplusplus
# define __tolower_l(c, locale) \
__tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))
# define __toupper_l(c, locale) \
diff --git a/include/limits.h b/include/limits.h
index 905849b736..6d69c86f08 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -32,86 +32,6 @@
#define MB_LEN_MAX 16
-/* If we are not using GNU CC we have to define all the symbols ourself.
- Otherwise use gcc's definitions (see below). */
-#if __GNUC__ < 2
-
-/* We only protect from multiple inclusion here, because all the other
- #include's protect themselves, and in GCC 2 we may #include_next through
- multiple copies of this file before we get to GCC's. */
-# ifndef _LIMITS_H
-# define _LIMITS_H 1
-
-#include <bits/wordsize.h>
-
-/* We don't have #include_next.
- Define ANSI <limits.h> for standard 32-bit words. */
-
-/* These assume 8-bit `char's, 16-bit `short int's,
- and 32-bit `int's and `long int's. */
-
-/* Number of bits in a `char'. */
-# define CHAR_BIT 8
-
-/* Minimum and maximum values a `signed char' can hold. */
-# define SCHAR_MIN (-128)
-# define SCHAR_MAX 127
-
-/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
-# define UCHAR_MAX 255
-
-/* Minimum and maximum values a `char' can hold. */
-# ifdef __CHAR_UNSIGNED__
-# define CHAR_MIN 0
-# define CHAR_MAX UCHAR_MAX
-# else
-# define CHAR_MIN SCHAR_MIN
-# define CHAR_MAX SCHAR_MAX
-# endif
-
-/* Minimum and maximum values a `signed short int' can hold. */
-# define SHRT_MIN (-32768)
-# define SHRT_MAX 32767
-
-/* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */
-# define USHRT_MAX 65535
-
-/* Minimum and maximum values a `signed int' can hold. */
-# define INT_MIN (-INT_MAX - 1)
-# define INT_MAX 2147483647
-
-/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
-# define UINT_MAX 4294967295U
-
-/* Minimum and maximum values a `signed long int' can hold. */
-# if __WORDSIZE == 64
-# define LONG_MAX 9223372036854775807L
-# else
-# define LONG_MAX 2147483647L
-# endif
-# define LONG_MIN (-LONG_MAX - 1L)
-
-/* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */
-# if __WORDSIZE == 64
-# define ULONG_MAX 18446744073709551615UL
-# else
-# define ULONG_MAX 4294967295UL
-# endif
-
-# ifdef __USE_ISOC99
-
-/* Minimum and maximum values a `signed long long int' can hold. */
-# define LLONG_MAX 9223372036854775807LL
-# define LLONG_MIN (-LLONG_MAX - 1LL)
-
-/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
-# define ULLONG_MAX 18446744073709551615ULL
-
-# endif /* ISO C99 */
-
-# endif /* limits.h */
-#endif /* GCC 2. */
-
#endif /* !_LIBC_LIMITS_H_ */
/* Get the compiler's limits.h, which defines almost all the ISO constants.
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index cb33a589a1..fe5c19bf37 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -95,12 +95,7 @@ extern int errno;
#endif
/* Alignment of types. */
-#if __GNUC__ >= 2
# define alignof(TYPE) __alignof__ (TYPE)
-#else
-# define alignof(TYPE) \
- ((int) &((struct { char dummy1; TYPE dummy2; } *) 0)->dummy2)
-#endif
/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>. */
#ifndef offsetof
diff --git a/libio/oldstdfiles.c b/libio/oldstdfiles.c
index 250bf9e616..af793413ba 100644
--- a/libio/oldstdfiles.c
+++ b/libio/oldstdfiles.c
@@ -52,8 +52,6 @@ compat_symbol (libc, _IO_stdin_, _IO_stdin_, GLIBC_2_0);
compat_symbol (libc, _IO_stdout_, _IO_stdout_, GLIBC_2_0);
compat_symbol (libc, _IO_stderr_, _IO_stderr_, GLIBC_2_0);
-#if __GNUC__ >= 2
-
#include <stdio.h>
extern const int _IO_stdin_used;
@@ -96,5 +94,3 @@ _IO_check_libio (void)
}
#endif
-
-#endif
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index a4ae665d8a..71e2ec92d5 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -383,8 +383,6 @@
Example:
int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
-#if (__GNUC__ >= 2) || (__clang_major__ >= 4)
-
# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
# ifdef __cplusplus
# define __REDIRECT_NTH(name, proto, alias) \
@@ -408,14 +406,6 @@
#define __REDIRECT_FORTIFY_NTH __REDIRECT_NTH
#endif
-/*
-#elif __SOME_OTHER_COMPILER__
-
-# define __REDIRECT(name, proto, alias) name proto; \
- _Pragma("let " #name " = " #alias)
-*/
-#endif
-
/* At some point during the gcc 2.96 development the `malloc' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
diff --git a/posix/regex_internal.h b/posix/regex_internal.h
index 722da1b7d2..34c7c32764 100644
--- a/posix/regex_internal.h
+++ b/posix/regex_internal.h
@@ -347,7 +347,7 @@ typedef struct
Idx idx; /* for BACK_REF */
re_context_type ctx_type; /* for ANCHOR */
} opr;
-#if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__
+#if !defined __STRICT_ANSI__
re_token_type_t type : 8;
#else
re_token_type_t type;
diff --git a/stdlib/longlong.h b/stdlib/longlong.h
index 49a78c9596..0be2159111 100644
--- a/stdlib/longlong.h
+++ b/stdlib/longlong.h
@@ -112,15 +112,10 @@ extern const UQItype __clz_tab[256] attribute_hidden;
#if !defined (NO_ASM)
-/* We sometimes need to clobber "cc" with gcc2, but that would not be
- understood by gcc1. Use cpp to avoid major code duplication. */
-#if __GNUC__ < 2
-#define __CLOBBER_CC
-#define __AND_CLOBBER_CC
-#else /* __GNUC__ >= 2 */
+/* We sometimes need to clobber "cc".
+ Use cpp to avoid major code duplication. */
#define __CLOBBER_CC : "cc"
#define __AND_CLOBBER_CC , "cc"
-#endif /* __GNUC__ < 2 */
#if defined (__aarch64__)
diff --git a/sysdeps/generic/machine-gmon.h b/sysdeps/generic/machine-gmon.h
index 20babbbaf5..e4a6528f47 100644
--- a/sysdeps/generic/machine-gmon.h
+++ b/sysdeps/generic/machine-gmon.h
@@ -16,7 +16,7 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-/* GCC version 2 gives us a perfect magical function to get
+/* GCC gives us a perfect magical function to get
just the information we need:
void *__builtin_return_address (unsigned int N)
returns the return address of the frame N frames up. */
@@ -25,10 +25,6 @@
for N != 0 on all machines. In this case, you may have to write
your own version of _mcount(). */
-#if __GNUC__ < 2
- #error "This file uses __builtin_return_address, a GCC 2 extension."
-#endif
-
#include <sysdep.h>
/* The canonical name for the function is `_mcount' in both C and asm,
but some old asm code might assume it's `mcount'. */
diff --git a/sysdeps/mach/hurd/x86/sys/io.h b/sysdeps/mach/hurd/x86/sys/io.h
index 24e0ecf7df..1dd5b324b5 100644
--- a/sysdeps/mach/hurd/x86/sys/io.h
+++ b/sysdeps/mach/hurd/x86/sys/io.h
@@ -34,8 +34,6 @@ extern int ioperm (unsigned long int __from, unsigned long int __num,
privileges. */
extern int iopl (int __level) __THROW;
-#if __GNUC__ >= 2
-
static __inline unsigned char
inb (unsigned short int port)
{
@@ -171,7 +169,5 @@ outsl (unsigned short int port, const void *addr, unsigned long int count)
"=c" (count):"d" (port), "0" (addr), "1" (count));
}
-#endif /* GNU C */
-
__END_DECLS
#endif /* _SYS_IO_H */
diff --git a/sysdeps/unix/sysv/linux/x86/sys/io.h b/sysdeps/unix/sysv/linux/x86/sys/io.h
index af65e556b2..b9eda87faf 100644
--- a/sysdeps/unix/sysv/linux/x86/sys/io.h
+++ b/sysdeps/unix/sysv/linux/x86/sys/io.h
@@ -37,8 +37,6 @@ extern int ioperm (unsigned long int __from, unsigned long int __num,
privileges. */
extern int iopl (int __level) __THROW;
-#if __GNUC__ >= 2
-
static __inline unsigned char
inb (unsigned short int __port)
{
@@ -177,7 +175,5 @@ outsl (unsigned short int __port, const void *__addr,
:"d" (__port), "0" (__addr), "1" (__count));
}
-#endif /* GNU C */
-
__END_DECLS
#endif /* _SYS_IO_H */
diff --git a/time/strptime_l.c b/time/strptime_l.c
index 988ee0b655..ab5d4447bd 100644
--- a/time/strptime_l.c
+++ b/time/strptime_l.c
@@ -56,17 +56,11 @@ localtime_r (const time_t *t, struct tm *tp)
#define match_char(ch1, ch2) if (ch1 != ch2) return NULL
-#if __GNUC__ >= 2
# define match_string(cs1, s2) \
({ size_t len = strlen (cs1); \
int result = __strncasecmp_l ((cs1), (s2), len, locale) == 0; \
if (result) (s2) += len; \
result; })
-#else
-/* Oh come on. Get a reasonable compiler. */
-# define match_string(cs1, s2) \
- (strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1))
-#endif
/* We intentionally do not use isdigit() for testing because this will
lead to problems with the wide character version. */
#define get_number(from, to, n) \
--
2.51.0
More information about the Libc-alpha
mailing list