Skip to content

Commit 4ba2500

Browse files
committed
Revise alltypes.h update process. NFC
Align it with musl, i.e. only update `alltypes.h.in` and regenerate `alltypes.h` using a script.
1 parent 90250aa commit 4ba2500

File tree

4 files changed

+215
-71
lines changed

4 files changed

+215
-71
lines changed

system/lib/libc/musl/arch/emscripten/bits/alltypes.h

Lines changed: 149 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
#define __LITTLE_ENDIAN 1234
2-
#define __BIG_ENDIAN 4321
3-
#define __USE_TIME_BITS64 1
4-
5-
#define __BYTE_ORDER __LITTLE_ENDIAN
6-
7-
#define __LONG_MAX __LONG_MAX__
8-
1+
/*
2+
* The .h version of this file is generated from the .h.in.
3+
* See update_alltypes.sh.
4+
*/
95
#define _Addr __PTRDIFF_TYPE__
106
#define _Int64 __INT64_TYPE__
117
#define _Reg __PTRDIFF_TYPE__
128

13-
#if __GNUC__ >= 3
9+
#define __BYTE_ORDER 1234
10+
#define __LONG_MAX __LONG_MAX__
11+
1412
#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
1513
typedef __builtin_va_list va_list;
1614
#define __DEFINED_va_list
@@ -21,18 +19,6 @@ typedef __builtin_va_list __isoc_va_list;
2119
#define __DEFINED___isoc_va_list
2220
#endif
2321

24-
#else
25-
#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
26-
typedef struct __va_list * va_list;
27-
#define __DEFINED_va_list
28-
#endif
29-
30-
#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list)
31-
typedef struct __va_list * __isoc_va_list;
32-
#define __DEFINED___isoc_va_list
33-
#endif
34-
35-
#endif
3622

3723
#ifndef __cplusplus
3824
#ifdef __WCHAR_TYPE__
@@ -43,7 +29,7 @@ typedef __WCHAR_TYPE__ wchar_t;
4329

4430
#else
4531
#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
46-
typedef int wchar_t;
32+
typedef long wchar_t;
4733
#define __DEFINED_wchar_t
4834
#endif
4935

@@ -55,6 +41,48 @@ typedef __WINT_TYPE__ wint_t;
5541
#endif
5642

5743

44+
// XXX EMSCRIPTEN: ensure it's always 32-bits even in wasm64
45+
#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t)
46+
typedef int blkcnt_t;
47+
#define __DEFINED_blkcnt_t
48+
#endif
49+
50+
#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t)
51+
typedef int blksize_t;
52+
#define __DEFINED_blksize_t
53+
#endif
54+
55+
#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
56+
typedef int clock_t;
57+
#define __DEFINED_clock_t
58+
#endif
59+
60+
#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t)
61+
typedef unsigned int dev_t;
62+
#define __DEFINED_dev_t
63+
#endif
64+
65+
#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t)
66+
typedef unsigned int fsblkcnt_t;
67+
#define __DEFINED_fsblkcnt_t
68+
#endif
69+
70+
#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
71+
typedef int suseconds_t;
72+
#define __DEFINED_suseconds_t
73+
#endif
74+
75+
#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t)
76+
typedef unsigned int fsfilcnt_t;
77+
#define __DEFINED_fsfilcnt_t
78+
#endif
79+
80+
#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t)
81+
typedef unsigned int wctype_t;
82+
#define __DEFINED_wctype_t
83+
#endif
84+
85+
5886
#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 0
5987
#if defined(__NEED_float_t) && !defined(__DEFINED_float_t)
6088
typedef float float_t;
@@ -79,40 +107,40 @@ typedef long double double_t;
79107

80108
#endif
81109

82-
#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
83-
typedef _Int64 time_t;
84-
#define __DEFINED_time_t
110+
#ifndef __cplusplus
111+
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
112+
typedef struct { _Alignas(8) long long __ll; long double __ld; } max_align_t;
113+
#define __DEFINED_max_align_t
85114
#endif
86115

