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// DO not define BOOL, it will conflict with system headers in some platforms
68// TRUE and FALSE maybe conflict with headers from chip vendor,
69// so only define them only when necessary for some platform/arch.
70#if 0
71#ifndef TRUE
72# define TRUE 1
73#endif
74#ifndef FALSE
75# define FALSE 0
76#endif
77#endif
78
79#ifndef offsetof
80// use offsetof from compiler if available for constexpr feature in cpp
81# if __IS_COMPILER_GCC__ || __IS_COMPILER_LLVM__
82# define offsetof(__type, __member) __builtin_offsetof(__type, __member)
83# else
84# define offsetof(__type, __member) (uintptr_t)(&(((__type *)0)->__member))
85# endif
86#endif
87
88// define max_align_t, can not depend on uintalu_t because of circular depoendency
89#if __IS_COMPILER_GCC__
90typedef struct {
91 long long __clang_max_align_nonce1
92 __attribute__((__aligned__(__alignof__(long long))));
93 long double __clang_max_align_nonce2
94 __attribute__((__aligned__(__alignof__(long double))));
96#elif __IS_COMPILER_LLVM__
97# if defined(__WIN__)
98typedef double max_align_t;
99# elif defined(__MACOS__)
100typedef long double max_align_t;
101# else
102typedef struct {
103 long long __clang_max_align_nonce1
104 __attribute__((__aligned__(__alignof__(long long))));
105 long double __clang_max_align_nonce2
106 __attribute__((__aligned__(__alignof__(long double))));
108# endif
109#else
110typedef long double max_align_t;
111#endif
112
113#if __IS_COMPILER_IAR__
114typedef void *nullptr_t;
115#endif
116
117#if defined(__PTRDIFF_TYPE__)
118typedef __PTRDIFF_TYPE__ ptrdiff_t;
119#elif defined(__WIN__)
120# if defined(__CPU_X86__)
121typedef unsigned int size_t;
122typedef int ptrdiff_t;
123typedef int intptr_t;
124typedef unsigned int uintptr_t;
125# elif defined(__CPU_X64__)
126typedef unsigned __int64 size_t;
127typedef __int64 ptrdiff_t;
128typedef __int64 intptr_t;
129typedef unsigned __int64 uintptr_t;
130# endif
131#else
132typedef long int ptrdiff_t;
133#endif
134
135#ifdef __cplusplus
136}
137
138# ifdef __WIN__
139namespace std {
140 typedef decltype(__nullptr) nullptr_t;
141}
142
143using ::std::nullptr_t;
144# endif
145#endif
146
147#endif
__attribute__((weak))
Definition handlers.c:10
long int ptrdiff_t
Definition stddef.h:132
long double max_align_t
Definition stddef.h:110
unsigned short wchar_t
Definition stddef.h:43
unsigned short wint_t
Definition stddef.h:49
unsigned int size_t
Definition types.h:54
Definition vsf_linux_glibcpp.cc:9
uint32_t uintptr_t
Definition stdint.h:38
int32_t intptr_t
Definition stdint.h:39
Generated from commit: vsfteam/vsf@91f710a