michael@574: /* michael@574: ** cdefs.h: ISO C interface michael@574: ** Most of this file was developed by Sendmail, Incorporated, so: michael@574: ** michael@574: ** Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. michael@574: ** michael@574: ** Permission to use, copy, modify, and distribute this software for michael@574: ** any purpose with or without fee is hereby granted, provided that michael@574: ** the above copyright notice and this permission notice appear in all michael@574: ** copies. michael@574: ** michael@574: ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED michael@574: ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF michael@574: ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. michael@574: ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR michael@574: ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@574: ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@574: ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF michael@574: ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND michael@574: ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, michael@574: ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT michael@574: ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@574: ** SUCH DAMAGE. michael@574: ** michael@574: */ michael@574: michael@574: /* michael@574: ** BSD and Linux already have which defines a set of C michael@574: ** language portability macros that are a defacto standard in the open michael@574: ** source community. This file allows for building on platforms lacking michael@574: ** these definitions. michael@574: */ michael@574: #ifndef HOND_CDEFS_H michael@574: # define HOND_CDEFS_H michael@574: michael@574: # if defined(__cplusplus) michael@574: # define __BEGIN_DECLS extern "C" { michael@574: # define __END_DECLS }; michael@574: # else /* defined(__cplusplus) */ michael@574: # define __BEGIN_DECLS michael@574: # define __END_DECLS michael@574: # endif /* defined(__cplusplus) */ michael@574: # if defined(__STDC__) || defined(__cplusplus) michael@574: # ifndef __P michael@574: # define __P(protos) protos michael@574: # endif /* __P */ michael@574: # define __CONCAT(x,y) x ## y michael@574: # define __STRING(x) #x michael@574: # else /* defined(__STDC__) || defined(__cplusplus) */ michael@574: # define __P(protos) () michael@574: # define __CONCAT(x,y) x/**/y michael@574: # define __STRING(x) "x" michael@574: # define const michael@574: # define signed michael@574: # define volatile michael@574: # endif /* defined(__STDC__) || defined(__cplusplus) */ michael@574: michael@574: /* michael@574: ** Define HOND_DEAD, a macro used to declare functions that do not return michael@574: ** to their caller. michael@574: */ michael@574: # ifndef HOND_DEAD michael@574: # if __GNUC__ >= 2 michael@574: # if __GNUC__ == 2 && __GNUC_MINOR__ < 5 michael@574: # define HOND_DEAD(proto) volatile proto michael@574: # else /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ michael@574: # define HOND_DEAD(proto) proto __attribute__((__noreturn__)) michael@574: # endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ michael@574: # else /* __GNUC__ >= 2 */ michael@574: # define HOND_DEAD(proto) proto michael@574: # endif /* __GNUC__ >= 2 */ michael@574: # endif /* HOND_DEAD */ michael@574: michael@574: /* michael@574: ** Define HOND_UNUSED, a macro used to declare variables that may be unused. michael@574: */ michael@574: # ifndef HOND_UNUSED michael@574: # if __GNUC__ >= 2 michael@574: # if __GNUC__ == 2 && __GNUC_MINOR__ < 7 michael@574: # define HOND_UNUSED(decl) decl michael@574: # else /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ michael@574: # define HOND_UNUSED(decl) decl __attribute__((__unused__)) michael@574: # endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ michael@574: # else /* __GNUC__ >= 2 */ michael@574: # define HOND_UNUSED(decl) decl michael@574: # endif /* __GNUC__ >= 2 */ michael@574: # endif /* HOND_UNUSED */ michael@574: michael@574: /* michael@574: ** The HOND_NONVOLATILE macro is used to declare variables that are not michael@574: ** volatile, but which must be declared volatile when compiling with michael@574: ** gcc -O -Wall in order to suppress bogus warning messages. michael@574: ** michael@574: ** Variables that actually are volatile should be declared volatile michael@574: ** using the "volatile" keyword. If a variable actually is volatile, michael@574: ** then HOND_NONVOLATILE should not be used. michael@574: ** michael@574: ** To compile source code with gcc and see all non-bogus warnings use: michael@574: ** michael@574: ** gcc -O -Wall -DHOND_OMIT_BOGUS_WARNINGS ... michael@574: ** michael@574: ** Do not use -DHOND_OMIT_BOGUS_WARNINGS when compiling production michael@574: ** software, because there is a performance hit. michael@574: */ michael@574: # ifdef HOND_OMIT_BOGUS_WARNINGS michael@574: # define HOND_NONVOLATILE volatile michael@574: # else /* HOND_OMIT_BOGUS_WARNINGS */ michael@574: # define HOND_NONVOLATILE michael@574: # endif /* HOND_OMIT_BOGUS_WARNINGS */ michael@574: michael@574: /* michael@574: ** Turn on format string argument checking. michael@574: */ michael@574: # ifndef HOND_CONF_FORMAT_TEST michael@574: # if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 michael@574: # define HOND_CONF_FORMAT_TEST 1 michael@574: # else /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ michael@574: # define HOND_CONF_FORMAT_TEST 0 michael@574: # endif /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ michael@574: # endif /* HOND_CONF_FORMAT_TEST */ michael@574: michael@574: # ifndef PRINTFLIKE michael@574: # if HOND_CONF_FORMAT_TEST michael@574: # define PRINTFLIKE(x,y) __attribute__ ((__format__ (__printf__, x, y))) michael@574: # else /* HOND_CONF_FORMAT_TEST */ michael@574: # define PRINTFLIKE(x,y) michael@574: # endif /* HOND_CONF_FORMAT_TEST */ michael@574: # endif /* ! PRINTFLIKE */ michael@574: michael@574: # ifndef SCANFLIKE michael@574: # if HOND_CONF_FORMAT_TEST michael@574: # define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, x, y))) michael@574: # else /* HOND_CONF_FORMAT_TEST */ michael@574: # define SCANFLIKE(x,y) michael@574: # endif /* HOND_CONF_FORMAT_TEST */ michael@574: # endif /* ! SCANFLIKE */ michael@574: michael@574: #endif /* ! HOND_CDEFS_H */ michael@574: