xref: /onnv-gate/usr/src/uts/common/sys/int_const.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _SYS_INT_CONST_H
28*0Sstevel@tonic-gate #define	_SYS_INT_CONST_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * This file, <sys/int_const.h>, is part of the Sun Microsystems implementation
34*0Sstevel@tonic-gate  * of <inttypes.h> as proposed in the ISO/JTC1/SC22/WG14 C committee's working
35*0Sstevel@tonic-gate  * draft for the revision of the current ISO C standard, ISO/IEC 9899:1990
36*0Sstevel@tonic-gate  * Programming language - C.
37*0Sstevel@tonic-gate  *
38*0Sstevel@tonic-gate  * Programs/Modules should not directly include this file.  Access to the
39*0Sstevel@tonic-gate  * types defined in this file should be through the inclusion of one of the
40*0Sstevel@tonic-gate  * following files:
41*0Sstevel@tonic-gate  *
42*0Sstevel@tonic-gate  *	<sys/inttypes.h>	Provides the Kernel and Driver appropriate
43*0Sstevel@tonic-gate  *				components of <inttypes.h>.
44*0Sstevel@tonic-gate  *
45*0Sstevel@tonic-gate  *	<inttypes.h>		For use by applications.
46*0Sstevel@tonic-gate  *
47*0Sstevel@tonic-gate  * See these files for more details.
48*0Sstevel@tonic-gate  *
49*0Sstevel@tonic-gate  * Use at your own risk.  This file will track the evolution of the revision
50*0Sstevel@tonic-gate  * of the current ISO C standard.  As of February 1996, the committee is
51*0Sstevel@tonic-gate  * squarely behind the fixed sized types.
52*0Sstevel@tonic-gate  */
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate #include <sys/feature_tests.h>
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate #ifdef __cplusplus
57*0Sstevel@tonic-gate extern "C" {
58*0Sstevel@tonic-gate #endif
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate /*
61*0Sstevel@tonic-gate  * Constants
62*0Sstevel@tonic-gate  *
63*0Sstevel@tonic-gate  * The following macros create constants of the types defined in
64*0Sstevel@tonic-gate  * <sys/int_types.h>. The intent is that:
65*0Sstevel@tonic-gate  *	Constants defined using these macros have a specific size and
66*0Sstevel@tonic-gate  *	signedness. The suffix used for int64_t and uint64_t (ll and ull)
67*0Sstevel@tonic-gate  *	are for examples only. Implementations are permitted to use other
68*0Sstevel@tonic-gate  *	suffixes.
69*0Sstevel@tonic-gate  *
70*0Sstevel@tonic-gate  * The "CSTYLED" comments are flags to an internal code style analysis tool
71*0Sstevel@tonic-gate  * telling it to silently accept the line which follows.  This internal
72*0Sstevel@tonic-gate  * standard requires a space between arguments, but the historical,
73*0Sstevel@tonic-gate  * non-ANSI-C ``method'' of concatenation can't tolerate those spaces.
74*0Sstevel@tonic-gate  */
75*0Sstevel@tonic-gate #ifdef __STDC__
76*0Sstevel@tonic-gate /* CSTYLED */
77*0Sstevel@tonic-gate #define	__CONCAT__(A,B) A ## B
78*0Sstevel@tonic-gate #else
79*0Sstevel@tonic-gate /* CSTYLED */
80*0Sstevel@tonic-gate #define	__CONCAT__(A,B) A/**/B
81*0Sstevel@tonic-gate #endif
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
84*0Sstevel@tonic-gate #define	INT8_C(c)	(c)
85*0Sstevel@tonic-gate #endif
86*0Sstevel@tonic-gate #define	INT16_C(c)	(c)
87*0Sstevel@tonic-gate #define	INT32_C(c)	(c)
88*0Sstevel@tonic-gate #ifdef  _LP64
89*0Sstevel@tonic-gate /* CSTYLED */
90*0Sstevel@tonic-gate #define	INT64_C(c)	__CONCAT__(c,l)
91*0Sstevel@tonic-gate #else   /* _ILP32 */
92*0Sstevel@tonic-gate #if defined(_LONGLONG_TYPE)
93*0Sstevel@tonic-gate /* CSTYLED */
94*0Sstevel@tonic-gate #define	INT64_C(c)	__CONCAT__(c,ll)
95*0Sstevel@tonic-gate #endif
96*0Sstevel@tonic-gate #endif
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate /* CSTYLED */
99*0Sstevel@tonic-gate #define	UINT8_C(c)	__CONCAT__(c,u)
100*0Sstevel@tonic-gate /* CSTYLED */
101*0Sstevel@tonic-gate #define	UINT16_C(c)	__CONCAT__(c,u)
102*0Sstevel@tonic-gate /* CSTYLED */
103*0Sstevel@tonic-gate #define	UINT32_C(c)	__CONCAT__(c,u)
104*0Sstevel@tonic-gate #ifdef  _LP64
105*0Sstevel@tonic-gate /* CSTYLED */
106*0Sstevel@tonic-gate #define	UINT64_C(c)	__CONCAT__(c,ul)
107*0Sstevel@tonic-gate #else   /* _ILP32 */
108*0Sstevel@tonic-gate #if defined(_LONGLONG_TYPE)
109*0Sstevel@tonic-gate /* CSTYLED */
110*0Sstevel@tonic-gate #define	UINT64_C(c)	__CONCAT__(c,ull)
111*0Sstevel@tonic-gate #endif
112*0Sstevel@tonic-gate #endif
113*0Sstevel@tonic-gate 
114*0Sstevel@tonic-gate #ifdef  _LP64
115*0Sstevel@tonic-gate /* CSTYLED */
116*0Sstevel@tonic-gate #define	INTMAX_C(c)	__CONCAT__(c,l)
117*0Sstevel@tonic-gate /* CSTYLED */
118*0Sstevel@tonic-gate #define	UINTMAX_C(c)	__CONCAT__(c,ul)
119*0Sstevel@tonic-gate #else   /* _ILP32 */
120*0Sstevel@tonic-gate #if defined(_LONGLONG_TYPE)
121*0Sstevel@tonic-gate /* CSTYLED */
122*0Sstevel@tonic-gate #define	INTMAX_C(c)	__CONCAT__(c,ll)
123*0Sstevel@tonic-gate /* CSTYLED */
124*0Sstevel@tonic-gate #define	UINTMAX_C(c)	__CONCAT__(c,ull)
125*0Sstevel@tonic-gate #else
126*0Sstevel@tonic-gate #define	INTMAX_C(c)	(c)
127*0Sstevel@tonic-gate #define	UINTMAX_C(c)	(c)
128*0Sstevel@tonic-gate #endif
129*0Sstevel@tonic-gate #endif
130*0Sstevel@tonic-gate 
131*0Sstevel@tonic-gate #ifdef __cplusplus
132*0Sstevel@tonic-gate }
133*0Sstevel@tonic-gate #endif
134*0Sstevel@tonic-gate 
135*0Sstevel@tonic-gate #endif /* _SYS_INT_CONST_H */
136