8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sendmail / include / sm / cdefs.h
blob73c6f64e6da368819360e0d3775cc4a037813beb
1 /*
2 * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
9 * $Id: cdefs.h,v 1.15.2.1 2003/12/05 22:44:17 ca Exp $
12 #pragma ident "%Z%%M% %I% %E% SMI"
15 ** libsm C language portability macros
16 ** See libsm/cdefs.html for documentation.
19 #ifndef SM_CDEFS_H
20 # define SM_CDEFS_H
22 # include <sm/config.h>
25 ** BSD and Linux have <sys/cdefs.h> which defines a set of C language
26 ** portability macros that are a defacto standard in the open source
27 ** community.
30 # if SM_CONF_SYS_CDEFS_H
31 # include <sys/cdefs.h>
32 # endif /* SM_CONF_SYS_CDEFS_H */
35 ** Define the standard C language portability macros
36 ** for platforms that lack <sys/cdefs.h>.
39 # if !SM_CONF_SYS_CDEFS_H
40 # if defined(__cplusplus)
41 # define __BEGIN_DECLS extern "C" {
42 # define __END_DECLS };
43 # else /* defined(__cplusplus) */
44 # define __BEGIN_DECLS
45 # define __END_DECLS
46 # endif /* defined(__cplusplus) */
47 # if defined(__STDC__) || defined(__cplusplus)
48 # ifndef __P
49 # define __P(protos) protos
50 # endif /* __P */
51 # define __CONCAT(x,y) x ## y
52 # define __STRING(x) #x
53 # else /* defined(__STDC__) || defined(__cplusplus) */
54 # define __P(protos) ()
55 # define __CONCAT(x,y) x/**/y
56 # define __STRING(x) "x"
57 # define const
58 # define signed
59 # define volatile
60 # endif /* defined(__STDC__) || defined(__cplusplus) */
61 # endif /* !SM_CONF_SYS_CDEFS_H */
64 ** Define SM_DEAD, a macro used to declare functions that do not return
65 ** to their caller.
68 # ifndef SM_DEAD
69 # if __GNUC__ >= 2
70 # if __GNUC__ == 2 && __GNUC_MINOR__ < 5
71 # define SM_DEAD(proto) volatile proto
72 # define SM_DEAD_D volatile
73 # else /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */
74 # define SM_DEAD(proto) proto __attribute__((__noreturn__))
75 # define SM_DEAD_D
76 # endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */
77 # else /* __GNUC__ >= 2 */
78 # define SM_DEAD(proto) proto
79 # define SM_DEAD_D
80 # endif /* __GNUC__ >= 2 */
81 # endif /* SM_DEAD */
84 ** Define SM_UNUSED, a macro used to declare variables that may be unused.
87 # ifndef SM_UNUSED
88 # if __GNUC__ >= 2
89 # if __GNUC__ == 2 && __GNUC_MINOR__ < 7
90 # define SM_UNUSED(decl) decl
91 # else /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */
92 # define SM_UNUSED(decl) decl __attribute__((__unused__))
93 # endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */
94 # else /* __GNUC__ >= 2 */
95 # define SM_UNUSED(decl) decl
96 # endif /* __GNUC__ >= 2 */
97 # endif /* SM_UNUSED */
100 ** The SM_NONVOLATILE macro is used to declare variables that are not
101 ** volatile, but which must be declared volatile when compiling with
102 ** gcc -O -Wall in order to suppress bogus warning messages.
104 ** Variables that actually are volatile should be declared volatile
105 ** using the "volatile" keyword. If a variable actually is volatile,
106 ** then SM_NONVOLATILE should not be used.
108 ** To compile sendmail with gcc and see all non-bogus warnings,
109 ** you should use
110 ** gcc -O -Wall -DSM_OMIT_BOGUS_WARNINGS ...
111 ** Do not use -DSM_OMIT_BOGUS_WARNINGS when compiling the production
112 ** version of sendmail, because there is a performance hit.
115 # ifdef SM_OMIT_BOGUS_WARNINGS
116 # define SM_NONVOLATILE volatile
117 # else /* SM_OMIT_BOGUS_WARNINGS */
118 # define SM_NONVOLATILE
119 # endif /* SM_OMIT_BOGUS_WARNINGS */
122 ** Turn on format string argument checking.
125 # ifndef SM_CONF_FORMAT_TEST
126 # if __GNUC__ == 2 && __GNUC_MINOR__ >= 7
127 # define SM_CONF_FORMAT_TEST 1
128 # else /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */
129 # define SM_CONF_FORMAT_TEST 0
130 # endif /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */
131 # endif /* SM_CONF_FORMAT_TEST */
133 # ifndef PRINTFLIKE
134 # if SM_CONF_FORMAT_TEST
135 # define PRINTFLIKE(x,y) __attribute__ ((__format__ (__printf__, x, y)))
136 # else /* SM_CONF_FORMAT_TEST */
137 # define PRINTFLIKE(x,y)
138 # endif /* SM_CONF_FORMAT_TEST */
139 # endif /* ! PRINTFLIKE */
141 # ifndef SCANFLIKE
142 # if SM_CONF_FORMAT_TEST
143 # define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, x, y)))
144 # else /* SM_CONF_FORMAT_TEST */
145 # define SCANFLIKE(x,y)
146 # endif /* SM_CONF_FORMAT_TEST */
147 # endif /* ! SCANFLIKE */
149 #endif /* ! SM_CDEFS_H */