Overall changes for C++

This commit is contained in:
mintsuki 2023-03-15 22:50:24 +01:00
parent 1b0f0ce419
commit b447ceb80b
15 changed files with 197 additions and 19 deletions

16
cfloat Normal file
View File

@ -0,0 +1,16 @@
#ifndef __cplusplus
#error "Must only use this header with C++"
#endif
#ifndef _CFLOAT
#define _CFLOAT 1
namespace std {
#define __LIBC_GUARDLESS_INCLUDE
#include <float.h>
#undef __LIBC_GUARDLESS_INCLUDE
}
#endif

0
ciso646 Normal file
View File

16
climits Normal file
View File

@ -0,0 +1,16 @@
#ifndef __cplusplus
#error "Must only use this header with C++"
#endif
#ifndef _CLIMITS
#define _CLIMITS 1
namespace std {
#define __LIBC_GUARDLESS_INCLUDE
#include <limits.h>
#undef __LIBC_GUARDLESS_INCLUDE
}
#endif

16
cstdalign Normal file
View File

@ -0,0 +1,16 @@
#ifndef __cplusplus
#error "Must only use this header with C++"
#endif
#ifndef _CSTDALIGN
#define _CSTDALIGN 1
namespace std {
#define __LIBC_GUARDLESS_INCLUDE
#include <stdalign.h>
#undef __LIBC_GUARDLESS_INCLUDE
}
#endif

16
cstdarg Normal file
View File

@ -0,0 +1,16 @@
#ifndef __cplusplus
#error "Must only use this header with C++"
#endif
#ifndef _CSTDARG
#define _CSTDARG 1
namespace std {
#define __LIBC_GUARDLESS_INCLUDE
#include <stdarg.h>
#undef __LIBC_GUARDLESS_INCLUDE
}
#endif

16
cstdbool Normal file
View File

@ -0,0 +1,16 @@
#ifndef __cplusplus
#error "Must only use this header with C++"
#endif
#ifndef _CSTDBOOL
#define _CSTDBOOL 1
namespace std {
#define __LIBC_GUARDLESS_INCLUDE
#include <stdbool.h>
#undef __LIBC_GUARDLESS_INCLUDE
}
#endif

16
cstddef Normal file
View File

@ -0,0 +1,16 @@
#ifndef __cplusplus
#error "Must only use this header with C++"
#endif
#ifndef _CSTDDEF
#define _CSTDDEF 1
namespace std {
#define __LIBC_GUARDLESS_INCLUDE
#include <stddef.h>
#undef __LIBC_GUARDLESS_INCLUDE
}
#endif

16
cstdint Normal file
View File

@ -0,0 +1,16 @@
#ifndef __cplusplus
#error "Must only use this header with C++"
#endif
#ifndef _CSTDINT
#define _CSTDINT 1
namespace std {
#define __LIBC_GUARDLESS_INCLUDE
#include <stdint.h>
#undef __LIBC_GUARDLESS_INCLUDE
}
#endif

13
float.h
View File

@ -1,5 +1,6 @@
#if !defined(_FLOAT_H) || defined(__LIBC_GUARDLESS_INCLUDE)
#ifndef _FLOAT_H #ifndef _FLOAT_H
#define _FLOAT_H 1
#define FLT_ROUNDS 1 #define FLT_ROUNDS 1
@ -11,6 +12,10 @@
#define DECIMAL_DIG __DECIMAL_DIG__ #define DECIMAL_DIG __DECIMAL_DIG__
#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#define FLT_DIG __FLT_DIG__ #define FLT_DIG __FLT_DIG__
@ -46,3 +51,9 @@
#define LDBL_MIN __LDBL_MIN__ #define LDBL_MIN __LDBL_MIN__
#endif #endif
#if !defined(__LIBC_GUARDLESS_INCLUDE)
#define _FLOAT_H 1
#endif
#endif

View File

@ -1,5 +1,6 @@
#if !defined(_LIMITS_H) || defined(__LIBC_GUARDLESS_INCLUDE)
#ifndef _LIMITS_H #ifndef _LIMITS_H
#define _LIMITS_H 1
#ifndef __LIBC_C_JOIN #ifndef __LIBC_C_JOIN
# define __LIBC_C_EXPAND_JOIN(x, suffix) x ## suffix # define __LIBC_C_EXPAND_JOIN(x, suffix) x ## suffix
@ -8,6 +9,8 @@
#define CHAR_BIT __CHAR_BIT__ #define CHAR_BIT __CHAR_BIT__
#define MB_LEN_MAX 16
#define SCHAR_MAX __SCHAR_MAX__ #define SCHAR_MAX __SCHAR_MAX__
#define SCHAR_MIN (-SCHAR_MAX - 1) #define SCHAR_MIN (-SCHAR_MAX - 1)
@ -42,3 +45,9 @@
#define ULLONG_MAX (__LIBC_C_JOIN(LLONG_MAX, U) * 2 + 1) #define ULLONG_MAX (__LIBC_C_JOIN(LLONG_MAX, U) * 2 + 1)
#endif #endif
#if !defined(__LIBC_GUARDLESS_INCLUDE)
#define _LIMITS_H 1
#endif
#endif

