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