From 767c095adbe156b25d2de8e48a417df3ed926468 Mon Sep 17 00:00:00 2001 From: yanghaku <1961882079@qq.com> Date: Fri, 14 Jul 2023 12:05:49 +0800 Subject: [PATCH] [Types]Fix size_t types in x86, fix wchar_t in cplusplus, add locale_t and max_align_t. Signed-off-by: yanghaku <1961882079@qq.com> --- src/arch/riscv64/include/bits/types.h | 12 ++++++++++++ src/arch/x86/include/bits/types.h | 28 ++++++++++++++++++++++----- src/internal/locale_impl.h | 2 -- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/arch/riscv64/include/bits/types.h b/src/arch/riscv64/include/bits/types.h index b5309a0..8f04e40 100644 --- a/src/arch/riscv64/include/bits/types.h +++ b/src/arch/riscv64/include/bits/types.h @@ -25,6 +25,18 @@ typedef signed long int loff_t; typedef signed int bool_t; +#ifndef __cplusplus typedef int wchar_t; +#endif // !__cplusplus typedef unsigned wint_t; typedef unsigned long wctype_t; + +#if !defined(__DEFINED_locale_t) +typedef struct __locale_struct * locale_t; +#define __DEFINED_locale_t +#endif + +#if !defined(__DEFINED_max_align_t) +typedef struct { long long __ll; long double __ld; } max_align_t; +#define __DEFINED_max_align_t +#endif diff --git a/src/arch/x86/include/bits/types.h b/src/arch/x86/include/bits/types.h index 1aadc7f..ad51c75 100644 --- a/src/arch/x86/include/bits/types.h +++ b/src/arch/x86/include/bits/types.h @@ -13,18 +13,36 @@ typedef unsigned long long u64_t; typedef signed long long intmax_t; typedef unsigned long long uintmax_t; -typedef signed int ptrdiff_t; -typedef signed int intptr_t; -typedef unsigned int uintptr_t; +typedef signed long int ptrdiff_t; +typedef signed long int intptr_t; +typedef unsigned long int uintptr_t; -typedef unsigned int size_t; -typedef signed int ssize_t; +typedef unsigned long int size_t; +typedef signed long int ssize_t; typedef signed int off_t; typedef signed long long loff_t; typedef signed int bool_t; +#ifndef __cplusplus typedef unsigned short wchar_t; +#endif // !__cplusplus typedef unsigned wint_t; typedef unsigned long wctype_t; + +#if !defined(__DEFINED_locale_t) +typedef struct __locale_struct * locale_t; +#define __DEFINED_locale_t +#endif + +#if !defined(__DEFINED_max_align_t) +#if !defined(__cplusplus) +typedef struct { _Alignas(8) long long __ll; long double __ld; } max_align_t; +#elif defined(__GNUC__) +typedef struct { __attribute__((__aligned__(8))) long long __ll; long double __ld; } max_align_t; +#else +typedef struct { alignas(8) long long __ll; long double __ld; } max_align_t; +#endif +#define __DEFINED_max_align_t +#endif diff --git a/src/internal/locale_impl.h b/src/internal/locale_impl.h index 1a3dabf..52461ca 100644 --- a/src/internal/locale_impl.h +++ b/src/internal/locale_impl.h @@ -15,8 +15,6 @@ struct __locale_map { const struct __locale_map *next; }; -typedef struct __locale_struct * locale_t; - extern hidden_sym volatile int __locale_lock[1]; extern hidden_sym const struct __locale_map __c_dot_utf8; -- Gitee