Skip to content

Commit 9448b05

Browse files
committed
refactor headers, especially alltypes.h, and improve C++ ABI compat
the arch-specific bits/alltypes.h.sh has been replaced with a generic alltypes.h.in and minimal arch-specific bits/alltypes.h.in. this commit is intended to have no functional changes except: - exposing additional symbols that POSIX allows but does not require - changing the C++ name mangling for some types - fixing the signedness of blksize_t on powerpc (POSIX requires signed) - fixing the limit macros for sig_atomic_t on x86_64 - making dev_t an unsigned type (ABI matching goal, and more logical) in addition, some types that were wrongly defined with long on 32-bit archs were changed to int, and vice versa; this change is non-functional except for the possibility of making pointer types mismatch, and only affects programs that were using them incorrectly, and only at build-time, not runtime. the following changes were made in the interest of moving non-arch-specific types out of the alltypes system and into the headers they're associated with, and also will tend to improve application compatibility: - netdb.h now includes netinet/in.h (for socklen_t and uint32_t) - netinet/in.h now includes sys/socket.h and inttypes.h - sys/resource.h now includes sys/time.h (for struct timeval) - sys/wait.h now includes signal.h (for siginfo_t) - langinfo.h now includes nl_types.h (for nl_item) for the types in stdint.h: - types which are of no interest to other headers were moved out of the alltypes system. - fast types for 8- and 64-bit are hard-coded (at least for now); only the 16- and 32-bit ones have reason to vary by arch. and the following types have been changed for C++ ABI purposes; - mbstate_t now has a struct tag, __mbstate_t - FILE's struct tag has been changed to _IO_FILE - DIR's struct tag has been changed to __dirstream - locale_t's struct tag has been changed to __locale_struct - pthread_t is defined as unsigned long in C++ mode only - fpos_t now has a struct tag, _G_fpos64_t - fsid_t's struct tag has been changed to __fsid_t - idtype_t has been made an enum type (also required by POSIX) - nl_catd has been changed from long to void * - siginfo_t's struct tag has been removed - sigset_t's has been given a struct tag, __sigset_t - stack_t has been given a struct tag, sigaltstack - suseconds_t has been changed to long on 32-bit archs - [u]intptr_t have been changed from long to int rank on 32-bit archs - dev_t has been made unsigned summary of tests that have been performed against these changes: - nsz's libc-test (diff -u before and after) - C++ ABI check symbol dump (diff -u before, after, glibc) - grepped for __NEED, made sure types needed are still in alltypes - built gcc 3.4.6
1 parent 976c0fd commit 9448b05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+335
-907
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ include/bits:
7373
@test "$(ARCH)" || { echo "Please set ARCH in config.mak before running make." ; exit 1 ; }
7474
ln -sf ../arch/$(ARCH)/bits $@
7575

76-
include/bits/alltypes.h.sh: include/bits
76+
include/bits/alltypes.h.in: include/bits
7777

78-
include/bits/alltypes.h: include/bits/alltypes.h.sh
79-
sh $< > $@
78+
include/bits/alltypes.h: include/bits/alltypes.h.in include/alltypes.h.in tools/mkalltypes.sed
79+
sed -f tools/mkalltypes.sed include/bits/alltypes.h.in include/alltypes.h.in > $@
8080

8181
src/ldso/dynlink.lo: arch/$(ARCH)/reloc.h
8282

arch/arm/bits/alltypes.h.in

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#define _Addr int
2+
#define _Int64 long long
3+
4+
TYPEDEF __builtin_va_list va_list;
5+
TYPEDEF __builtin_va_list __isoc_va_list;
6+
7+
#ifndef __cplusplus
8+
TYPEDEF unsigned wchar_t;
9+
#endif
10+
TYPEDEF int wint_t;
11+
12+
TYPEDEF float float_t;
13+
TYPEDEF double double_t;
14+
15+
TYPEDEF long time_t;
16+
TYPEDEF long suseconds_t;
17+
18+
TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
19+
TYPEDEF struct { union { int __i[6]; void *__p[6]; } __u; } pthread_mutex_t;
20+
TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
21+
TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
22+
TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;

