relibc: integrate upstream wchar.h include ordering + stdbool.h POSIX fix
Two upstream improvements integrated: 1. wchar.h cbindgen.toml — adopt upstream include ordering: - Remove redundant wchar_t redefinition (now provided by bits/wchar-t.h) - Define wint_t BEFORE #include <stddef.h> (conflict with GCC __need_wint_t) - Drop sys_includes, use no_includes=true (all includes in after_includes) - Cleaner circular-dependency breaking (wchar.h → stdio.h → inttypes.h → wchar.h) 2. stdbool.h — fix to POSIX standard: - Change 'typedef _Bool bool' to '#define bool _Bool' (C mode) - Remove 'typedef bool _Bool' (C++ mode, not in POSIX) - Only emit bool/true/false defines in C++ when __cplusplus < 201103L
This commit is contained in:
+2
-2
@@ -2,12 +2,12 @@
|
||||
#define _STDBOOL_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef _Bool bool;
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
#else /* __cplusplus */
|
||||
typedef bool _Bool;
|
||||
#if __cplusplus < 201103L
|
||||
#define bool bool
|
||||
#define false false
|
||||
#define true true
|
||||
#endif /*__cplusplus < 201103L*/
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
sys_includes = ["features.h", "stddef.h", "stdarg.h", "stdio.h"]
|
||||
# wint_t defined before stddef.h to avoid conflict with GCC's __need_wint_t.
|
||||
# wchar_t provided by bits/wchar-t.h → stddef.h (no local redefinition needed).
|
||||
# mbstate_t defined before transitive includes to break circular chains:
|
||||
# wchar.h → stdio.h → inttypes.h → wchar.h (gnulib-based: m4, bison, flex).
|
||||
after_includes = """
|
||||
// int32_t, uint32_t, WCHAR_MIN, WCHAR_MAX
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef _WCHAR_T
|
||||
#define _WCHAR_T
|
||||
#ifndef __cplusplus
|
||||
#ifndef __WCHAR_TYPE__
|
||||
#define __WCHAR_TYPE__ int32_t
|
||||
#endif
|
||||
typedef __WCHAR_TYPE__ wchar_t;
|
||||
#endif // __cplusplus
|
||||
#endif // _WCHAR_T
|
||||
#include <stdint.h> // for uint32_t, WCHAR_MIN, WCHAR_MAX
|
||||
|
||||
#ifndef _WINT_T
|
||||
#define _WINT_T
|
||||
@@ -21,32 +13,24 @@ after_includes = """
|
||||
typedef __WINT_TYPE__ wint_t;
|
||||
#endif // _WINT_T
|
||||
|
||||
// Define mbstate_t before headers that may transitively re-include wchar.h.
|
||||
// The circular chain wchar.h → stdio.h → inttypes.h → wchar.h (and also
|
||||
// stdlib.h → wchar.h) would otherwise cause wint_t and mbstate_t to be
|
||||
// undefined in gnulib's wchar.h wrapper, breaking m4, bison, and other
|
||||
// gnulib-based packages.
|
||||
#ifndef _RELIBC_MBSTATE_T
|
||||
#define _RELIBC_MBSTATE_T
|
||||
typedef struct {} mbstate_t;
|
||||
#endif
|
||||
|
||||
// Now include headers that depend on wchar_t/wint_t/mbstate_t.
|
||||
// These must come after the type definitions to break circular includes.
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
// NULL, size_t, must come after wchar_t and wint_t
|
||||
// wchar_t comes from stddef.h → bits/wchar-t.h
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
#include <stdio.h> // for FILE
|
||||
#include <time.h> // for struct tm
|
||||
|
||||
#define WEOF (0xffffffffu)
|
||||
"""
|
||||
include_guard = "_RELIBC_WCHAR_H"
|
||||
language = "C"
|
||||
style = "Type"
|
||||
no_includes = false
|
||||
no_includes = true
|
||||
cpp_compat = true
|
||||
|
||||
[export]
|
||||
|
||||
Reference in New Issue
Block a user