blob: 2667f66296adbc87d1b189892c95b305d19224ab [file] [log] [blame]
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#ifndef OPENTITAN_SW_DEVICE_LIB_BASE_FREESTANDING_STDDEF_H_
#define OPENTITAN_SW_DEVICE_LIB_BASE_FREESTANDING_STDDEF_H_
#include <stdalign.h>
#include <stdint.h>
/**
* This header implements the stdint.h standard header, as required by C11 S4p6.
* This header is specified in detail in S7.19 of the same.
*
* See https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md
* for the RISC-V specifics this file conforms to.
*/
// GCC's built-in defines do not include a type with the maximum alignment, but
// does include a define with the maximum alignment value. Since the only
// requirement of |max_align_t| is that it be some type such that its alignment
// is maximal, we simply use a one-byte struct whose alignment is forced to be
// the maximum.
typedef struct { alignas(__BIGGEST_ALIGNMENT__) uint8_t __nonce; } max_align_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __SIZE_TYPE__ size_t;
typedef __WCHAR_TYPE__ wchar_t;
#define NULL ((void *)0)
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif // OPENTITAN_SW_DEVICE_LIB_BASE_FREESTANDING_STDDEF_H_