Software APIs
limits.h
Go to the documentation of this file.
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #ifndef OPENTITAN_SW_DEVICE_LIB_BASE_FREESTANDING_LIMITS_H_
6 #define OPENTITAN_SW_DEVICE_LIB_BASE_FREESTANDING_LIMITS_H_
7 
8 #include <stdint.h>
9 
10 /**
11  * @file
12  * @brief C library Sizes of integer types (Freestanding)
13  *
14  * This header implements the limits.h standard header, as required by C11 S4p6.
15  * This header is specified in detail in S7.10 and S5.2.4.2.1 of the same.
16  */
17 
18 #define SCHAR_MAX __SCHAR_MAX__ /**< @hideinitializer */
19 #define SHRT_MAX __SHRT_MAX__ /**< @hideinitializer */
20 #define INT_MAX __INT_MAX__ /**< @hideinitializer */
21 #define LONG_MAX __LONG_MAX__ /**< @hideinitializer */
22 #define LLONG_MAX __LONG_LONG_MAX__ /**< @hideinitializer */
23 
24 #define SCHAR_MIN (-__SCHAR_MAX__ - 1) /**< @hideinitializer */
25 #define SHRT_MIN (-__SHRT_MAX__ - 1) /**< @hideinitializer */
26 #define INT_MIN (-__INT_MAX__ - 1) /**< @hideinitializer */
27 #define LONG_MIN (-__LONG_MAX__ - 1L) /**< @hideinitializer */
28 #define LLONG_MIN (-__LONG_LONG_MAX__ - 1LL) /**< @hideinitializer */
29 
30 #define UCHAR_MAX (__SCHAR_MAX__ * 2 + 1) /**< @hideinitializer */
31 #define USHRT_MAX (__SHRT_MAX__ * 2 + 1) /**< @hideinitializer */
32 #define UINT_MAX (__INT_MAX__ * 2U + 1U) /**< @hideinitializer */
33 #define ULONG_MAX (__LONG_MAX__ * 2UL + 1UL) /**< @hideinitializer */
34 #define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL) /**< @hideinitializer */
35 
36 #define CHAR_BIT __CHAR_BIT__ /**< @hideinitializer */
37 #define MB_LEN_MAX (1) /**< @hideinitializer */
38 
39 #ifdef __CHAR_UNSIGNED__
40 #define CHAR_MIN (0) /**< @hideinitializer */
41 #define CHAR_MAX UCHAR_MAX /**< @hideinitializer */
42 #else
43 #define CHAR_MIN SCHAR_MIN /**< @hideinitializer */
44 #define CHAR_MAX SCHAR_MAX /**< @hideinitializer */
45 #endif
46 
47 #endif // OPENTITAN_SW_DEVICE_LIB_BASE_FREESTANDING_LIMITS_H_