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