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