87-
#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
88-
typedef int suseconds_t; /* XXX EMSCRIPTEN: ensure it's always 32-bits even in wasm64 */
89-
#define __DEFINED_suseconds_t
116+
#elif defined(__GNUC__)
117+
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
118+
typedef struct { __attribute__((__aligned__(8))) long long __ll; long double __ld; } max_align_t;
119+
#define __DEFINED_max_align_t
90120
#endif
91121

122+
#else
123+
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
124+
typedef struct { alignas(8) long long __ll; long double __ld; } max_align_t;
125+
#define __DEFINED_max_align_t
126+
#endif
92127

128+
#endif
129+
130+
// For canvas transfer implementation in Emscripten, use an extra control field
131+
// to pass a pointer to a string denoting the WebGL canvases to transfer.
93132
#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
94-
typedef struct {
95-
union {
96-
int __i[10];
97-
volatile int __vi[10];
98-
unsigned long __s[10];
99-
} __u;
100-
#ifdef __EMSCRIPTEN__
101-
// For canvas transfer implementation in Emscripten, use an extra control field
102-
// to pass a pointer to a string denoting the WebGL canvases to transfer.
103-
const char *_a_transferredcanvases;
104-
#endif
105-
} pthread_attr_t;
133+
typedef struct { union { int __i[10]; volatile int __vi[10]; unsigned long __s[10]; } __u; const char *_a_transferredcanvases; } pthread_attr_t;
106134
#define __DEFINED_pthread_attr_t
107135
#endif
108136

109137
#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
110-
typedef struct { union { int __i[6]; volatile int __vi[6]; volatile void *__p[6]; } __u; } pthread_mutex_t;
138+
typedef struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
111139
#define __DEFINED_pthread_mutex_t
112140
#endif
113141

114142
#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t)
115-
typedef struct { union { int __i[6]; volatile int __vi[6]; volatile void *__p[6]; } __u; } mtx_t;
143+
typedef struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
116144
#define __DEFINED_mtx_t
117145
#endif
118146

@@ -127,7 +155,7 @@ typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __
127155
#endif
128156

129157
#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
130-
typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t;
158+
typedef struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
131159
#define __DEFINED_pthread_rwlock_t
132160
#endif
133161

@@ -136,6 +164,9 @@ typedef struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u;
136164
#define __DEFINED_pthread_barrier_t
137165
#endif
138166

167+
#define __LITTLE_ENDIAN 1234
168+
#define __BIG_ENDIAN 4321
169+
#define __USE_TIME_BITS64 1
139170

140171
#if defined(__NEED_size_t) && !defined(__DEFINED_size_t)
141172
typedef unsigned _Addr size_t;
@@ -172,29 +203,39 @@ typedef _Reg register_t;
172203
#define __DEFINED_register_t
173204
#endif
174205

206+
#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
207+
typedef _Int64 time_t;
208+
#define __DEFINED_time_t
209+
#endif
210+
211+
#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
212+
typedef _Int64 suseconds_t;
213+
#define __DEFINED_suseconds_t
214+
#endif
215+
175216

176217
#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t)
177218
typedef signed char int8_t;
178219
#define __DEFINED_int8_t
179220
#endif
180221

181222
#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t)
182-
typedef short int16_t;
223+
typedef signed short int16_t;
183224
#define __DEFINED_int16_t
184225
#endif
185226

186227
#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t)
187-
typedef int int32_t;
228+
typedef signed int int32_t;
188229
#define __DEFINED_int32_t
189230
#endif
190231

191232
#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t)
192-
typedef _Int64 int64_t;
233+
typedef signed _Int64 int64_t;
193234
#define __DEFINED_int64_t
194235
#endif
195236

196237
#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t)
197-
typedef _Int64 intmax_t;
238+
typedef signed _Int64 intmax_t;
198239
#define __DEFINED_intmax_t
199240
#endif
200241

@@ -250,37 +291,38 @@ typedef unsigned _Int64 ino_t;
250291
#endif
251292

252293
#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t)
253-
typedef unsigned int dev_t;
294+
typedef unsigned _Int64 dev_t;
254295
#define __DEFINED_dev_t
255296
#endif
256297

