blob: 190413c6a25979e6b2234f9282ce4353d4a15981 [file] [log] [blame]
Stefan Reinauerda1ef022012-12-07 17:24:06 -08001#ifndef STDDEF_H
2#define STDDEF_H
Eric Biederman8ca8d762003-04-22 19:02:15 +00003
Aaron Durbindc9f5cd2015-09-08 13:34:43 -05004#include <commonlib/helpers.h>
5
Jacob Garber26979ca2021-06-06 19:56:14 -06006typedef __PTRDIFF_TYPE__ ptrdiff_t;
Stefan Reinauer0e740d32012-05-14 13:21:08 -07007typedef __SIZE_TYPE__ size_t;
Stefan Reinauerf8b36502013-05-02 14:02:28 -07008/* There is a GCC macro for a size_t type, but not
9 * for a ssize_t type. Below construct tricks GCC
10 * into making __SIZE_TYPE__ signed.
11 */
12#define unsigned signed
13typedef __SIZE_TYPE__ ssize_t;
14#undef unsigned
Eric Biederman8ca8d762003-04-22 19:02:15 +000015
Jacob Garber26979ca2021-06-06 19:56:14 -060016typedef __WCHAR_TYPE__ wchar_t;
17typedef __WINT_TYPE__ wint_t;
Eric Biederman8ca8d762003-04-22 19:02:15 +000018
Eric Biedermanb78c1972004-10-14 20:54:17 +000019#define NULL ((void *)0)
Eric Biederman8ca8d762003-04-22 19:02:15 +000020
Aaron Durbine4d7abc2017-04-16 22:05:36 -050021/* The devicetree data structures are only mutable in ramstage. All other
22 stages have a constant devicetree. */
Subrata Banik42c44c22019-05-15 20:27:04 +053023#if !ENV_PAYLOAD_LOADER
Aaron Durbine4d7abc2017-04-16 22:05:36 -050024#define DEVTREE_EARLY 1
Stefan Reinauer57879c92012-07-31 16:47:25 -070025#else
Aaron Durbine4d7abc2017-04-16 22:05:36 -050026#define DEVTREE_EARLY 0
27#endif
28
29#if DEVTREE_EARLY
30#define DEVTREE_CONST const
31#else
32#define DEVTREE_CONST
Stefan Reinauer57879c92012-07-31 16:47:25 -070033#endif
34
Kyösti Mälkki117cf2b2019-08-20 06:01:57 +030035#if ENV_STAGE_HAS_DATA_SECTION
36#define MAYBE_STATIC_NONZERO static
Julius Wernerdbe0df12014-06-06 16:10:56 -070037#else
Kyösti Mälkki117cf2b2019-08-20 06:01:57 +030038#define MAYBE_STATIC_NONZERO
39#endif
40
Patrick Georgiff8076d2016-01-27 08:18:16 +010041/* Provide a pointer to address 0 that thwarts any "accessing this is
42 * undefined behaviour and do whatever" trickery in compilers.
43 * Use when you _really_ need to read32(zeroptr) (ie. read address 0).
44 */
Patrick Georgic42b7862016-04-13 18:51:12 +020045extern char zeroptr[];
Patrick Georgiff8076d2016-01-27 08:18:16 +010046
Stefan Reinauerda1ef022012-12-07 17:24:06 -080047#endif /* STDDEF_H */