blob: e30b05f6720ecebdee641c84e755227ac9becc5d [file] [log] [blame]
Martin Roth239b5df2022-07-26 22:18:26 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
Stefan Reinauerda1ef022012-12-07 17:24:06 -08003#ifndef STDDEF_H
4#define STDDEF_H
Eric Biederman8ca8d762003-04-22 19:02:15 +00005
Aaron Durbindc9f5cd2015-09-08 13:34:43 -05006#include <commonlib/helpers.h>
7
Jacob Garber26979ca2021-06-06 19:56:14 -06008typedef __PTRDIFF_TYPE__ ptrdiff_t;
Stefan Reinauer0e740d32012-05-14 13:21:08 -07009typedef __SIZE_TYPE__ size_t;
Stefan Reinauerf8b36502013-05-02 14:02:28 -070010/* 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
15typedef __SIZE_TYPE__ ssize_t;
16#undef unsigned
Eric Biederman8ca8d762003-04-22 19:02:15 +000017
Jacob Garber26979ca2021-06-06 19:56:14 -060018typedef __WCHAR_TYPE__ wchar_t;
19typedef __WINT_TYPE__ wint_t;
Eric Biederman8ca8d762003-04-22 19:02:15 +000020
Eric Biedermanb78c1972004-10-14 20:54:17 +000021#define NULL ((void *)0)
Eric Biederman8ca8d762003-04-22 19:02:15 +000022
Aaron Durbine4d7abc2017-04-16 22:05:36 -050023/* The devicetree data structures are only mutable in ramstage. All other
24 stages have a constant devicetree. */
Subrata Banik42c44c22019-05-15 20:27:04 +053025#if !ENV_PAYLOAD_LOADER
Aaron Durbine4d7abc2017-04-16 22:05:36 -050026#define DEVTREE_EARLY 1
Stefan Reinauer57879c92012-07-31 16:47:25 -070027#else
Aaron Durbine4d7abc2017-04-16 22:05:36 -050028#define DEVTREE_EARLY 0
29#endif
30
31#if DEVTREE_EARLY
32#define DEVTREE_CONST const
33#else
34#define DEVTREE_CONST
Stefan Reinauer57879c92012-07-31 16:47:25 -070035#endif
36
Arthur Heymans6acc05e2022-05-12 18:01:13 +020037#if ENV_HAS_DATA_SECTION
Kyösti Mälkki117cf2b2019-08-20 06:01:57 +030038#define MAYBE_STATIC_NONZERO static
Julius Wernerdbe0df12014-06-06 16:10:56 -070039#else
Kyösti Mälkki117cf2b2019-08-20 06:01:57 +030040#define MAYBE_STATIC_NONZERO
41#endif
42
Patrick Georgiff8076d2016-01-27 08:18:16 +010043/* 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 Georgic42b7862016-04-13 18:51:12 +020047extern char zeroptr[];
Patrick Georgiff8076d2016-01-27 08:18:16 +010048
Stefan Reinauerda1ef022012-12-07 17:24:06 -080049#endif /* STDDEF_H */