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
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.
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_CCOMPILE_H
28 #define _SYS_CCOMPILE_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * This file contains definitions designed to enable different compilers
34 * to be used harmoniously on Solaris systems.
42 * Allow for version tests for compiler bugs and features.
45 #define __GNUC_VERSION \
46 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
48 #define __GNUC_VERSION 0
51 #if defined(__ATTRIBUTE_IMPLEMENTED) || defined(__GNUC__)
54 * analogous to lint's PRINTFLIKEn
56 #define __sun_attr___PRINTFLIKE__(__n) \
57 __attribute__((__format__(printf, __n, (__n)+1)))
58 #define __sun_attr___VPRINTFLIKE__(__n) \
59 __attribute__((__format__(printf, __n, 0)))
62 * Handle the kernel printf routines that can take '%b' too
64 #if __GNUC_VERSION < 30402
66 * XX64 at least this doesn't work correctly yet with 3.4.1 anyway!
68 #define __sun_attr___KPRINTFLIKE__ __sun_attr___PRINTFLIKE__
69 #define __sun_attr___KVPRINTFLIKE__ __sun_attr___VPRINTFLIKE__
71 #define __sun_attr___KPRINTFLIKE__(__n) \
72 __attribute__((__format__(cmn_err, __n, (__n)+1)))
73 #define __sun_attr___KVPRINTFLIKE__(__n) \
74 __attribute__((__format__(cmn_err, __n, 0)))
78 * This one's pretty obvious -- the function never returns
80 #define __sun_attr___noreturn__ __attribute__((__noreturn__))
84 * This is an appropriate label for functions that do not
85 * modify their arguments, e.g. strlen()
87 #define __sun_attr___pure__ __attribute__((__pure__))
90 * This is a stronger form of __pure__. Can be used for functions
91 * that do not modify their arguments and don't depend on global
94 #define __sun_attr___const__ __attribute__((__const__))
97 * structure packing like #pragma pack(1)
99 #define __sun_attr___packed__ __attribute__((__packed__))
101 #define ___sun_attr_inner(__a) __sun_attr_##__a
102 #define __sun_attr__(__a) ___sun_attr_inner __a
104 #else /* __ATTRIBUTE_IMPLEMENTED || __GNUC__ */
106 #define __sun_attr__(__a)
108 #endif /* __ATTRIBUTE_IMPLEMENTED || __GNUC__ */
111 * Shorthand versions for readability
114 #define __PRINTFLIKE(__n) __sun_attr__((__PRINTFLIKE__(__n)))
115 #define __VPRINTFLIKE(__n) __sun_attr__((__VPRINTFLIKE__(__n)))
116 #define __KPRINTFLIKE(__n) __sun_attr__((__KPRINTFLIKE__(__n)))
117 #define __KVPRINTFLIKE(__n) __sun_attr__((__KVPRINTFLIKE__(__n)))
118 #define __NORETURN __sun_attr__((__noreturn__))
119 #define __CONST __sun_attr__((__const__))
120 #define __PURE __sun_attr__((__pure__))
127 #endif /* _SYS_CCOMPILE_H */