arch/arm/bits/alltypes.h.sh

-127
This file was deleted.

arch/arm/bits/stdint.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
#define INT_FAST8_MIN INT8_MIN
1+
typedef int32_t int_fast16_t;
2+
typedef int32_t int_fast32_t;
3+
typedef uint32_t uint_fast16_t;
4+
typedef uint32_t uint_fast32_t;
5+
26
#define INT_FAST16_MIN INT32_MIN
37
#define INT_FAST32_MIN INT32_MIN
4-
#define INT_FAST64_MIN INT64_MIN
58

6-
#define INT_FAST8_MAX INT8_MAX
79
#define INT_FAST16_MAX INT32_MAX
810
#define INT_FAST32_MAX INT32_MAX
9-
#define INT_FAST64_MAX INT64_MAX
1011

11-
#define UINT_FAST8_MAX UINT8_MAX
1212
#define UINT_FAST16_MAX UINT32_MAX
1313
#define UINT_FAST32_MAX UINT32_MAX
14-
#define UINT_FAST64_MAX UINT64_MAX
1514

1615
#define INTPTR_MIN INT32_MIN
1716
#define INTPTR_MAX INT32_MAX

arch/i386/bits/alltypes.h.in

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#define _Addr int
2+
#define _Int64 long long
3+
4+
#if __GNUC__ >= 3
5+
TYPEDEF __builtin_va_list va_list;
6+
TYPEDEF __builtin_va_list __isoc_va_list;
7+
#else
8+
TYPEDEF struct __va_list * va_list;
9+
TYPEDEF struct __va_list * __isoc_va_list;
10+
#endif
11+
12+
#ifndef __cplusplus
13+
#ifdef __WCHAR_TYPE__
14+
TYPEDEF __WCHAR_TYPE__ wchar_t;
15+
#else
16+
TYPEDEF long wchar_t;
17+
#endif
18+
#endif
19+
TYPEDEF long wint_t;
20+
21+
#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 0
22+
TYPEDEF float float_t;
23+
TYPEDEF double double_t;
24+
#else
25+
TYPEDEF long double float_t;
26+
TYPEDEF long double double_t;
27+
#endif
28+
29+
TYPEDEF long time_t;
30+
TYPEDEF long suseconds_t;
31+
32+
TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
33+
TYPEDEF struct { union { int __i[6]; void *__p[6]; } __u; } pthread_mutex_t;
34+
TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
35+
TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
36+
TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;

arch/i386/bits/alltypes.h.sh

-141
This file was deleted.

arch/i386/bits/stdint.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
#define INT_FAST8_MIN INT8_MIN
1+
typedef int32_t int_fast16_t;
2+
typedef int32_t int_fast32_t;
3+
typedef uint32_t uint_fast16_t;
4+
typedef uint32_t uint_fast32_t;
5+
26
#define INT_FAST16_MIN INT32_MIN
37
#define INT_FAST32_MIN INT32_MIN
4-
#define INT_FAST64_MIN INT64_MIN
58

6-
#define INT_FAST8_MAX INT8_MAX
79
#define INT_FAST16_MAX INT32_MAX
810
#define INT_FAST32_MAX INT32_MAX
9-
#define INT_FAST64_MAX INT64_MAX
1011

11-
#define UINT_FAST8_MAX UINT8_MAX
1212
#define UINT_FAST16_MAX UINT32_MAX
1313
#define UINT_FAST32_MAX UINT32_MAX
14-
#define UINT_FAST64_MAX UINT64_MAX
1514

1615
#define INTPTR_MIN INT32_MIN
1716
#define INTPTR_MAX INT32_MAX
1817
#define UINTPTR_MAX UINT32_MAX
1918
#define PTRDIFF_MIN INT32_MIN
2019
#define PTRDIFF_MAX INT32_MAX
21-
#define SIG_ATOMIC_MIN INT32_MIN
22-
#define SIG_ATOMIC_MAX INT32_MAX
2320
#define SIZE_MAX UINT32_MAX

0 commit comments

Comments
 (0)