blob: 9a4f35fdb4facc2e69ffbbc21726686d218a35fe [file] [log] [blame]
Harry Liebel0f702c62013-12-17 18:19:04 +00001/*-
2 * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
3 * Copyright (c) 2001 The NetBSD Foundation, Inc.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Klaus Klein.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $FreeBSD$
31 */
32
Soby Mathewa0fedc42016-06-16 14:52:04 +010033/*
34 * Portions copyright (c) 2016, ARM Limited and Contributors.
35 * All rights reserved.
36 */
37
Harry Liebel0f702c62013-12-17 18:19:04 +000038#ifndef _MACHINE__STDINT_H_
39#define _MACHINE__STDINT_H_
40
41#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
42
43#define INT8_C(c) (c)
44#define INT16_C(c) (c)
45#define INT32_C(c) (c)
Soby Mathewa0fedc42016-06-16 14:52:04 +010046#define INT64_C(c) (c ## LL)
Harry Liebel0f702c62013-12-17 18:19:04 +000047
48#define UINT8_C(c) (c)
49#define UINT16_C(c) (c)
50#define UINT32_C(c) (c ## U)
Soby Mathewa0fedc42016-06-16 14:52:04 +010051#define UINT64_C(c) (c ## ULL)
Harry Liebel0f702c62013-12-17 18:19:04 +000052
53#define INTMAX_C(c) INT64_C(c)
54#define UINTMAX_C(c) UINT64_C(c)
55
56#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
57
58#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
59
60/*
61 * ISO/IEC 9899:1999
62 * 7.18.2.1 Limits of exact-width integer types
63 */
64/* Minimum values of exact-width signed integer types. */
65#define INT8_MIN (-0x7f-1)
66#define INT16_MIN (-0x7fff-1)
67#define INT32_MIN (-0x7fffffff-1)
Soby Mathewa0fedc42016-06-16 14:52:04 +010068#define INT64_MIN (-0x7fffffffffffffffLL-1)
Harry Liebel0f702c62013-12-17 18:19:04 +000069
70/* Maximum values of exact-width signed integer types. */
71#define INT8_MAX 0x7f
72#define INT16_MAX 0x7fff
73#define INT32_MAX 0x7fffffff
Soby Mathewa0fedc42016-06-16 14:52:04 +010074#define INT64_MAX 0x7fffffffffffffffLL
Harry Liebel0f702c62013-12-17 18:19:04 +000075
76/* Maximum values of exact-width unsigned integer types. */
77#define UINT8_MAX 0xff
78#define UINT16_MAX 0xffff
79#define UINT32_MAX 0xffffffffU
Soby Mathewa0fedc42016-06-16 14:52:04 +010080#define UINT64_MAX 0xffffffffffffffffULL
Harry Liebel0f702c62013-12-17 18:19:04 +000081
82/*
83 * ISO/IEC 9899:1999
84 * 7.18.2.2 Limits of minimum-width integer types
85 */
86/* Minimum values of minimum-width signed integer types. */
87#define INT_LEAST8_MIN INT8_MIN
88#define INT_LEAST16_MIN INT16_MIN
89#define INT_LEAST32_MIN INT32_MIN
90#define INT_LEAST64_MIN INT64_MIN
91
92/* Maximum values of minimum-width signed integer types. */
93#define INT_LEAST8_MAX INT8_MAX
94#define INT_LEAST16_MAX INT16_MAX
95#define INT_LEAST32_MAX INT32_MAX
96#define INT_LEAST64_MAX INT64_MAX
97
98/* Maximum values of minimum-width unsigned integer types. */
99#define UINT_LEAST8_MAX UINT8_MAX
100#define UINT_LEAST16_MAX UINT16_MAX
101#define UINT_LEAST32_MAX UINT32_MAX
102#define UINT_LEAST64_MAX UINT64_MAX
103
104/*
105 * ISO/IEC 9899:1999
106 * 7.18.2.3 Limits of fastest minimum-width integer types
107 */
108/* Minimum values of fastest minimum-width signed integer types. */
109#define INT_FAST8_MIN INT32_MIN
110#define INT_FAST16_MIN INT32_MIN
111#define INT_FAST32_MIN INT32_MIN
112#define INT_FAST64_MIN INT64_MIN
113
114/* Maximum values of fastest minimum-width signed integer types. */
115#define INT_FAST8_MAX INT32_MAX
116#define INT_FAST16_MAX INT32_MAX
117#define INT_FAST32_MAX INT32_MAX
118#define INT_FAST64_MAX INT64_MAX
119
120/* Maximum values of fastest minimum-width unsigned integer types. */
121#define UINT_FAST8_MAX UINT32_MAX
122#define UINT_FAST16_MAX UINT32_MAX
123#define UINT_FAST32_MAX UINT32_MAX
124#define UINT_FAST64_MAX UINT64_MAX
125
126/*
127 * ISO/IEC 9899:1999
128 * 7.18.2.4 Limits of integer types capable of holding object pointers
129 */
130#define INTPTR_MIN INT64_MIN
131#define INTPTR_MAX INT64_MAX
132#define UINTPTR_MAX UINT64_MAX
133
134/*
135 * ISO/IEC 9899:1999
136 * 7.18.2.5 Limits of greatest-width integer types
137 */
138#define INTMAX_MIN INT64_MIN
139#define INTMAX_MAX INT64_MAX
140#define UINTMAX_MAX UINT64_MAX
141
142/*
143 * ISO/IEC 9899:1999
144 * 7.18.3 Limits of other integer types
145 */
146/* Limits of ptrdiff_t. */
147#define PTRDIFF_MIN INT64_MIN
148#define PTRDIFF_MAX INT64_MAX
149
150/* Limits of sig_atomic_t. */
151#define SIG_ATOMIC_MIN INT32_MIN
152#define SIG_ATOMIC_MAX INT32_MAX
153
154/* Limit of size_t. */
155#define SIZE_MAX UINT64_MAX
156
157#ifndef WCHAR_MIN /* Also possibly defined in <wchar.h> */
158/* Limits of wchar_t. */
159#define WCHAR_MIN INT32_MIN
160#define WCHAR_MAX INT32_MAX
161#endif
162
163/* Limits of wint_t. */
164#define WINT_MIN INT32_MIN
165#define WINT_MAX INT32_MAX
166
167#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
168
169#endif /* !_MACHINE__STDINT_H_ */