xref: /titanic_50/usr/src/uts/common/sys/int_const.h (revision ba3594ba9b5dd4c846c472a8d657edcb7c8109ac)
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 2014 Garrett D'Amore <garrett@damore.org>
24  *
25  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 #ifndef _SYS_INT_CONST_H
30 #define	_SYS_INT_CONST_H
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 /* CSTYLED */
76 #define	__CONCAT__(A,B) A ## B
77 
78 #define	INT8_C(c)	(c)
79 #define	INT16_C(c)	(c)
80 #define	INT32_C(c)	(c)
81 #ifdef  _LP64
82 /* CSTYLED */
83 #define	INT64_C(c)	__CONCAT__(c,l)
84 #else   /* _ILP32 */
85 #if defined(_LONGLONG_TYPE)
86 /* CSTYLED */
87 #define	INT64_C(c)	__CONCAT__(c,ll)
88 #endif
89 #endif
90 
91 /* CSTYLED */
92 #define	UINT8_C(c)	__CONCAT__(c,u)
93 /* CSTYLED */
94 #define	UINT16_C(c)	__CONCAT__(c,u)
95 /* CSTYLED */
96 #define	UINT32_C(c)	__CONCAT__(c,u)
97 #ifdef  _LP64
98 /* CSTYLED */
99 #define	UINT64_C(c)	__CONCAT__(c,ul)
100 #else   /* _ILP32 */
101 #if defined(_LONGLONG_TYPE)
102 /* CSTYLED */
103 #define	UINT64_C(c)	__CONCAT__(c,ull)
104 #endif
105 #endif
106 
107 #ifdef  _LP64
108 /* CSTYLED */
109 #define	INTMAX_C(c)	__CONCAT__(c,l)
110 /* CSTYLED */
111 #define	UINTMAX_C(c)	__CONCAT__(c,ul)
112 #else   /* _ILP32 */
113 #if defined(_LONGLONG_TYPE)
114 /* CSTYLED */
115 #define	INTMAX_C(c)	__CONCAT__(c,ll)
116 /* CSTYLED */
117 #define	UINTMAX_C(c)	__CONCAT__(c,ull)
118 #else
119 #define	INTMAX_C(c)	(c)
120 #define	UINTMAX_C(c)	(c)
121 #endif
122 #endif
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* _SYS_INT_CONST_H */
129