blob: b668b1aeb642ab759589171d96aa5baedc60af2a [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
Eric Biederman8ca8d762003-04-22 19:02:15 +00006typedef long ptrdiff_t;
Stefan Reinauer0e740d32012-05-14 13:21:08 -07007#ifndef __SIZE_TYPE__
8#define __SIZE_TYPE__ unsigned long
9#endif
10typedef __SIZE_TYPE__ size_t;
Stefan Reinauerf8b36502013-05-02 14:02:28 -070011/* 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
16typedef __SIZE_TYPE__ ssize_t;
17#undef unsigned
Eric Biederman8ca8d762003-04-22 19:02:15 +000018
19typedef int wchar_t;
20typedef unsigned int wint_t;
21
Eric Biedermanb78c1972004-10-14 20:54:17 +000022#define NULL ((void *)0)
Eric Biederman8ca8d762003-04-22 19:02:15 +000023
Aaron Durbine4d7abc2017-04-16 22:05:36 -050024/* The devicetree data structures are only mutable in ramstage. All other
25 stages have a constant devicetree. */
Subrata Banik42c44c22019-05-15 20:27:04 +053026#if !ENV_PAYLOAD_LOADER
Aaron Durbine4d7abc2017-04-16 22:05:36 -050027#define DEVTREE_EARLY 1
Stefan Reinauer57879c92012-07-31 16:47:25 -070028#else
Aaron Durbine4d7abc2017-04-16 22:05:36 -050029#define DEVTREE_EARLY 0
30#endif
31
32#if DEVTREE_EARLY
33#define DEVTREE_CONST const
34#else
35#define DEVTREE_CONST
Stefan Reinauer57879c92012-07-31 16:47:25 -070036#endif
37
Kyösti Mälkki117cf2b2019-08-20 06:01:57 +030038#if ENV_STAGE_HAS_DATA_SECTION
39#define MAYBE_STATIC_NONZERO static
Julius Wernerdbe0df12014-06-06 16:10:56 -070040#else
Kyösti Mälkki117cf2b2019-08-20 06:01:57 +030041#define MAYBE_STATIC_NONZERO
42#endif
43
Patrick Georgiff8076d2016-01-27 08:18:16 +010044/* Provide a pointer to address 0 that thwarts any "accessing this is
45 * undefined behaviour and do whatever" trickery in compilers.
46 * Use when you _really_ need to read32(zeroptr) (ie. read address 0).
47 */
Patrick Georgic42b7862016-04-13 18:51:12 +020048extern char zeroptr[];
Patrick Georgiff8076d2016-01-27 08:18:16 +010049
Stefan Reinauerda1ef022012-12-07 17:24:06 -080050#endif /* STDDEF_H */