VSF Documented
stddef.h
Go to the documentation of this file.
1#ifndef __SIMPLE_LIBC_STDDEF_H__
2#define __SIMPLE_LIBC_STDDEF_H__
3
5
6#if VSF_LINUX_CFG_RELATIVE_PATH == ENABLED
7# include "../sys/types.h"
8#else
9# include <sys/types.h>
10#endif
11
12// for uintptr_t
13#include <stdint.h>
14
15// include compiler detect only, do not include compiler.h
17
18#define VSF_LINUX_LIBC_WRAPPER(__api) VSF_SHELL_WRAPPER(vsf_linux_libc, __api)
19
20// define wchar_t and wint_t before include vsf_utilities.h
21// because vsf_utilities will include other c headers which will require wchar_t
22#if !defined(__cplusplus)
23// wchar_t MSUT match the real wchar_t in the compiler, if not, fix here
24// eg: for GCC, wchar_t is int
25# if defined(__WCHAR_TYPE__)
26typedef __WCHAR_TYPE__ wchar_t;
27# elif defined(__WIN__)
28typedef unsigned short wchar_t;
29# elif __IS_COMPILER_GCC__ || __IS_COMPILER_LLVM__
30typedef int wchar_t;
31# elif __IS_COMPILER_IAR__
32# if !defined(__ARM_SIZEOF_WCHAR_T)
33// old iar has no __ARM_SIZEOF_WCHAR_T, and use 4 bytes as wchar_t
34typedef unsigned int wchar_t;
35# elif __ARM_SIZEOF_WCHAR_T == 2
36typedef unsigned short wchar_t;
37# elif __ARM_SIZEOF_WCHAR_T == 4
38typedef unsigned int wchar_t;
39# else
40# error __ARM_SIZEOF_WCHAR_T not supported
41# endif
42# else
43typedef unsigned short wchar_t;
44# endif
45#endif
46#ifdef __WINT_TYPE__
47typedef __WINT_TYPE__ wint_t;
48#else
49typedef unsigned short wint_t;
50#endif
51#if __IS_COMPILER_IAR__
52# define _WINTT
53#endif
54
55#ifndef NULL
56# ifdef __cplusplus
57# define NULL (0)
58# else
59# define NULL ((void *)0)
60# endif
61#endif
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
67#ifndef TRUE
68# define TRUE 1
69#endif
70#ifndef FALSE
71# define FALSE 0
72#endif
73// DO not define BOOL, it will conflict with system headers in some platform
74
75#ifndef offsetof
76// use offsetof from compiler if available for constexpr feature in cpp
77# if __IS_COMPILER_GCC__ || __IS_COMPILER_LLVM__
78# define offsetof(__type, __member) __builtin_offsetof(__type, __member)
79# else
80# define offsetof(__type, __member) (uintptr_t)(&(((__type *)0)->__member))
81# endif
82#endif
83
84// define max_align_t, can not depend on uintalu_t because of circular depoendency
85#if __IS_COMPILER_GCC__
86typedef struct {
87 long long __clang_max_align_nonce1
88 __attribute__((__aligned__(__alignof__(long long))));
89 long double __clang_max_align_nonce2
90 __attribute__((__aligned__(__alignof__(long double))));
92#elif __IS_COMPILER_LLVM__
93# if defined(__WIN__)
94typedef double max_align_t;
95# elif defined(__MACOS__)
96typedef long double max_align_t;
97# else
98typedef struct {
99 long long __clang_max_align_nonce1
100 __attribute__((__aligned__(__alignof__(long long))));
101 long double __clang_max_align_nonce2
102 __attribute__((__aligned__(__alignof__(long double))));
104# endif
105#else
106typedef long double max_align_t;
107#endif
108
109#if __IS_COMPILER_IAR__
110typedef void *nullptr_t;
111#endif
112
113#if defined(__PTRDIFF_TYPE__)
114typedef __PTRDIFF_TYPE__ ptrdiff_t;
115#elif defined(__WIN__)
116# if defined(__CPU_X86__)
117typedef unsigned int size_t;
118typedef int ptrdiff_t;
119typedef int intptr_t;
120typedef unsigned int uintptr_t;
121# elif defined(__CPU_X64__)
122typedef unsigned __int64 size_t;
123typedef __int64 ptrdiff_t;
124typedef __int64 intptr_t;
125typedef unsigned __int64 uintptr_t;
126# endif
127#else
128typedef long int ptrdiff_t;
129#endif
130
131#ifdef __cplusplus
132}
133
134# ifdef __WIN__
135namespace std {
136 typedef decltype(__nullptr) nullptr_t;
137}
138
139using ::std::nullptr_t;
140# endif
141#endif
142
143#endif
__attribute__((weak))
Definition handlers.c:10
long int ptrdiff_t
Definition stddef.h:128
long double max_align_t
Definition stddef.h:106
unsigned short wchar_t
Definition stddef.h:43
unsigned short wint_t
Definition stddef.h:49
unsigned int size_t
Definition types.h:51
Definition vsf_linux_glibcpp.cc:8
uint32_t uintptr_t
Definition stdint.h:38
int32_t intptr_t
Definition stdint.h:39