190792Sgshapiro/* 294334Sgshapiro * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. 390792Sgshapiro * All rights reserved. 490792Sgshapiro * 590792Sgshapiro * By using this file, you agree to the terms and conditions set 690792Sgshapiro * forth in the LICENSE file which can be found at the top level of 790792Sgshapiro * the sendmail distribution. 890792Sgshapiro * 9132943Sgshapiro * $Id: cdefs.h,v 1.16 2003/12/05 22:45:25 ca Exp $ 1090792Sgshapiro */ 1190792Sgshapiro 1290792Sgshapiro/* 1390792Sgshapiro** libsm C language portability macros 1490792Sgshapiro** See libsm/cdefs.html for documentation. 1590792Sgshapiro*/ 1690792Sgshapiro 1790792Sgshapiro#ifndef SM_CDEFS_H 1890792Sgshapiro# define SM_CDEFS_H 1990792Sgshapiro 2090792Sgshapiro# include <sm/config.h> 2190792Sgshapiro 2290792Sgshapiro/* 2390792Sgshapiro** BSD and Linux have <sys/cdefs.h> which defines a set of C language 2490792Sgshapiro** portability macros that are a defacto standard in the open source 2590792Sgshapiro** community. 2690792Sgshapiro*/ 2790792Sgshapiro 2890792Sgshapiro# if SM_CONF_SYS_CDEFS_H 2990792Sgshapiro# include <sys/cdefs.h> 3090792Sgshapiro# endif /* SM_CONF_SYS_CDEFS_H */ 3190792Sgshapiro 3290792Sgshapiro/* 3390792Sgshapiro** Define the standard C language portability macros 3490792Sgshapiro** for platforms that lack <sys/cdefs.h>. 3590792Sgshapiro*/ 3690792Sgshapiro 3790792Sgshapiro# if !SM_CONF_SYS_CDEFS_H 3890792Sgshapiro# if defined(__cplusplus) 3990792Sgshapiro# define __BEGIN_DECLS extern "C" { 4090792Sgshapiro# define __END_DECLS }; 4190792Sgshapiro# else /* defined(__cplusplus) */ 4290792Sgshapiro# define __BEGIN_DECLS 4390792Sgshapiro# define __END_DECLS 4490792Sgshapiro# endif /* defined(__cplusplus) */ 4590792Sgshapiro# if defined(__STDC__) || defined(__cplusplus) 4694334Sgshapiro# ifndef __P 4794334Sgshapiro# define __P(protos) protos 4894334Sgshapiro# endif /* __P */ 4990792Sgshapiro# define __CONCAT(x,y) x ## y 5090792Sgshapiro# define __STRING(x) #x 5190792Sgshapiro# else /* defined(__STDC__) || defined(__cplusplus) */ 5290792Sgshapiro# define __P(protos) () 5390792Sgshapiro# define __CONCAT(x,y) x/**/y 5490792Sgshapiro# define __STRING(x) "x" 5590792Sgshapiro# define const 5690792Sgshapiro# define signed 5790792Sgshapiro# define volatile 5890792Sgshapiro# endif /* defined(__STDC__) || defined(__cplusplus) */ 5990792Sgshapiro# endif /* !SM_CONF_SYS_CDEFS_H */ 6090792Sgshapiro 6190792Sgshapiro/* 6290792Sgshapiro** Define SM_DEAD, a macro used to declare functions that do not return 6390792Sgshapiro** to their caller. 6490792Sgshapiro*/ 6590792Sgshapiro 6690792Sgshapiro# ifndef SM_DEAD 6790792Sgshapiro# if __GNUC__ >= 2 6890792Sgshapiro# if __GNUC__ == 2 && __GNUC_MINOR__ < 5 6990792Sgshapiro# define SM_DEAD(proto) volatile proto 70125820Sgshapiro# define SM_DEAD_D volatile 7190792Sgshapiro# else /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ 7290792Sgshapiro# define SM_DEAD(proto) proto __attribute__((__noreturn__)) 73125820Sgshapiro# define SM_DEAD_D 7490792Sgshapiro# endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ 7590792Sgshapiro# else /* __GNUC__ >= 2 */ 7690792Sgshapiro# define SM_DEAD(proto) proto 77125820Sgshapiro# define SM_DEAD_D 7890792Sgshapiro# endif /* __GNUC__ >= 2 */ 7990792Sgshapiro# endif /* SM_DEAD */ 8090792Sgshapiro 8190792Sgshapiro/* 8290792Sgshapiro** Define SM_UNUSED, a macro used to declare variables that may be unused. 8390792Sgshapiro*/ 8490792Sgshapiro 8590792Sgshapiro# ifndef SM_UNUSED 8690792Sgshapiro# if __GNUC__ >= 2 8790792Sgshapiro# if __GNUC__ == 2 && __GNUC_MINOR__ < 7 8890792Sgshapiro# define SM_UNUSED(decl) decl 8990792Sgshapiro# else /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ 9090792Sgshapiro# define SM_UNUSED(decl) decl __attribute__((__unused__)) 9190792Sgshapiro# endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ 9290792Sgshapiro# else /* __GNUC__ >= 2 */ 9390792Sgshapiro# define SM_UNUSED(decl) decl 9490792Sgshapiro# endif /* __GNUC__ >= 2 */ 9590792Sgshapiro# endif /* SM_UNUSED */ 9690792Sgshapiro 9790792Sgshapiro/* 9890792Sgshapiro** The SM_NONVOLATILE macro is used to declare variables that are not 9990792Sgshapiro** volatile, but which must be declared volatile when compiling with 10090792Sgshapiro** gcc -O -Wall in order to suppress bogus warning messages. 10190792Sgshapiro** 10290792Sgshapiro** Variables that actually are volatile should be declared volatile 10390792Sgshapiro** using the "volatile" keyword. If a variable actually is volatile, 10490792Sgshapiro** then SM_NONVOLATILE should not be used. 10590792Sgshapiro** 10690792Sgshapiro** To compile sendmail with gcc and see all non-bogus warnings, 10790792Sgshapiro** you should use 10890792Sgshapiro** gcc -O -Wall -DSM_OMIT_BOGUS_WARNINGS ... 10990792Sgshapiro** Do not use -DSM_OMIT_BOGUS_WARNINGS when compiling the production 11090792Sgshapiro** version of sendmail, because there is a performance hit. 11190792Sgshapiro*/ 11290792Sgshapiro 11390792Sgshapiro# ifdef SM_OMIT_BOGUS_WARNINGS 11490792Sgshapiro# define SM_NONVOLATILE volatile 11590792Sgshapiro# else /* SM_OMIT_BOGUS_WARNINGS */ 11690792Sgshapiro# define SM_NONVOLATILE 11790792Sgshapiro# endif /* SM_OMIT_BOGUS_WARNINGS */ 11890792Sgshapiro 11990792Sgshapiro/* 12090792Sgshapiro** Turn on format string argument checking. 12190792Sgshapiro*/ 12290792Sgshapiro 12390792Sgshapiro# ifndef SM_CONF_FORMAT_TEST 12490792Sgshapiro# if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 12590792Sgshapiro# define SM_CONF_FORMAT_TEST 1 12690792Sgshapiro# else /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ 12790792Sgshapiro# define SM_CONF_FORMAT_TEST 0 12890792Sgshapiro# endif /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ 12990792Sgshapiro# endif /* SM_CONF_FORMAT_TEST */ 13090792Sgshapiro 13190792Sgshapiro# ifndef PRINTFLIKE 13290792Sgshapiro# if SM_CONF_FORMAT_TEST 13390792Sgshapiro# define PRINTFLIKE(x,y) __attribute__ ((__format__ (__printf__, x, y))) 13490792Sgshapiro# else /* SM_CONF_FORMAT_TEST */ 13590792Sgshapiro# define PRINTFLIKE(x,y) 13690792Sgshapiro# endif /* SM_CONF_FORMAT_TEST */ 13790792Sgshapiro# endif /* ! PRINTFLIKE */ 13890792Sgshapiro 13990792Sgshapiro# ifndef SCANFLIKE 14090792Sgshapiro# if SM_CONF_FORMAT_TEST 14190792Sgshapiro# define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, x, y))) 14290792Sgshapiro# else /* SM_CONF_FORMAT_TEST */ 14390792Sgshapiro# define SCANFLIKE(x,y) 14490792Sgshapiro# endif /* SM_CONF_FORMAT_TEST */ 14590792Sgshapiro# endif /* ! SCANFLIKE */ 14690792Sgshapiro 14790792Sgshapiro#endif /* ! SM_CDEFS_H */ 148