cdefs.h revision 285303
134689Sbde/* 250476Speter * Copyright (c) 2000-2002 Proofpoint, Inc. and its suppliers. 31573Srgrimes * All rights reserved. 4156813Sru * 5156813Sru * By using this file, you agree to the terms and conditions set 634689Sbde * forth in the LICENSE file which can be found at the top level of 734689Sbde * the sendmail distribution. 834689Sbde * 938752Sbde * $Id: cdefs.h,v 1.17 2013-11-22 20:51:31 ca Exp $ 10173017Sru */ 11228989Srwatson 12204738Simp/* 13204738Simp** libsm C language portability macros 1481133Stmm** See libsm/cdefs.html for documentation. 1559897Sjoe*/ 1679471Smarkm 17166131Srafan#ifndef SM_CDEFS_H 18122568Sharti# define SM_CDEFS_H 1959353Skris 2041257Sjdp# include <sm/config.h> 2182355Smarkm 2294690Sdes/* 2341257Sjdp** BSD and Linux have <sys/cdefs.h> which defines a set of C language 2456081Sbde** portability macros that are a defacto standard in the open source 2594690Sdes** community. 26181344Sdfr*/ 2734689Sbde 2834689Sbde# if SM_CONF_SYS_CDEFS_H 29204738Simp# include <sys/cdefs.h> 30204738Simp# endif /* SM_CONF_SYS_CDEFS_H */ 3134689Sbde 32205113Simp/* 33205113Simp** Define the standard C language portability macros 34205113Simp** for platforms that lack <sys/cdefs.h>. 35205113Simp*/ 36215127Sed 37205113Simp# if !SM_CONF_SYS_CDEFS_H 38205113Simp# if defined(__cplusplus) 39219019Sgabor# define __BEGIN_DECLS extern "C" { 40205113Simp# define __END_DECLS }; 41205113Simp# else /* defined(__cplusplus) */ 42205113Simp# define __BEGIN_DECLS 43205113Simp# define __END_DECLS 44205113Simp# endif /* defined(__cplusplus) */ 45205113Simp# if defined(__STDC__) || defined(__cplusplus) 46205113Simp# ifndef __P 47205113Simp# define __P(protos) protos 48205113Simp# endif /* __P */ 49205113Simp# define __CONCAT(x,y) x ## y 50227987Sdim# define __STRING(x) #x 51227987Sdim# else /* defined(__STDC__) || defined(__cplusplus) */ 52227987Sdim# define __P(protos) () 53205113Simp# define __CONCAT(x,y) x/**/y 54233337Sstas# define __STRING(x) "x" 55233337Sstas# define const 56233337Sstas# define signed 57233337Sstas# define volatile 58205113Simp# endif /* defined(__STDC__) || defined(__cplusplus) */ 59205113Simp# endif /* !SM_CONF_SYS_CDEFS_H */ 60205113Simp 61205113Simp/* 62205113Simp** Define SM_DEAD, a macro used to declare functions that do not return 63215127Sed** to their caller. 64205113Simp*/ 65205113Simp 66205113Simp# ifndef SM_DEAD 67205113Simp# if __GNUC__ >= 2 68205113Simp# if __GNUC__ == 2 && __GNUC_MINOR__ < 5 69205113Simp# define SM_DEAD(proto) volatile proto 70205113Simp# define SM_DEAD_D volatile 71205113Simp# else /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ 72205113Simp# define SM_DEAD(proto) proto __attribute__((__noreturn__)) 73205113Simp# define SM_DEAD_D 74205113Simp# endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ 75205113Simp# else /* __GNUC__ >= 2 */ 76205113Simp# define SM_DEAD(proto) proto 77205113Simp# define SM_DEAD_D 78205113Simp# endif /* __GNUC__ >= 2 */ 79205113Simp# endif /* SM_DEAD */ 80205113Simp 81205113Simp/* 82205113Simp** Define SM_UNUSED, a macro used to declare variables that may be unused. 83205113Simp*/ 84205113Simp 85205113Simp# ifndef SM_UNUSED 86207842Smm# if __GNUC__ >= 2 87205113Simp# if __GNUC__ == 2 && __GNUC_MINOR__ < 7 88241774Suqs# define SM_UNUSED(decl) decl 89205113Simp# else /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ 90205113Simp# define SM_UNUSED(decl) decl __attribute__((__unused__)) 91205113Simp# endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ 92235537Sgber# else /* __GNUC__ >= 2 */ 93205113Simp# define SM_UNUSED(decl) decl 94205113Simp# endif /* __GNUC__ >= 2 */ 95205113Simp# endif /* SM_UNUSED */ 96205113Simp 97205113Simp/* 98210682Srpaulo** The SM_NONVOLATILE macro is used to declare variables that are not 99221807Sstas** volatile, but which must be declared volatile when compiling with 100205113Simp** gcc -O -Wall in order to suppress bogus warning messages. 101210690Srpaulo** 102205113Simp** Variables that actually are volatile should be declared volatile 103205113Simp** using the "volatile" keyword. If a variable actually is volatile, 104205113Simp** then SM_NONVOLATILE should not be used. 105205113Simp** 106205113Simp** To compile sendmail with gcc and see all non-bogus warnings, 107234772Sjlh** you should use 108228904Sed** gcc -O -Wall -DSM_OMIT_BOGUS_WARNINGS ... 109205113Simp** Do not use -DSM_OMIT_BOGUS_WARNINGS when compiling the production 110205113Simp** version of sendmail, because there is a performance hit. 111205113Simp*/ 112205113Simp 113205113Simp# ifdef SM_OMIT_BOGUS_WARNINGS 114205113Simp# define SM_NONVOLATILE volatile 115205113Simp# else /* SM_OMIT_BOGUS_WARNINGS */ 116205113Simp# define SM_NONVOLATILE 117205113Simp# endif /* SM_OMIT_BOGUS_WARNINGS */ 118205113Simp 119205113Simp/* 120205113Simp** Turn on format string argument checking. 121208964Srdivacky*/ 122208964Srdivacky 12334689Sbde# ifndef SM_CONF_FORMAT_TEST 124211759Simp# if (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2 125211759Simp# define SM_CONF_FORMAT_TEST 1 126211934Snwhitehorn# else 127211934Snwhitehorn# define SM_CONF_FORMAT_TEST 0 128211725Simp# endif 129211725Simp# endif /* SM_CONF_FORMAT_TEST */ 13072309Sobrien 13172309Sobrien# ifndef PRINTFLIKE 1321573Srgrimes# if SM_CONF_FORMAT_TEST 1331573Srgrimes# define PRINTFLIKE(x,y) __attribute__ ((__format__ (__printf__, x, y))) 134183242Ssam# else /* SM_CONF_FORMAT_TEST */ 135183242Ssam# define PRINTFLIKE(x,y) 136156813Sru# endif /* SM_CONF_FORMAT_TEST */ 137121340Sharti# endif /* ! PRINTFLIKE */ 138119508Sphk 139119508Sphk# ifndef SCANFLIKE 140156813Sru# if SM_CONF_FORMAT_TEST 141135549Sdes# define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, x, y))) 14253922Speter# else /* SM_CONF_FORMAT_TEST */ 14353922Speter# define SCANFLIKE(x,y) 144156813Sru# endif /* SM_CONF_FORMAT_TEST */ 145125123Semax# endif /* ! SCANFLIKE */ 146125123Semax 147125123Semax#endif /* ! SM_CDEFS_H */ 148131768Semax