View File

@ -1,10 +1,20 @@
#ifndef _STDALIGN_H #if !defined(_STDALIGN_H) || defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDALIGN_H 1
#define alignas _Alignas #ifndef _STDALIGN_H
#define alignof _Alignof
#ifndef __cplusplus
# define alignas _Alignas
# define alignof _Alignof
# define __alignof_is_defined 1
#endif
#define __alignas_is_defined 1 #define __alignas_is_defined 1
#define __alignof_is_defined 1
#endif
#if !defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDALIGN_H 1
#endif
#endif #endif

View File

@ -1,11 +1,18 @@
#ifndef _STDARG_H #if !defined(_STDARG_H) || defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDARG_H 1
typedef __builtin_va_list va_list; typedef __builtin_va_list va_list;
#ifndef _STDARG_H
#define va_start(v, l) __builtin_va_start(v, l) #define va_start(v, l) __builtin_va_start(v, l)
#define va_end(v) __builtin_va_end(v) #define va_end(v) __builtin_va_end(v)
#define va_arg(v, l) __builtin_va_arg(v, l) #define va_arg(v, l) __builtin_va_arg(v, l)
#define va_copy(d, s) __builtin_va_copy(d, s) #define va_copy(d, s) __builtin_va_copy(d, s)
#endif #endif
#if !defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDARG_H 1
#endif
#endif

View File

@ -1,11 +1,20 @@
#if !defined(_STDBOOL_H) || defined(__LIBC_GUARDLESS_INCLUDE)
#ifndef __cplusplus
# define bool _Bool
# define true 1
# define false 0
#endif
#ifndef _STDBOOL_H #ifndef _STDBOOL_H
#define _STDBOOL_H 1
#define bool _Bool
#define true 1
#define false 0
#define __bool_true_false_are_defined 1 #define __bool_true_false_are_defined 1
#endif #endif
#if !defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDBOOL_H 1
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef _STDDEF_H #if !defined(_STDDEF_H) || defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDDEF_H 1
typedef __SIZE_TYPE__ size_t; typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t; typedef __PTRDIFF_TYPE__ ptrdiff_t;
@ -8,6 +7,14 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __WCHAR_TYPE__ wchar_t; typedef __WCHAR_TYPE__ wchar_t;
#endif #endif
#ifdef __cplusplus
typedef decltype(nullptr) nullptr_t;
enum class byte : unsigned char {};
#endif
#ifndef _STDDEF_H
#ifdef NULL #ifdef NULL
#undef NULL #undef NULL
#endif #endif
@ -21,3 +28,9 @@ typedef __WCHAR_TYPE__ wchar_t;
#define offsetof(s, m) __builtin_offsetof(s, m) #define offsetof(s, m) __builtin_offsetof(s, m)
#endif #endif
#if !defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDDEF_H 1
#endif
#endif

View File

@ -1,5 +1,4 @@
#ifndef _STDINT_H #if !defined(_STDINT_H) || defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDINT_H 1
typedef __UINT8_TYPE__ uint8_t; typedef __UINT8_TYPE__ uint8_t;
typedef __UINT16_TYPE__ uint16_t; typedef __UINT16_TYPE__ uint16_t;
@ -37,6 +36,8 @@ typedef __INTPTR_TYPE__ intptr_t;
typedef __UINTMAX_TYPE__ uintmax_t; typedef __UINTMAX_TYPE__ uintmax_t;
typedef __INTMAX_TYPE__ intmax_t; typedef __INTMAX_TYPE__ intmax_t;
#ifndef _STDINT_H
/* Clang and GCC have different mechanisms for INT32_C and friends. */ /* Clang and GCC have different mechanisms for INT32_C and friends. */
#ifdef __clang__ #ifdef __clang__
# define __LIBC_C_EXPAND_JOIN(x, suffix) x ## suffix # define __LIBC_C_EXPAND_JOIN(x, suffix) x ## suffix
@ -137,3 +138,9 @@ typedef __INTMAX_TYPE__ intmax_t;
#define WINT_MIN (-WINT_MAX - 1) #define WINT_MIN (-WINT_MAX - 1)
#endif #endif
#if !defined(__LIBC_GUARDLESS_INCLUDE)
#define _STDINT_H 1
#endif
#endif