/ src / include / stddef.h
stddef.h
 1  /* SPDX-License-Identifier: GPL-2.0-only */
 2  
 3  #ifndef STDDEF_H
 4  #define STDDEF_H
 5  
 6  #include <commonlib/helpers.h>
 7  
 8  typedef __PTRDIFF_TYPE__ ptrdiff_t;
 9  typedef __SIZE_TYPE__ size_t;
10  #define SIZE_MAX __SIZE_MAX__
11  /* There is a GCC macro for a size_t type, but not
12   * for a ssize_t type. Below construct tricks GCC
13   * into making __SIZE_TYPE__ signed.
14   */
15  #define unsigned signed
16  typedef __SIZE_TYPE__ ssize_t;
17  #undef unsigned
18  
19  typedef __WCHAR_TYPE__ wchar_t;
20  typedef __WINT_TYPE__ wint_t;
21  
22  #if __STDC_VERSION__ >= 202300L
23  #define NULL nullptr
24  #else
25  #define nullptr ((void *)0)
26  #define NULL ((void *)0)
27  #endif
28  
29  /* The devicetree data structures are only mutable in ramstage. All other
30     stages have a constant devicetree. */
31  #if !ENV_PAYLOAD_LOADER
32  #define DEVTREE_EARLY 1
33  #else
34  #define DEVTREE_EARLY 0
35  #endif
36  
37  #if DEVTREE_EARLY
38  #define DEVTREE_CONST const
39  #else
40  #define DEVTREE_CONST
41  #endif
42  
43  /* Provide a pointer to address 0 that thwarts any "accessing this is
44   * undefined behaviour and do whatever" trickery in compilers.
45   * Use when you _really_ need to read32(zeroptr) (ie. read address 0).
46   */
47  extern char zeroptr[];
48  
49  #endif /* STDDEF_H */