blob: 82d38c39972f8147d30d487833c10af6e6748700 [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;
Patrick Georgi69bbe262023-10-06 19:54:28 +020010#define SIZE_MAX __SIZE_MAX__
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
Jacob Garber26979ca2021-06-06 19:56:14 -060019typedef __WCHAR_TYPE__ wchar_t;
20typedef __WINT_TYPE__ wint_t;
Eric Biederman8ca8d762003-04-22 19:02:15 +000021
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
Patrick Georgiff8076d2016-01-27 08:18:16 +010038/* Provide a pointer to address 0 that thwarts any "accessing this is
39 * undefined behaviour and do whatever" trickery in compilers.
40 * Use when you _really_ need to read32(zeroptr) (ie. read address 0).
41 */
Patrick Georgic42b7862016-04-13 18:51:12 +020042extern char zeroptr[];
Patrick Georgiff8076d2016-01-27 08:18:16 +010043
Stefan Reinauerda1ef022012-12-07 17:24:06 -080044#endif /* STDDEF_H */