257298
#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t)
258-
typedef int blksize_t; /* XXX EMSCRIPTEN: ensure it's always 32-bits even in wasm64 */
299+
typedef long blksize_t;
259300
#define __DEFINED_blksize_t
260301
#endif
261302

262303
#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t)
263-
typedef int blkcnt_t;
304+
typedef _Int64 blkcnt_t;
264305
#define __DEFINED_blkcnt_t
265306
#endif
266307

267308
#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t)
268-
typedef unsigned int fsblkcnt_t;
309+
typedef unsigned _Int64 fsblkcnt_t;
269310
#define __DEFINED_fsblkcnt_t
270311
#endif
271312

272313
#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t)
273-
typedef unsigned int fsfilcnt_t;
314+
typedef unsigned _Int64 fsfilcnt_t;
274315
#define __DEFINED_fsfilcnt_t
275316
#endif
276317

318+
277319
#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
278320
typedef unsigned wint_t;
279321
#define __DEFINED_wint_t
280322
#endif
281323

282324
#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t)
283-
typedef unsigned int wctype_t; /* XXX EMSCRIPTEN: ensure it's always 32-bits even in wasm64 */
325+
typedef unsigned long wctype_t;
284326
#define __DEFINED_wctype_t
285327
#endif
286328

@@ -296,22 +338,17 @@ typedef int clockid_t;
296338
#endif
297339

298340
#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
299-
typedef int clock_t; /* XXX EMSCRIPTEN: ensure it's always 32-bits even in wasm64 */
341+
typedef long clock_t;
300342
#define __DEFINED_clock_t
301343
#endif
302344

303-
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
304-
typedef struct { long long __ll; long double __ld; } max_align_t;
305-
#define __DEFINED_max_align_t
306-
#endif
307-
308345
#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval)
309346
struct timeval { time_t tv_sec; suseconds_t tv_usec; };
310347
#define __DEFINED_struct_timeval
311348
#endif
312349

313350
#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec)
314-
struct timespec { time_t tv_sec; long tv_nsec; };
351+
struct timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); };
315352
#define __DEFINED_struct_timespec
316353
#endif
317354

@@ -396,12 +433,28 @@ typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;
396433
#endif
397434

398435

436+
#if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE)
437+
struct _IO_FILE { char __x; };
438+
#define __DEFINED_struct__IO_FILE
439+
#endif
440+
399441
#if defined(__NEED_FILE) && !defined(__DEFINED_FILE)
400442
typedef struct _IO_FILE FILE;
401443
#define __DEFINED_FILE
402444
#endif
403445

404446

447+
#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
448+
typedef __builtin_va_list va_list;
449+
#define __DEFINED_va_list
450+
#endif
451+
452+
#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list)
453+
typedef __builtin_va_list __isoc_va_list;
454+
#define __DEFINED___isoc_va_list
455+
#endif
456+
457+
405458
#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t)
406459
typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
407460
#define __DEFINED_mbstate_t
@@ -443,6 +496,42 @@ typedef unsigned short sa_family_t;
443496
#endif
444497

445498

499+
#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
500+
typedef struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t;
501+
#define __DEFINED_pthread_attr_t
502+
#endif
503+
504+
#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
505+
typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t;
506+
#define __DEFINED_pthread_mutex_t
507+
#endif
508+
509+
#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t)
510+
typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t;
511+
#define __DEFINED_mtx_t
512+
#endif
513+
514+
#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t)
515+
typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t;
516+
#define __DEFINED_pthread_cond_t
517+
#endif
518+
519+
#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t)
520+
typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t;
521+
#define __DEFINED_cnd_t
522+
#endif
523+
524+
#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
525+
typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t;
526+
#define __DEFINED_pthread_rwlock_t
527+
#endif
528+
529+
#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t)
530+
typedef struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t;
531+
#define __DEFINED_pthread_barrier_t
532+
#endif
533+
534+
446535
#undef _Addr
447536
#undef _Int64
448537
#undef _Reg

0 commit comments

Comments
 (0)