OSDN Git Service

remade more type safe function
[ccunit/ccunit.git] / src / ccunit / CCUnitConfig.h
1 /* -*- C -*- */
2 /* Copyright (C) 2003 TSUTSUMI Kikuo.
3    This file is part of the CCUnit Library.
4
5    The CCUnit Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public License
7    as published by the Free Software Foundation; either version 2.1 of
8    the License, or (at your option) any later version.
9
10    The CCUnit Library is distributed in the hope that it will be
11    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the CCUnit Library; see the file COPYING.LESSER.
17    If not, write to the Free Software Foundation, Inc., 59 Temple
18    Place - Suite 330, Boston, MA 02111-1307, USA.  
19 */
20
21 /*
22  * $Id$
23  */
24
25 /** @file
26  * CCUnit configrations.
27  */
28 #ifndef CCUNITCONFIG_H
29 #define CCUNITCONFIG_H
30
31 #include <ccunit/config.h>
32
33 #if WITH_DMALLOC
34 #  include <dmalloc.h>
35 #endif
36
37 #if STDC_HEADERS
38 #include <stdlib.h>
39 #include <string.h>
40 #endif
41
42 #if HAVE_STDBOOL_H
43 #include <stdbool.h>
44 #elif defined (__cplusplus)
45 #elif HAVE__BOOL
46 #define bool _Bool                              /**< boolean */
47 #define true ((bool)1)                          /**< true */
48 #define false ((bool)0)                         /**< false */
49 #elif !defined (bool)
50 #define bool int                                /**< boolean */
51 #define true (1)                                /**< true */
52 #define false (0)                               /**< false */
53 #endif
54
55 #ifndef HAVE_U_CHAR
56 typedef unsigned char u_char;
57 #endif
58 #ifndef HAVE_U_INT
59 typedef unsigned int u_int;
60 #endif
61 #ifndef HAVE_U_SHORT
62 typedef unsigned short u_short;
63 #endif
64 #ifndef HAVE_U_LONG
65 typedef unsigned long u_long;
66 #endif
67
68 typedef char* _ccunit_str_t;
69 typedef void* _ccunit_ptr_t;
70
71 #define _CCUNIT_CONCAT(A,B) A ## B
72 #define _CCUNIT_TOSTR(S) #S
73
74 /**
75  * safty free memory.
76  * Omits dmalloc's free(NULL) warning.
77  * @param p [in/out] pointer to free. and set NULL.
78  */
79 #define safe_free(p) (!p ? NULL : (free (p), p = NULL))
80
81 /**
82  * safty strdup. Tries not to pass NULL to strdup.
83  * @param s string to duplicate.
84  * @return duplicated string, or NULL when error occured.
85  */
86 #define safe_strdup(s) (!s ? NULL : strdup (s))
87
88 #endif