xref: /titanic_52/usr/src/uts/common/sys/int_const.h (revision 06e46062ef4f5f4b687cbafb4518fb123fe23920)
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_CONST_H
28 #define	_SYS_INT_CONST_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * This file, <sys/int_const.h>, is part of the Sun Microsystems implementation
34  * of <inttypes.h> as proposed in the ISO/JTC1/SC22/WG14 C committee's working
35  * draft for the revision of the current ISO C standard, ISO/IEC 9899:1990
36  * Programming language - C.
37  *
38  * Programs/Modules should not directly include this file.  Access to the
39  * types defined in this file should be through the inclusion of one of the
40  * following files:
41  *
42  *	<sys/inttypes.h>	Provides the Kernel and Driver appropriate
43  *				components of <inttypes.h>.
44  *
45  *	<inttypes.h>		For use by applications.
46  *
47  * See these files for more details.
48  *
49  * Use at your own risk.  This file will track the evolution of the revision
50  * of the current ISO C standard.  As of February 1996, the committee is
51  * squarely behind the fixed sized types.
52  */
53 
54 #include <sys/feature_tests.h>
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 /*
61  * Constants
62  *
63  * The following macros create constants of the types defined in
64  * <sys/int_types.h>. The intent is that:
65  *	Constants defined using these macros have a specific size and
66  *	signedness. The suffix used for int64_t and uint64_t (ll and ull)
67  *	are for examples only. Implementations are permitted to use other
68  *	suffixes.
69  *
70  * The "CSTYLED" comments are flags to an internal code style analysis tool
71  * telling it to silently accept the line which follows.  This internal
72  * standard requires a space between arguments, but the historical,
73  * non-ANSI-C ``method'' of concatenation can't tolerate those spaces.
74  */
75 #ifdef __STDC__
76 /* CSTYLED */
77 #define	__CONCAT__(A,B) A ## B
78 #else
79 /* CSTYLED */
80 #define	__CONCAT__(A,B) A/**/B
81 #endif
82 
83 #if defined(_CHAR_IS_SIGNED) || defined(__STDC__)
84 #define	INT8_C(c)	(c)
85 #endif
86 #define	INT16_C(c)	(c)
87 #define	INT32_C(c)	(c)
88 #ifdef  _LP64
89 /* CSTYLED */
90 #define	INT64_C(c)	__CONCAT__(c,l)
91 #else   /* _ILP32 */
92 #if defined(_LONGLONG_TYPE)
93 /* CSTYLED */
94 #define	INT64_C(c)	__CONCAT__(c,ll)
95 #endif
96 #endif
97 
98 /* CSTYLED */
99 #define	UINT8_C(c)	__CONCAT__(c,u)
100 /* CSTYLED */
101 #define	UINT16_C(c)	__CONCAT__(c,u)
102 /* CSTYLED */
103 #define	UINT32_C(c)	__CONCAT__(c,u)
104 #ifdef  _LP64
105 /* CSTYLED */
106 #define	UINT64_C(c)	__CONCAT__(c,ul)
107 #else   /* _ILP32 */
108 #if defined(_LONGLONG_TYPE)
109 /* CSTYLED */
110 #define	UINT64_C(c)	__CONCAT__(c,ull)
111 #endif
112 #endif
113 
114 #ifdef  _LP64
115 /* CSTYLED */
116 #define	INTMAX_C(c)	__CONCAT__(c,l)
117 /* CSTYLED */
118 #define	UINTMAX_C(c)	__CONCAT__(c,ul)
119 #else   /* _ILP32 */
120 #if defined(_LONGLONG_TYPE)
121 /* CSTYLED */
122 #define	INTMAX_C(c)	__CONCAT__(c,ll)
123 /* CSTYLED */
124 #define	UINTMAX_C(c)	__CONCAT__(c,ull)
125 #else
126 #define	INTMAX_C(c)	(c)
127 #define	UINTMAX_C(c)	(c)
128 #endif
129 #endif
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* _SYS_INT_CONST_H */
136