17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
227c478bdstevel@tonic-gate/*
23ba3594bGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24ba3594bGarrett D'Amore *
257c478bdstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
267c478bdstevel@tonic-gate * Use is subject to license terms.
277c478bdstevel@tonic-gate */
287c478bdstevel@tonic-gate
297c478bdstevel@tonic-gate#ifndef _SYS_INT_TYPES_H
307c478bdstevel@tonic-gate#define	_SYS_INT_TYPES_H
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate/*
337c478bdstevel@tonic-gate * This file, <sys/int_types.h>, is part of the Sun Microsystems implementation
347c478bdstevel@tonic-gate * of <inttypes.h> defined in the ISO C standard, ISO/IEC 9899:1999
357c478bdstevel@tonic-gate * Programming language - C.
367c478bdstevel@tonic-gate *
377c478bdstevel@tonic-gate * Programs/Modules should not directly include this file.  Access to the
387c478bdstevel@tonic-gate * types defined in this file should be through the inclusion of one of the
397c478bdstevel@tonic-gate * following files:
407c478bdstevel@tonic-gate *
417c478bdstevel@tonic-gate *	<sys/types.h>		Provides only the "_t" types defined in this
427c478bdstevel@tonic-gate *				file which is a subset of the contents of
437c478bdstevel@tonic-gate *				<inttypes.h>.  (This can be appropriate for
447c478bdstevel@tonic-gate *				all programs/modules except those claiming
457c478bdstevel@tonic-gate *				ANSI-C conformance.)
467c478bdstevel@tonic-gate *
477c478bdstevel@tonic-gate *	<sys/inttypes.h>	Provides the Kernel and Driver appropriate
487c478bdstevel@tonic-gate *				components of <inttypes.h>.
497c478bdstevel@tonic-gate *
507c478bdstevel@tonic-gate *	<inttypes.h>		For use by applications.
517c478bdstevel@tonic-gate *
527c478bdstevel@tonic-gate * See these files for more details.
537c478bdstevel@tonic-gate */
547c478bdstevel@tonic-gate
557c478bdstevel@tonic-gate#include <sys/feature_tests.h>
567c478bdstevel@tonic-gate
577c478bdstevel@tonic-gate#ifdef __cplusplus
587c478bdstevel@tonic-gateextern "C" {
597c478bdstevel@tonic-gate#endif
607c478bdstevel@tonic-gate
617c478bdstevel@tonic-gate/*
627c478bdstevel@tonic-gate * Basic / Extended integer types
637c478bdstevel@tonic-gate *
647c478bdstevel@tonic-gate * The following defines the basic fixed-size integer types.
657c478bdstevel@tonic-gate *
667c478bdstevel@tonic-gate * Implementations are free to typedef them to Standard C integer types or
677c478bdstevel@tonic-gate * extensions that they support. If an implementation does not support one
687c478bdstevel@tonic-gate * of the particular integer data types below, then it should not define the
697c478bdstevel@tonic-gate * typedefs and macros corresponding to that data type.  Note that int8_t
707c478bdstevel@tonic-gate * is not defined in -Xs mode on ISAs for which the ABI specifies "char"
717c478bdstevel@tonic-gate * as an unsigned entity because there is no way to define an eight bit
727c478bdstevel@tonic-gate * signed integral.
737c478bdstevel@tonic-gate */
747c478bdstevel@tonic-gate#if defined(_CHAR_IS_SIGNED)
757c478bdstevel@tonic-gatetypedef char			int8_t;
767c478bdstevel@tonic-gate#else
777c478bdstevel@tonic-gatetypedef signed char		int8_t;
787c478bdstevel@tonic-gate#endif
797c478bdstevel@tonic-gatetypedef short			int16_t;
807c478bdstevel@tonic-gatetypedef int			int32_t;
817c478bdstevel@tonic-gate#ifdef	_LP64
827c478bdstevel@tonic-gate#define	_INT64_TYPE
837c478bdstevel@tonic-gatetypedef long			int64_t;
847c478bdstevel@tonic-gate#else	/* _ILP32 */
857c478bdstevel@tonic-gate#if defined(_LONGLONG_TYPE)
867c478bdstevel@tonic-gate#define	_INT64_TYPE
877c478bdstevel@tonic-gatetypedef	long long		int64_t;
887c478bdstevel@tonic-gate#endif
897c478bdstevel@tonic-gate#endif
907c478bdstevel@tonic-gate
917c478bdstevel@tonic-gatetypedef unsigned char		uint8_t;
927c478bdstevel@tonic-gatetypedef unsigned short		uint16_t;
937c478bdstevel@tonic-gatetypedef unsigned int		uint32_t;
947c478bdstevel@tonic-gate#ifdef	_LP64
957c478bdstevel@tonic-gatetypedef unsigned long		uint64_t;
967c478bdstevel@tonic-gate#else	/* _ILP32 */
977c478bdstevel@tonic-gate#if defined(_LONGLONG_TYPE)
987c478bdstevel@tonic-gatetypedef unsigned long long	uint64_t;
997c478bdstevel@tonic-gate#endif
1007c478bdstevel@tonic-gate#endif
1017c478bdstevel@tonic-gate
1027c478bdstevel@tonic-gate/*
1037c478bdstevel@tonic-gate * intmax_t and uintmax_t are to be the longest (in number of bits) signed
1047c478bdstevel@tonic-gate * and unsigned integer types supported by the implementation.
1057c478bdstevel@tonic-gate */
1067c478bdstevel@tonic-gate#if defined(_INT64_TYPE)
1077c478bdstevel@tonic-gatetypedef int64_t			intmax_t;
1087c478bdstevel@tonic-gatetypedef uint64_t		uintmax_t;
1097c478bdstevel@tonic-gate#else
1107c478bdstevel@tonic-gatetypedef int32_t			intmax_t;
1117c478bdstevel@tonic-gatetypedef uint32_t		uintmax_t;
1127c478bdstevel@tonic-gate#endif
1137c478bdstevel@tonic-gate
1147c478bdstevel@tonic-gate/*
1157c478bdstevel@tonic-gate * intptr_t and uintptr_t are signed and unsigned integer types large enough
1167c478bdstevel@tonic-gate * to hold any data pointer; that is, data pointers can be assigned into or
1177c478bdstevel@tonic-gate * from these integer types without losing precision.
1187c478bdstevel@tonic-gate */
1197c478bdstevel@tonic-gate#if defined(_LP64) || defined(_I32LPx)
1207c478bdstevel@tonic-gatetypedef long			intptr_t;
1217c478bdstevel@tonic-gatetypedef unsigned long		uintptr_t;
1227c478bdstevel@tonic-gate#else
1237c478bdstevel@tonic-gatetypedef	int			intptr_t;
1247c478bdstevel@tonic-gatetypedef	unsigned int		uintptr_t;
1257c478bdstevel@tonic-gate#endif
1267c478bdstevel@tonic-gate
1277c478bdstevel@tonic-gate/*
1287c478bdstevel@tonic-gate * The following define the fastest integer types that can hold the
1297c478bdstevel@tonic-gate * specified number of bits.
1307c478bdstevel@tonic-gate */
1317c478bdstevel@tonic-gate#if defined(_CHAR_IS_SIGNED)
1327c478bdstevel@tonic-gatetypedef char			int_fast8_t;
1337c478bdstevel@tonic-gate#else
1347c478bdstevel@tonic-gatetypedef signed char		int_fast8_t;
1357c478bdstevel@tonic-gate#endif
1367c478bdstevel@tonic-gatetypedef int			int_fast16_t;
1377c478bdstevel@tonic-gatetypedef int			int_fast32_t;
1387c478bdstevel@tonic-gate#ifdef	_LP64
1397c478bdstevel@tonic-gatetypedef long			int_fast64_t;
1407c478bdstevel@tonic-gate#else	/* _ILP32 */
1417c478bdstevel@tonic-gate#if defined(_LONGLONG_TYPE)
1427c478bdstevel@tonic-gatetypedef long long		int_fast64_t;
1437c478bdstevel@tonic-gate#endif
1447c478bdstevel@tonic-gate#endif
1457c478bdstevel@tonic-gate
1467c478bdstevel@tonic-gatetypedef unsigned char		uint_fast8_t;
1477c478bdstevel@tonic-gatetypedef unsigned int		uint_fast16_t;
1487c478bdstevel@tonic-gatetypedef unsigned int		uint_fast32_t;
1497c478bdstevel@tonic-gate#ifdef	_LP64
1507c478bdstevel@tonic-gatetypedef unsigned long		uint_fast64_t;
1517c478bdstevel@tonic-gate#else	/* _ILP32 */
1527c478bdstevel@tonic-gate#if defined(_LONGLONG_TYPE)
1537c478bdstevel@tonic-gatetypedef unsigned long long	uint_fast64_t;
1547c478bdstevel@tonic-gate#endif
1557c478bdstevel@tonic-gate#endif
1567c478bdstevel@tonic-gate
1577c478bdstevel@tonic-gate/*
1587c478bdstevel@tonic-gate * The following define the smallest integer types that can hold the
1597c478bdstevel@tonic-gate * specified number of bits.
1607c478bdstevel@tonic-gate */
1617c478bdstevel@tonic-gate#if defined(_CHAR_IS_SIGNED)
1627c478bdstevel@tonic-gatetypedef char			int_least8_t;
1637c478bdstevel@tonic-gate#else
1647c478bdstevel@tonic-gatetypedef signed char		int_least8_t;
1657c478bdstevel@tonic-gate#endif
1667c478bdstevel@tonic-gatetypedef short			int_least16_t;
1677c478bdstevel@tonic-gatetypedef int			int_least32_t;
1687c478bdstevel@tonic-gate#ifdef	_LP64
1697c478bdstevel@tonic-gatetypedef long			int_least64_t;
1707c478bdstevel@tonic-gate#else	/* _ILP32 */
1717c478bdstevel@tonic-gate#if defined(_LONGLONG_TYPE)
1727c478bdstevel@tonic-gatetypedef long long		int_least64_t;
1737c478bdstevel@tonic-gate#endif
1747c478bdstevel@tonic-gate#endif
1757c478bdstevel@tonic-gate
176eda3ef2Robert Mustacchi/*
177eda3ef2Robert Mustacchi * If these are changed, please update char16_t and char32_t in head/uchar.h.
178eda3ef2Robert Mustacchi */
1797c478bdstevel@tonic-gatetypedef unsigned char		uint_least8_t;
1807c478bdstevel@tonic-gatetypedef unsigned short		uint_least16_t;
1817c478bdstevel@tonic-gatetypedef unsigned int		uint_least32_t;
1827c478bdstevel@tonic-gate#ifdef	_LP64
1837c478bdstevel@tonic-gatetypedef unsigned long		uint_least64_t;
1847c478bdstevel@tonic-gate#else	/* _ILP32 */
1857c478bdstevel@tonic-gate#if defined(_LONGLONG_TYPE)
1867c478bdstevel@tonic-gatetypedef unsigned long long	uint_least64_t;
1877c478bdstevel@tonic-gate#endif
1887c478bdstevel@tonic-gate#endif
1897c478bdstevel@tonic-gate
1907c478bdstevel@tonic-gate#ifdef __cplusplus
1917c478bdstevel@tonic-gate}
1927c478bdstevel@tonic-gate#endif
1937c478bdstevel@tonic-gate
1947c478bdstevel@tonic-gate#endif /* _SYS_INT_TYPES_H */
195