1178172Simp/*-
2178172Simp * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
3178172Simp * Copyright (c) 2001 The NetBSD Foundation, Inc.
4178172Simp * All rights reserved.
5178172Simp *
6178172Simp * This code is derived from software contributed to The NetBSD Foundation
7178172Simp * by Klaus Klein.
8178172Simp *
9178172Simp * Redistribution and use in source and binary forms, with or without
10178172Simp * modification, are permitted provided that the following conditions
11178172Simp * are met:
12178172Simp * 1. Redistributions of source code must retain the above copyright
13178172Simp *    notice, this list of conditions and the following disclaimer.
14178172Simp * 2. Redistributions in binary form must reproduce the above copyright
15178172Simp *    notice, this list of conditions and the following disclaimer in the
16178172Simp *    documentation and/or other materials provided with the distribution.
17178172Simp * 3. All advertising materials mentioning features or use of this software
18178172Simp *    must display the following acknowledgement:
19178172Simp *        This product includes software developed by the NetBSD
20178172Simp *        Foundation, Inc. and its contributors.
21178172Simp * 4. Neither the name of The NetBSD Foundation nor the names of its
22178172Simp *    contributors may be used to endorse or promote products derived
23178172Simp *    from this software without specific prior written permission.
24178172Simp *
25178172Simp * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26178172Simp * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27178172Simp * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28178172Simp * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29178172Simp * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30178172Simp * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31178172Simp * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32178172Simp * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33178172Simp * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34178172Simp * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35178172Simp * POSSIBILITY OF SUCH DAMAGE.
36178172Simp *
37178172Simp *	from: src/sys/i386/include/_stdint.h,v 1.2 2004/05/18 16:04:57 stefanf
38178172Simp * $FreeBSD$
39178172Simp */
40178172Simp
41178172Simp#ifndef _MACHINE__STDINT_H_
42178172Simp#define	_MACHINE__STDINT_H_
43178172Simp
44178172Simp#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
45178172Simp
46178172Simp#define	INT8_C(c)		(c)
47178172Simp#define	INT16_C(c)		(c)
48178172Simp#define	INT32_C(c)		(c)
49178172Simp
50178172Simp#define	UINT8_C(c)		(c)
51178172Simp#define	UINT16_C(c)		(c)
52178172Simp#define	UINT32_C(c)		(c ## U)
53217147Stijl
54218266Stijl#ifdef __mips_n64
55217147Stijl#define	INT64_C(c)		(c ## L)
56210606Sjchandra#define	UINT64_C(c)		(c ## UL)
57210606Sjchandra#else
58217147Stijl#define	INT64_C(c)		(c ## LL)
59178172Simp#define	UINT64_C(c)		(c ## ULL)
60210606Sjchandra#endif
61178172Simp
62217147Stijl#define	INTMAX_C(c)		INT64_C(c)
63217147Stijl#define	UINTMAX_C(c)		UINT64_C(c)
64178172Simp
65178172Simp#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */
66178172Simp
67178172Simp#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
68178172Simp
69255194Simp#ifndef __INT64_C
70229496Sandreast#ifdef __mips_n64
71229496Sandreast#define __INT64_C(c)              (c ## L)
72229496Sandreast#define __UINT64_C(c)             (c ## UL)
73229496Sandreast#else
74229496Sandreast#define __INT64_C(c)              (c ## LL)
75229496Sandreast#define __UINT64_C(c)             (c ## ULL)
76229496Sandreast#endif
77255194Simp#endif
78229496Sandreast
79178172Simp/*
80178172Simp * ISO/IEC 9899:1999
81178172Simp * 7.18.2.1 Limits of exact-width integer types
82178172Simp */
83178172Simp/* Minimum values of exact-width signed integer types. */
84178172Simp#define	INT8_MIN	(-0x7f-1)
85178172Simp#define	INT16_MIN	(-0x7fff-1)
86178172Simp#define	INT32_MIN	(-0x7fffffff-1)
87229496Sandreast#define	INT64_MIN	(-__INT64_C(0x7fffffffffffffff)-1)
88178172Simp
89178172Simp/* Maximum values of exact-width signed integer types. */
90178172Simp#define	INT8_MAX	0x7f
91178172Simp#define	INT16_MAX	0x7fff
92178172Simp#define	INT32_MAX	0x7fffffff
93229496Sandreast#define	INT64_MAX	__INT64_C(0x7fffffffffffffff)
94178172Simp
95178172Simp/* Maximum values of exact-width unsigned integer types. */
96178172Simp#define	UINT8_MAX	0xff
97178172Simp#define	UINT16_MAX	0xffff
98217147Stijl#define	UINT32_MAX	0xffffffff
99229496Sandreast#define	UINT64_MAX	__UINT64_C(0xffffffffffffffff)
100178172Simp
101178172Simp/*
102178172Simp * ISO/IEC 9899:1999
103178172Simp * 7.18.2.2  Limits of minimum-width integer types
104178172Simp */
105178172Simp/* Minimum values of minimum-width signed integer types. */
106178172Simp#define	INT_LEAST8_MIN	INT8_MIN
107178172Simp#define	INT_LEAST16_MIN	INT16_MIN
108178172Simp#define	INT_LEAST32_MIN	INT32_MIN
109178172Simp#define	INT_LEAST64_MIN	INT64_MIN
110178172Simp
111178172Simp/* Maximum values of minimum-width signed integer types. */
112178172Simp#define	INT_LEAST8_MAX	INT8_MAX
113178172Simp#define	INT_LEAST16_MAX	INT16_MAX
114178172Simp#define	INT_LEAST32_MAX	INT32_MAX
115178172Simp#define	INT_LEAST64_MAX	INT64_MAX
116178172Simp
117178172Simp/* Maximum values of minimum-width unsigned integer types. */
118178172Simp#define	UINT_LEAST8_MAX	 UINT8_MAX
119178172Simp#define	UINT_LEAST16_MAX UINT16_MAX
120178172Simp#define	UINT_LEAST32_MAX UINT32_MAX
121178172Simp#define	UINT_LEAST64_MAX UINT64_MAX
122178172Simp
123178172Simp/*
124178172Simp * ISO/IEC 9899:1999
125178172Simp * 7.18.2.3  Limits of fastest minimum-width integer types
126178172Simp */
127178172Simp/* Minimum values of fastest minimum-width signed integer types. */
128178172Simp#define	INT_FAST8_MIN	INT32_MIN
129178172Simp#define	INT_FAST16_MIN	INT32_MIN
130178172Simp#define	INT_FAST32_MIN	INT32_MIN
131178172Simp#define	INT_FAST64_MIN	INT64_MIN
132178172Simp
133178172Simp/* Maximum values of fastest minimum-width signed integer types. */
134178172Simp#define	INT_FAST8_MAX	INT32_MAX
135178172Simp#define	INT_FAST16_MAX	INT32_MAX
136178172Simp#define	INT_FAST32_MAX	INT32_MAX
137178172Simp#define	INT_FAST64_MAX	INT64_MAX
138178172Simp
139178172Simp/* Maximum values of fastest minimum-width unsigned integer types. */
140178172Simp#define	UINT_FAST8_MAX	UINT32_MAX
141178172Simp#define	UINT_FAST16_MAX	UINT32_MAX
142178172Simp#define	UINT_FAST32_MAX	UINT32_MAX
143178172Simp#define	UINT_FAST64_MAX	UINT64_MAX
144178172Simp
145178172Simp/*
146178172Simp * ISO/IEC 9899:1999
147178172Simp * 7.18.2.4  Limits of integer types capable of holding object pointers
148178172Simp */
149218266Stijl#ifdef __mips_n64
150210606Sjchandra#define	INTPTR_MIN	INT64_MIN
151210606Sjchandra#define	INTPTR_MAX	INT64_MAX
152210606Sjchandra#define	UINTPTR_MAX	UINT64_MAX
153210606Sjchandra#else
154178172Simp#define	INTPTR_MIN	INT32_MIN
155178172Simp#define	INTPTR_MAX	INT32_MAX
156178172Simp#define	UINTPTR_MAX	UINT32_MAX
157210606Sjchandra#endif
158178172Simp
159178172Simp/*
160178172Simp * ISO/IEC 9899:1999
161178172Simp * 7.18.2.5  Limits of greatest-width integer types
162178172Simp */
163178172Simp#define	INTMAX_MIN	INT64_MIN
164178172Simp#define	INTMAX_MAX	INT64_MAX
165178172Simp#define	UINTMAX_MAX	UINT64_MAX
166178172Simp
167178172Simp/*
168178172Simp * ISO/IEC 9899:1999
169178172Simp * 7.18.3  Limits of other integer types
170178172Simp */
171218266Stijl#ifdef __mips_n64
172178172Simp/* Limits of ptrdiff_t. */
173210606Sjchandra#define	PTRDIFF_MIN	INT64_MIN
174210606Sjchandra#define	PTRDIFF_MAX	INT64_MAX
175217147Stijl
176217147Stijl/* Limit of size_t. */
177217147Stijl#define	SIZE_MAX	UINT64_MAX
178210606Sjchandra#else
179217147Stijl/* Limits of ptrdiff_t. */
180178172Simp#define	PTRDIFF_MIN	INT32_MIN
181178172Simp#define	PTRDIFF_MAX	INT32_MAX
182217147Stijl
183217147Stijl/* Limit of size_t. */
184217147Stijl#define	SIZE_MAX	UINT32_MAX
185210606Sjchandra#endif
186178172Simp
187178172Simp/* Limits of sig_atomic_t. */
188178172Simp#define	SIG_ATOMIC_MIN	INT32_MIN
189178172Simp#define	SIG_ATOMIC_MAX	INT32_MAX
190178172Simp
191178172Simp/* Limits of wint_t. */
192178172Simp#define	WINT_MIN	INT32_MIN
193178172Simp#define	WINT_MAX	INT32_MAX
194178172Simp
195178172Simp#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
196178172Simp
197178172Simp#endif /* !_MACHINE__STDINT_H_ */
198