140266059SGregory Neil Shapiro /* 2*5dd76dd0SGregory Neil Shapiro * Copyright (c) 2000-2002 Proofpoint, Inc. and its suppliers. 340266059SGregory Neil Shapiro * All rights reserved. 440266059SGregory Neil Shapiro * 540266059SGregory Neil Shapiro * By using this file, you agree to the terms and conditions set 640266059SGregory Neil Shapiro * forth in the LICENSE file which can be found at the top level of 740266059SGregory Neil Shapiro * the sendmail distribution. 840266059SGregory Neil Shapiro * 9*5dd76dd0SGregory Neil Shapiro * $Id: cdefs.h,v 1.17 2013/11/22 20:51:31 ca Exp $ 1040266059SGregory Neil Shapiro */ 1140266059SGregory Neil Shapiro 1240266059SGregory Neil Shapiro /* 1340266059SGregory Neil Shapiro ** libsm C language portability macros 1440266059SGregory Neil Shapiro ** See libsm/cdefs.html for documentation. 1540266059SGregory Neil Shapiro */ 1640266059SGregory Neil Shapiro 1740266059SGregory Neil Shapiro #ifndef SM_CDEFS_H 1840266059SGregory Neil Shapiro # define SM_CDEFS_H 1940266059SGregory Neil Shapiro 2040266059SGregory Neil Shapiro # include <sm/config.h> 2140266059SGregory Neil Shapiro 2240266059SGregory Neil Shapiro /* 2340266059SGregory Neil Shapiro ** BSD and Linux have <sys/cdefs.h> which defines a set of C language 2440266059SGregory Neil Shapiro ** portability macros that are a defacto standard in the open source 2540266059SGregory Neil Shapiro ** community. 2640266059SGregory Neil Shapiro */ 2740266059SGregory Neil Shapiro 2840266059SGregory Neil Shapiro # if SM_CONF_SYS_CDEFS_H 2940266059SGregory Neil Shapiro # include <sys/cdefs.h> 3040266059SGregory Neil Shapiro # endif /* SM_CONF_SYS_CDEFS_H */ 3140266059SGregory Neil Shapiro 3240266059SGregory Neil Shapiro /* 3340266059SGregory Neil Shapiro ** Define the standard C language portability macros 3440266059SGregory Neil Shapiro ** for platforms that lack <sys/cdefs.h>. 3540266059SGregory Neil Shapiro */ 3640266059SGregory Neil Shapiro 3740266059SGregory Neil Shapiro # if !SM_CONF_SYS_CDEFS_H 3840266059SGregory Neil Shapiro # if defined(__cplusplus) 3940266059SGregory Neil Shapiro # define __BEGIN_DECLS extern "C" { 4040266059SGregory Neil Shapiro # define __END_DECLS }; 4140266059SGregory Neil Shapiro # else /* defined(__cplusplus) */ 4240266059SGregory Neil Shapiro # define __BEGIN_DECLS 4340266059SGregory Neil Shapiro # define __END_DECLS 4440266059SGregory Neil Shapiro # endif /* defined(__cplusplus) */ 4540266059SGregory Neil Shapiro # if defined(__STDC__) || defined(__cplusplus) 46605302a5SGregory Neil Shapiro # ifndef __P 4740266059SGregory Neil Shapiro # define __P(protos) protos 48605302a5SGregory Neil Shapiro # endif /* __P */ 4940266059SGregory Neil Shapiro # define __CONCAT(x,y) x ## y 5040266059SGregory Neil Shapiro # define __STRING(x) #x 5140266059SGregory Neil Shapiro # else /* defined(__STDC__) || defined(__cplusplus) */ 5240266059SGregory Neil Shapiro # define __P(protos) () 5340266059SGregory Neil Shapiro # define __CONCAT(x,y) x/**/y 5440266059SGregory Neil Shapiro # define __STRING(x) "x" 5540266059SGregory Neil Shapiro # define const 5640266059SGregory Neil Shapiro # define signed 5740266059SGregory Neil Shapiro # define volatile 5840266059SGregory Neil Shapiro # endif /* defined(__STDC__) || defined(__cplusplus) */ 5940266059SGregory Neil Shapiro # endif /* !SM_CONF_SYS_CDEFS_H */ 6040266059SGregory Neil Shapiro 6140266059SGregory Neil Shapiro /* 6240266059SGregory Neil Shapiro ** Define SM_DEAD, a macro used to declare functions that do not return 6340266059SGregory Neil Shapiro ** to their caller. 6440266059SGregory Neil Shapiro */ 6540266059SGregory Neil Shapiro 6640266059SGregory Neil Shapiro # ifndef SM_DEAD 6740266059SGregory Neil Shapiro # if __GNUC__ >= 2 6840266059SGregory Neil Shapiro # if __GNUC__ == 2 && __GNUC_MINOR__ < 5 6940266059SGregory Neil Shapiro # define SM_DEAD(proto) volatile proto 70323f6dcbSGregory Neil Shapiro # define SM_DEAD_D volatile 7140266059SGregory Neil Shapiro # else /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ 7240266059SGregory Neil Shapiro # define SM_DEAD(proto) proto __attribute__((__noreturn__)) 73323f6dcbSGregory Neil Shapiro # define SM_DEAD_D 7440266059SGregory Neil Shapiro # endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ 7540266059SGregory Neil Shapiro # else /* __GNUC__ >= 2 */ 7640266059SGregory Neil Shapiro # define SM_DEAD(proto) proto 77323f6dcbSGregory Neil Shapiro # define SM_DEAD_D 7840266059SGregory Neil Shapiro # endif /* __GNUC__ >= 2 */ 7940266059SGregory Neil Shapiro # endif /* SM_DEAD */ 8040266059SGregory Neil Shapiro 8140266059SGregory Neil Shapiro /* 8240266059SGregory Neil Shapiro ** Define SM_UNUSED, a macro used to declare variables that may be unused. 8340266059SGregory Neil Shapiro */ 8440266059SGregory Neil Shapiro 8540266059SGregory Neil Shapiro # ifndef SM_UNUSED 8640266059SGregory Neil Shapiro # if __GNUC__ >= 2 8740266059SGregory Neil Shapiro # if __GNUC__ == 2 && __GNUC_MINOR__ < 7 8840266059SGregory Neil Shapiro # define SM_UNUSED(decl) decl 8940266059SGregory Neil Shapiro # else /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ 9040266059SGregory Neil Shapiro # define SM_UNUSED(decl) decl __attribute__((__unused__)) 9140266059SGregory Neil Shapiro # endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ 9240266059SGregory Neil Shapiro # else /* __GNUC__ >= 2 */ 9340266059SGregory Neil Shapiro # define SM_UNUSED(decl) decl 9440266059SGregory Neil Shapiro # endif /* __GNUC__ >= 2 */ 9540266059SGregory Neil Shapiro # endif /* SM_UNUSED */ 9640266059SGregory Neil Shapiro 9740266059SGregory Neil Shapiro /* 9840266059SGregory Neil Shapiro ** The SM_NONVOLATILE macro is used to declare variables that are not 9940266059SGregory Neil Shapiro ** volatile, but which must be declared volatile when compiling with 10040266059SGregory Neil Shapiro ** gcc -O -Wall in order to suppress bogus warning messages. 10140266059SGregory Neil Shapiro ** 10240266059SGregory Neil Shapiro ** Variables that actually are volatile should be declared volatile 10340266059SGregory Neil Shapiro ** using the "volatile" keyword. If a variable actually is volatile, 10440266059SGregory Neil Shapiro ** then SM_NONVOLATILE should not be used. 10540266059SGregory Neil Shapiro ** 10640266059SGregory Neil Shapiro ** To compile sendmail with gcc and see all non-bogus warnings, 10740266059SGregory Neil Shapiro ** you should use 10840266059SGregory Neil Shapiro ** gcc -O -Wall -DSM_OMIT_BOGUS_WARNINGS ... 10940266059SGregory Neil Shapiro ** Do not use -DSM_OMIT_BOGUS_WARNINGS when compiling the production 11040266059SGregory Neil Shapiro ** version of sendmail, because there is a performance hit. 11140266059SGregory Neil Shapiro */ 11240266059SGregory Neil Shapiro 11340266059SGregory Neil Shapiro # ifdef SM_OMIT_BOGUS_WARNINGS 11440266059SGregory Neil Shapiro # define SM_NONVOLATILE volatile 11540266059SGregory Neil Shapiro # else /* SM_OMIT_BOGUS_WARNINGS */ 11640266059SGregory Neil Shapiro # define SM_NONVOLATILE 11740266059SGregory Neil Shapiro # endif /* SM_OMIT_BOGUS_WARNINGS */ 11840266059SGregory Neil Shapiro 11940266059SGregory Neil Shapiro /* 12040266059SGregory Neil Shapiro ** Turn on format string argument checking. 12140266059SGregory Neil Shapiro */ 12240266059SGregory Neil Shapiro 12340266059SGregory Neil Shapiro # ifndef SM_CONF_FORMAT_TEST 12440266059SGregory Neil Shapiro # if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 12540266059SGregory Neil Shapiro # define SM_CONF_FORMAT_TEST 1 12640266059SGregory Neil Shapiro # else /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ 12740266059SGregory Neil Shapiro # define SM_CONF_FORMAT_TEST 0 12840266059SGregory Neil Shapiro # endif /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ 12940266059SGregory Neil Shapiro # endif /* SM_CONF_FORMAT_TEST */ 13040266059SGregory Neil Shapiro 13140266059SGregory Neil Shapiro # ifndef PRINTFLIKE 13240266059SGregory Neil Shapiro # if SM_CONF_FORMAT_TEST 13340266059SGregory Neil Shapiro # define PRINTFLIKE(x,y) __attribute__ ((__format__ (__printf__, x, y))) 13440266059SGregory Neil Shapiro # else /* SM_CONF_FORMAT_TEST */ 13540266059SGregory Neil Shapiro # define PRINTFLIKE(x,y) 13640266059SGregory Neil Shapiro # endif /* SM_CONF_FORMAT_TEST */ 13740266059SGregory Neil Shapiro # endif /* ! PRINTFLIKE */ 13840266059SGregory Neil Shapiro 13940266059SGregory Neil Shapiro # ifndef SCANFLIKE 14040266059SGregory Neil Shapiro # if SM_CONF_FORMAT_TEST 14140266059SGregory Neil Shapiro # define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, x, y))) 14240266059SGregory Neil Shapiro # else /* SM_CONF_FORMAT_TEST */ 14340266059SGregory Neil Shapiro # define SCANFLIKE(x,y) 14440266059SGregory Neil Shapiro # endif /* SM_CONF_FORMAT_TEST */ 14540266059SGregory Neil Shapiro # endif /* ! SCANFLIKE */ 14640266059SGregory Neil Shapiro 14740266059SGregory Neil Shapiro #endif /* ! SM_CDEFS_H */ 148