Home | History | Annotate | Download | only in sys
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 #ifndef _SYS_INT_TYPES_H
     28 #define	_SYS_INT_TYPES_H
     29 
     30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     31 
     32 /*
     33  * This file, <sys/int_types.h>, is part of the Sun Microsystems implementation
     34  * of <inttypes.h> defined in the ISO C standard, ISO/IEC 9899:1999
     35  * Programming language - C.
     36  *
     37  * Programs/Modules should not directly include this file.  Access to the
     38  * types defined in this file should be through the inclusion of one of the
     39  * following files:
     40  *
     41  *	<sys/types.h>		Provides only the "_t" types defined in this
     42  *				file which is a subset of the contents of
     43  *				<inttypes.h>.  (This can be appropriate for
     44  *				all programs/modules except those claiming
     45  *				ANSI-C conformance.)
     46  *
     47  *	<sys/inttypes.h>	Provides the Kernel and Driver appropriate
     48  *				components of <inttypes.h>.
     49  *
     50  *	<inttypes.h>		For use by applications.
     51  *
     52  * See these files for more details.
     53  */
     54 
     55 #include <sys/feature_tests.h>
     56 
     57 #ifdef __cplusplus
     58 extern "C" {
     59 #endif
     60 
     61 /*
     62  * Basic / Extended integer types
     63  *
     64  * The following defines the basic fixed-size integer types.
     65  *
     66  * Implementations are free to typedef them to Standard C integer types or
     67  * extensions that they support. If an implementation does not support one
     68  * of the particular integer data types below, then it should not define the
     69  * typedefs and macros corresponding to that data type.  Note that int8_t
     70  * is not defined in -Xs mode on ISAs for which the ABI specifies "char"
     71  * as an unsigned entity because there is no way to define an eight bit
     72  * signed integral.
     73  */
     74 #if defined(_CHAR_IS_SIGNED)
     75 typedef char			int8_t;
     76 #else
     77 #if defined(__STDC__)
     78 typedef signed char		int8_t;
     79 #endif
     80 #endif
     81 typedef short			int16_t;
     82 typedef int			int32_t;
     83 #ifdef	_LP64
     84 #define	_INT64_TYPE
     85 typedef long			int64_t;
     86 #else	/* _ILP32 */
     87 #if defined(_LONGLONG_TYPE)
     88 #define	_INT64_TYPE
     89 typedef	long long		int64_t;
     90 #endif
     91 #endif
     92 
     93 typedef unsigned char		uint8_t;
     94 typedef unsigned short		uint16_t;
     95 typedef unsigned int		uint32_t;
     96 #ifdef	_LP64
     97 typedef unsigned long		uint64_t;
     98 #else	/* _ILP32 */
     99 #if defined(_LONGLONG_TYPE)
    100 typedef unsigned long long	uint64_t;
    101 #endif
    102 #endif
    103 
    104 /*
    105  * intmax_t and uintmax_t are to be the longest (in number of bits) signed
    106  * and unsigned integer types supported by the implementation.
    107  */
    108 #if defined(_INT64_TYPE)
    109 typedef int64_t			intmax_t;
    110 typedef uint64_t		uintmax_t;
    111 #else
    112 typedef int32_t			intmax_t;
    113 typedef uint32_t		uintmax_t;
    114 #endif
    115 
    116 /*
    117  * intptr_t and uintptr_t are signed and unsigned integer types large enough
    118  * to hold any data pointer; that is, data pointers can be assigned into or
    119  * from these integer types without losing precision.
    120  */
    121 #if defined(_LP64) || defined(_I32LPx)
    122 typedef long			intptr_t;
    123 typedef unsigned long		uintptr_t;
    124 #else
    125 typedef	int			intptr_t;
    126 typedef	unsigned int		uintptr_t;
    127 #endif
    128 
    129 /*
    130  * The following define the fastest integer types that can hold the
    131  * specified number of bits.
    132  */
    133 #if defined(_CHAR_IS_SIGNED)
    134 typedef char			int_fast8_t;
    135 #else
    136 #if defined(__STDC__)
    137 typedef signed char		int_fast8_t;
    138 #endif
    139 #endif
    140 typedef int			int_fast16_t;
    141 typedef int			int_fast32_t;
    142 #ifdef	_LP64
    143 typedef long			int_fast64_t;
    144 #else	/* _ILP32 */
    145 #if defined(_LONGLONG_TYPE)
    146 typedef long long		int_fast64_t;
    147 #endif
    148 #endif
    149 
    150 typedef unsigned char		uint_fast8_t;
    151 typedef unsigned int		uint_fast16_t;
    152 typedef unsigned int		uint_fast32_t;
    153 #ifdef	_LP64
    154 typedef unsigned long		uint_fast64_t;
    155 #else	/* _ILP32 */
    156 #if defined(_LONGLONG_TYPE)
    157 typedef unsigned long long	uint_fast64_t;
    158 #endif
    159 #endif
    160 
    161 /*
    162  * The following define the smallest integer types that can hold the
    163  * specified number of bits.
    164  */
    165 #if defined(_CHAR_IS_SIGNED)
    166 typedef char			int_least8_t;
    167 #else
    168 #if defined(__STDC__)
    169 typedef signed char		int_least8_t;
    170 #endif
    171 #endif
    172 typedef short			int_least16_t;
    173 typedef int			int_least32_t;
    174 #ifdef	_LP64
    175 typedef long			int_least64_t;
    176 #else	/* _ILP32 */
    177 #if defined(_LONGLONG_TYPE)
    178 typedef long long		int_least64_t;
    179 #endif
    180 #endif
    181 
    182 typedef unsigned char		uint_least8_t;
    183 typedef unsigned short		uint_least16_t;
    184 typedef unsigned int		uint_least32_t;
    185 #ifdef	_LP64
    186 typedef unsigned long		uint_least64_t;
    187 #else	/* _ILP32 */
    188 #if defined(_LONGLONG_TYPE)
    189 typedef unsigned long long	uint_least64_t;
    190 #endif
    191 #endif
    192 
    193 #ifdef __cplusplus
    194 }
    195 #endif
    196 
    197 #endif /* _SYS_INT_TYPES_H */
    198