Stefan Reinauer | da1ef02 | 2012-12-07 17:24:06 -0800 | [diff] [blame] | 1 | #ifndef STDDEF_H |
| 2 | #define STDDEF_H |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 3 | |
Aaron Durbin | dc9f5cd | 2015-09-08 13:34:43 -0500 | [diff] [blame] | 4 | #include <commonlib/helpers.h> |
| 5 | |
Jacob Garber | 26979ca | 2021-06-06 19:56:14 -0600 | [diff] [blame] | 6 | typedef __PTRDIFF_TYPE__ ptrdiff_t; |
Stefan Reinauer | 0e740d3 | 2012-05-14 13:21:08 -0700 | [diff] [blame] | 7 | typedef __SIZE_TYPE__ size_t; |
Stefan Reinauer | f8b3650 | 2013-05-02 14:02:28 -0700 | [diff] [blame] | 8 | /* 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 |
| 13 | typedef __SIZE_TYPE__ ssize_t; |
| 14 | #undef unsigned |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 15 | |
Jacob Garber | 26979ca | 2021-06-06 19:56:14 -0600 | [diff] [blame] | 16 | typedef __WCHAR_TYPE__ wchar_t; |
| 17 | typedef __WINT_TYPE__ wint_t; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 18 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 19 | #define NULL ((void *)0) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 20 | |
Aaron Durbin | e4d7abc | 2017-04-16 22:05:36 -0500 | [diff] [blame] | 21 | /* The devicetree data structures are only mutable in ramstage. All other |
| 22 | stages have a constant devicetree. */ |
Subrata Banik | 42c44c2 | 2019-05-15 20:27:04 +0530 | [diff] [blame] | 23 | #if !ENV_PAYLOAD_LOADER |
Aaron Durbin | e4d7abc | 2017-04-16 22:05:36 -0500 | [diff] [blame] | 24 | #define DEVTREE_EARLY 1 |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 25 | #else |
Aaron Durbin | e4d7abc | 2017-04-16 22:05:36 -0500 | [diff] [blame] | 26 | #define DEVTREE_EARLY 0 |
| 27 | #endif |
| 28 | |
| 29 | #if DEVTREE_EARLY |
| 30 | #define DEVTREE_CONST const |
| 31 | #else |
| 32 | #define DEVTREE_CONST |
Stefan Reinauer | 57879c9 | 2012-07-31 16:47:25 -0700 | [diff] [blame] | 33 | #endif |
| 34 | |
Kyösti Mälkki | 117cf2b | 2019-08-20 06:01:57 +0300 | [diff] [blame] | 35 | #if ENV_STAGE_HAS_DATA_SECTION |
| 36 | #define MAYBE_STATIC_NONZERO static |
Julius Werner | dbe0df1 | 2014-06-06 16:10:56 -0700 | [diff] [blame] | 37 | #else |
Kyösti Mälkki | 117cf2b | 2019-08-20 06:01:57 +0300 | [diff] [blame] | 38 | #define MAYBE_STATIC_NONZERO |
| 39 | #endif |
| 40 | |
Patrick Georgi | ff8076d | 2016-01-27 08:18:16 +0100 | [diff] [blame] | 41 | /* 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 Georgi | c42b786 | 2016-04-13 18:51:12 +0200 | [diff] [blame] | 45 | extern char zeroptr[]; |
Patrick Georgi | ff8076d | 2016-01-27 08:18:16 +0100 | [diff] [blame] | 46 | |
Stefan Reinauer | da1ef02 | 2012-12-07 17:24:06 -0800 | [diff] [blame] | 47 | #endif /* STDDEF_H */ |