1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. 3*7c478bd9Sstevel@tonic-gate * All rights reserved. 4*7c478bd9Sstevel@tonic-gate * 5*7c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 6*7c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 7*7c478bd9Sstevel@tonic-gate * the sendmail distribution. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * $Id: gen.h,v 1.23 2003/11/04 18:51:54 ca Exp $ 10*7c478bd9Sstevel@tonic-gate */ 11*7c478bd9Sstevel@tonic-gate 12*7c478bd9Sstevel@tonic-gate /* 13*7c478bd9Sstevel@tonic-gate ** libsm general definitions 14*7c478bd9Sstevel@tonic-gate ** See libsm/gen.html for documentation. 15*7c478bd9Sstevel@tonic-gate */ 16*7c478bd9Sstevel@tonic-gate 17*7c478bd9Sstevel@tonic-gate #ifndef SM_GEN_H 18*7c478bd9Sstevel@tonic-gate # define SM_GEN_H 19*7c478bd9Sstevel@tonic-gate 20*7c478bd9Sstevel@tonic-gate # include <sm/config.h> 21*7c478bd9Sstevel@tonic-gate # include <sm/cdefs.h> 22*7c478bd9Sstevel@tonic-gate # include <sm/types.h> 23*7c478bd9Sstevel@tonic-gate 24*7c478bd9Sstevel@tonic-gate /* 25*7c478bd9Sstevel@tonic-gate ** Define SM_RCSID and SM_IDSTR, 26*7c478bd9Sstevel@tonic-gate ** macros used to embed RCS and SCCS identification strings in object files. 27*7c478bd9Sstevel@tonic-gate */ 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate # ifdef lint 30*7c478bd9Sstevel@tonic-gate # define SM_RCSID(str) 31*7c478bd9Sstevel@tonic-gate # define SM_IDSTR(id,str) 32*7c478bd9Sstevel@tonic-gate # else /* lint */ 33*7c478bd9Sstevel@tonic-gate # define SM_RCSID(str) SM_UNUSED(static const char RcsId[]) = str; 34*7c478bd9Sstevel@tonic-gate # define SM_IDSTR(id,str) SM_UNUSED(static const char id[]) = str; 35*7c478bd9Sstevel@tonic-gate # endif /* lint */ 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate /* 38*7c478bd9Sstevel@tonic-gate ** Define NULL and offsetof (from the C89 standard) 39*7c478bd9Sstevel@tonic-gate */ 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate # if SM_CONF_STDDEF_H 42*7c478bd9Sstevel@tonic-gate # include <stddef.h> 43*7c478bd9Sstevel@tonic-gate # else /* SM_CONF_STDDEF_H */ 44*7c478bd9Sstevel@tonic-gate # ifndef NULL 45*7c478bd9Sstevel@tonic-gate # define NULL 0 46*7c478bd9Sstevel@tonic-gate # endif /* ! NULL */ 47*7c478bd9Sstevel@tonic-gate # define offsetof(type, member) ((size_t)(&((type *)0)->member)) 48*7c478bd9Sstevel@tonic-gate # endif /* SM_CONF_STDDEF_H */ 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate /* 51*7c478bd9Sstevel@tonic-gate ** Define bool, true, false (from the C99 standard) 52*7c478bd9Sstevel@tonic-gate */ 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate # if SM_CONF_STDBOOL_H 55*7c478bd9Sstevel@tonic-gate # include <stdbool.h> 56*7c478bd9Sstevel@tonic-gate # else /* SM_CONF_STDBOOL_H */ 57*7c478bd9Sstevel@tonic-gate # ifndef __cplusplus 58*7c478bd9Sstevel@tonic-gate typedef int bool; 59*7c478bd9Sstevel@tonic-gate # define false 0 60*7c478bd9Sstevel@tonic-gate # define true 1 61*7c478bd9Sstevel@tonic-gate # define __bool_true_false_are_defined 1 62*7c478bd9Sstevel@tonic-gate # endif /* ! __cplusplus */ 63*7c478bd9Sstevel@tonic-gate # endif /* SM_CONF_STDBOOL_H */ 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate /* 66*7c478bd9Sstevel@tonic-gate ** Define SM_MAX and SM_MIN 67*7c478bd9Sstevel@tonic-gate */ 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate # define SM_MAX(a, b) ((a) > (b) ? (a) : (b)) 70*7c478bd9Sstevel@tonic-gate # define SM_MIN(a, b) ((a) < (b) ? (a) : (b)) 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate /* Define SM_SUCCESS and SM_FAILURE */ 73*7c478bd9Sstevel@tonic-gate # define SM_SUCCESS 0 74*7c478bd9Sstevel@tonic-gate # define SM_FAILURE (-1) 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate /* XXX This needs to be fixed when we start to use threads: */ 77*7c478bd9Sstevel@tonic-gate typedef int SM_ATOMIC_INT_T; 78*7c478bd9Sstevel@tonic-gate typedef unsigned int SM_ATOMIC_UINT_T; 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate #endif /* SM_GEN_H */ 81