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