1N/A/*
1N/A * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
1N/A * All rights reserved.
1N/A *
1N/A * By using this file, you agree to the terms and conditions set
1N/A * forth in the LICENSE file which can be found at the top level of
1N/A * the sendmail distribution.
1N/A *
1N/A * $Id: cdefs.h,v 1.15.2.1 2003/12/05 22:44:17 ca Exp $
1N/A */
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A/*
1N/A** libsm C language portability macros
1N/A** See libsm/cdefs.html for documentation.
1N/A*/
1N/A
1N/A#ifndef SM_CDEFS_H
1N/A# define SM_CDEFS_H
1N/A
1N/A# include <sm/config.h>
1N/A
1N/A/*
1N/A** BSD and Linux have <sys/cdefs.h> which defines a set of C language
1N/A** portability macros that are a defacto standard in the open source
1N/A** community.
1N/A*/
1N/A
1N/A# if SM_CONF_SYS_CDEFS_H
1N/A# include <sys/cdefs.h>
1N/A# endif /* SM_CONF_SYS_CDEFS_H */
1N/A
1N/A/*
1N/A** Define the standard C language portability macros
1N/A** for platforms that lack <sys/cdefs.h>.
1N/A*/
1N/A
1N/A# if !SM_CONF_SYS_CDEFS_H
1N/A# if defined(__cplusplus)
1N/A# define __BEGIN_DECLS extern "C" {
1N/A# define __END_DECLS };
1N/A# else /* defined(__cplusplus) */
1N/A# define __BEGIN_DECLS
1N/A# define __END_DECLS
1N/A# endif /* defined(__cplusplus) */
1N/A# if defined(__STDC__) || defined(__cplusplus)
1N/A# ifndef __P
1N/A# define __P(protos) protos
1N/A# endif /* __P */
1N/A# define __CONCAT(x,y) x ## y
1N/A# define __STRING(x) #x
1N/A# else /* defined(__STDC__) || defined(__cplusplus) */
1N/A# define __P(protos) ()
1N/A# define __CONCAT(x,y) x/**/y
1N/A# define __STRING(x) "x"
1N/A# define const
1N/A# define signed
1N/A# define volatile
1N/A# endif /* defined(__STDC__) || defined(__cplusplus) */
1N/A# endif /* !SM_CONF_SYS_CDEFS_H */
1N/A
1N/A/*
1N/A** Define SM_DEAD, a macro used to declare functions that do not return
1N/A** to their caller.
1N/A*/
1N/A
1N/A# ifndef SM_DEAD
1N/A# if __GNUC__ >= 2
1N/A# if __GNUC__ == 2 && __GNUC_MINOR__ < 5
1N/A# define SM_DEAD(proto) volatile proto
1N/A# define SM_DEAD_D volatile
1N/A# else /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */
1N/A# define SM_DEAD(proto) proto __attribute__((__noreturn__))
1N/A# define SM_DEAD_D
1N/A# endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */
1N/A# else /* __GNUC__ >= 2 */
1N/A# define SM_DEAD(proto) proto
1N/A# define SM_DEAD_D
1N/A# endif /* __GNUC__ >= 2 */
1N/A# endif /* SM_DEAD */
1N/A
1N/A/*
1N/A** Define SM_UNUSED, a macro used to declare variables that may be unused.
1N/A*/
1N/A
1N/A# ifndef SM_UNUSED
1N/A# if __GNUC__ >= 2
1N/A# if __GNUC__ == 2 && __GNUC_MINOR__ < 7
1N/A# define SM_UNUSED(decl) decl
1N/A# else /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */
1N/A# define SM_UNUSED(decl) decl __attribute__((__unused__))
1N/A# endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */
1N/A# else /* __GNUC__ >= 2 */
1N/A# define SM_UNUSED(decl) decl
1N/A# endif /* __GNUC__ >= 2 */
1N/A# endif /* SM_UNUSED */
1N/A
1N/A/*
1N/A** The SM_NONVOLATILE macro is used to declare variables that are not
1N/A** volatile, but which must be declared volatile when compiling with
1N/A** gcc -O -Wall in order to suppress bogus warning messages.
1N/A**
1N/A** Variables that actually are volatile should be declared volatile
1N/A** using the "volatile" keyword. If a variable actually is volatile,
1N/A** then SM_NONVOLATILE should not be used.
1N/A**
1N/A** To compile sendmail with gcc and see all non-bogus warnings,
1N/A** you should use
1N/A** gcc -O -Wall -DSM_OMIT_BOGUS_WARNINGS ...
1N/A** Do not use -DSM_OMIT_BOGUS_WARNINGS when compiling the production
1N/A** version of sendmail, because there is a performance hit.
1N/A*/
1N/A
1N/A# ifdef SM_OMIT_BOGUS_WARNINGS
1N/A# define SM_NONVOLATILE volatile
1N/A# else /* SM_OMIT_BOGUS_WARNINGS */
1N/A# define SM_NONVOLATILE
1N/A# endif /* SM_OMIT_BOGUS_WARNINGS */
1N/A
1N/A/*
1N/A** Turn on format string argument checking.
1N/A*/
1N/A
1N/A# ifndef SM_CONF_FORMAT_TEST
1N/A# if __GNUC__ == 2 && __GNUC_MINOR__ >= 7
1N/A# define SM_CONF_FORMAT_TEST 1
1N/A# else /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */
1N/A# define SM_CONF_FORMAT_TEST 0
1N/A# endif /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */
1N/A# endif /* SM_CONF_FORMAT_TEST */
1N/A
1N/A# ifndef PRINTFLIKE
1N/A# if SM_CONF_FORMAT_TEST
1N/A# define PRINTFLIKE(x,y) __attribute__ ((__format__ (__printf__, x, y)))
1N/A# else /* SM_CONF_FORMAT_TEST */
1N/A# define PRINTFLIKE(x,y)
1N/A# endif /* SM_CONF_FORMAT_TEST */
1N/A# endif /* ! PRINTFLIKE */
1N/A
1N/A# ifndef SCANFLIKE
1N/A# if SM_CONF_FORMAT_TEST
1N/A# define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, x, y)))
1N/A# else /* SM_CONF_FORMAT_TEST */
1N/A# define SCANFLIKE(x,y)
1N/A# endif /* SM_CONF_FORMAT_TEST */
1N/A# endif /* ! SCANFLIKE */
1N/A
1N/A#endif /* ! SM_CDEFS_H */