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