xref: /optee_os/lib/libutils/isoc/include/limits.h (revision a83aec29b778db0b01b3e74ff69122f930bed050)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, STMicroelectronics International N.V.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 #ifndef LIMITS_H
29 #define LIMITS_H
30 
31 #define CHAR_BIT __CHAR_BIT__
32 
33 #ifdef __CHAR_UNSIGNED__
34 #define CHAR_MAX UCHAR_MAX
35 #define CHAR_MIN 0
36 #else
37 #define CHAR_MAX SCHAR_MAX
38 #define CHAR_MIN SCHAR_MIN
39 #endif
40 
41 #define INT_MAX __INT_MAX__
42 #define INT_MIN (-INT_MAX - 1)
43 
44 #define LONG_MAX __LONG_MAX__
45 #define LONG_MIN (-LONG_MAX - 1L)
46 
47 #define LLONG_MAX __LONG_LONG_MAX__
48 #define LLONG_MIN (-LLONG_MAX - 1LL)
49 
50 #define MB_LEN_MAX 1
51 
52 #define SCHAR_MAX __SCHAR_MAX__
53 #define SCHAR_MIN (-SCHAR_MAX - 1)
54 
55 #define SHRT_MAX __SHRT_MAX__
56 #define SHRT_MIN (-SHRT_MAX - 1)
57 
58 #if __SCHAR_MAX__ == __INT_MAX__
59 #define UCHAR_MAX (SCHAR_MAX * 2U + 1U)
60 #else
61 #define UCHAR_MAX (SCHAR_MAX * 2 + 1)
62 #endif
63 
64 #if __SHRT_MAX__ == __INT_MAX__
65 #define USHRT_MAX (SHRT_MAX * 2U + 1U)
66 #else
67 #define USHRT_MAX (SHRT_MAX * 2 + 1)
68 #endif
69 
70 #define UINT_MAX (INT_MAX * 2U + 1U)
71 
72 #define ULONG_MAX (LONG_MAX * 2UL + 1UL)
73 #define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
74 
75 #endif /* LIMITS_H */
76