xref: /illumos-gate/usr/src/cmd/sendmail/include/sm/gen.h (revision 7c478bd9)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
13*7c478bd9Sstevel@tonic-gate 
14*7c478bd9Sstevel@tonic-gate /*
15*7c478bd9Sstevel@tonic-gate **  libsm general definitions
16*7c478bd9Sstevel@tonic-gate **  See libsm/gen.html for documentation.
17*7c478bd9Sstevel@tonic-gate */
18*7c478bd9Sstevel@tonic-gate 
19*7c478bd9Sstevel@tonic-gate #ifndef SM_GEN_H
20*7c478bd9Sstevel@tonic-gate # define SM_GEN_H
21*7c478bd9Sstevel@tonic-gate 
22*7c478bd9Sstevel@tonic-gate # include <sm/config.h>
23*7c478bd9Sstevel@tonic-gate # include <sm/cdefs.h>
24*7c478bd9Sstevel@tonic-gate # include <sm/types.h>
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate **  Define SM_RCSID and SM_IDSTR,
28*7c478bd9Sstevel@tonic-gate **  macros used to embed RCS and SCCS identification strings in object files.
29*7c478bd9Sstevel@tonic-gate */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate # ifdef lint
32*7c478bd9Sstevel@tonic-gate #  define SM_RCSID(str)
33*7c478bd9Sstevel@tonic-gate #  define SM_IDSTR(id,str)
34*7c478bd9Sstevel@tonic-gate # else /* lint */
35*7c478bd9Sstevel@tonic-gate #  define SM_RCSID(str) SM_UNUSED(static const char RcsId[]) = str;
36*7c478bd9Sstevel@tonic-gate #  define SM_IDSTR(id,str) SM_UNUSED(static const char id[]) = str;
37*7c478bd9Sstevel@tonic-gate # endif /* lint */
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate /*
40*7c478bd9Sstevel@tonic-gate **  Define NULL and offsetof (from the C89 standard)
41*7c478bd9Sstevel@tonic-gate */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate # if SM_CONF_STDDEF_H
44*7c478bd9Sstevel@tonic-gate #  include <stddef.h>
45*7c478bd9Sstevel@tonic-gate # else /* SM_CONF_STDDEF_H */
46*7c478bd9Sstevel@tonic-gate #  ifndef NULL
47*7c478bd9Sstevel@tonic-gate #   define NULL	0
48*7c478bd9Sstevel@tonic-gate #  endif /* ! NULL */
49*7c478bd9Sstevel@tonic-gate #  define offsetof(type, member)	((size_t)(&((type *)0)->member))
50*7c478bd9Sstevel@tonic-gate # endif /* SM_CONF_STDDEF_H */
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate /*
53*7c478bd9Sstevel@tonic-gate **  Define bool, true, false (from the C99 standard)
54*7c478bd9Sstevel@tonic-gate */
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate # if SM_CONF_STDBOOL_H
57*7c478bd9Sstevel@tonic-gate #  include <stdbool.h>
58*7c478bd9Sstevel@tonic-gate # else /* SM_CONF_STDBOOL_H */
59*7c478bd9Sstevel@tonic-gate #  ifndef __cplusplus
60*7c478bd9Sstevel@tonic-gate     typedef int bool;
61*7c478bd9Sstevel@tonic-gate #   define false	0
62*7c478bd9Sstevel@tonic-gate #   define true		1
63*7c478bd9Sstevel@tonic-gate #   define __bool_true_false_are_defined	1
64*7c478bd9Sstevel@tonic-gate #  endif /* ! __cplusplus */
65*7c478bd9Sstevel@tonic-gate # endif /* SM_CONF_STDBOOL_H */
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate /*
68*7c478bd9Sstevel@tonic-gate **  Define SM_MAX and SM_MIN
69*7c478bd9Sstevel@tonic-gate */
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate # define SM_MAX(a, b)	((a) > (b) ? (a) : (b))
72*7c478bd9Sstevel@tonic-gate # define SM_MIN(a, b)	((a) < (b) ? (a) : (b))
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate /* Define SM_SUCCESS and SM_FAILURE */
75*7c478bd9Sstevel@tonic-gate # define SM_SUCCESS	0
76*7c478bd9Sstevel@tonic-gate # define SM_FAILURE	(-1)
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate /* XXX This needs to be fixed when we start to use threads: */
79*7c478bd9Sstevel@tonic-gate typedef int SM_ATOMIC_INT_T;
80*7c478bd9Sstevel@tonic-gate typedef unsigned int SM_ATOMIC_UINT_T;
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate #endif /* SM_GEN_H */
83