2 * common.h - common include for library sources
4 * $Id: common.h,v 1.21 2010-02-24 19:40:04 behdad Exp $
6 * $Date: 2010-02-24 19:40:04 $
8 * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/common.h,v $
11 * Behdad Esfahbod, 2004
13 * Copyright (C) 2004 Sharif FarsiWeb, Inc.
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public License
26 * along with this library, in a file named COPYING; if not, write to the
27 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28 * Boston, MA 02110-1301, USA
30 * For licensing issues, contact <license@farsiweb.info>.
39 #include <fribidi-common.h>
41 /* FRIBIDI_PRIVATESPACE is a macro used to name library internal symbols. */
42 #ifndef FRIBIDI_PRIVATESPACE
43 # define FRIBIDI_PRIVATESPACE1(A,B) A##B
44 # define FRIBIDI_PRIVATESPACE0(A,B) FRIBIDI_PRIVATESPACE1(A,B)
45 # define FRIBIDI_PRIVATESPACE(SYMBOL) FRIBIDI_PRIVATESPACE0(_,FRIBIDI_NAMESPACE(_##SYMBOL##__internal__))
46 #endif /* !FRIBIDI_PRIVATESPACE */
48 #if FRIBIDI_USE_GLIB+0
50 # define SIZEOF_LONG GLIB_SIZEOF_LONG
51 # endif /* !SIZEOF_LONG */
52 # ifndef SIZEOF_VOID_P
53 # define SIZEOF_VOID_P GLIB_SIZEOF_VOID_P
54 # endif /* !SIZEOF_VOID_P */
55 # ifndef __FRIBIDI_DOC
57 # endif /* !__FRIBIDI_DOC */
58 # ifndef fribidi_malloc
59 # define fribidi_malloc g_try_malloc
60 # define fribidi_free g_free
61 # endif /* !fribidi_malloc */
62 # ifndef fribidi_assert
63 # ifndef __FRIBIDI_DOC
65 # endif /* !__FRIBIDI_DOC */
66 # define fribidi_assert g_assert
67 # endif /* !fribidi_assert */
68 # ifndef __FRIBIDI_DOC
70 # endif /* !__FRIBIDI_DOC */
71 # ifndef FRIBIDI_BEGIN_STMT
72 # define FRIBIDI_BEGIN_STMT G_STMT_START {
73 # define FRIBIDI_END_STMT } G_STMT_END
74 # endif /* !FRIBIDI_BEGIN_STMT */
76 # define LIKELY G_LIKELY
77 # define UNLIKELY G_UNLIKELY
85 #endif /* FRIBIDI_USE_GLIB */
91 # define true (!false)
97 # else /* !__cplusplus */
98 # define NULL ((void*) 0)
99 # endif /* !__cplusplus */
102 /* fribidi_malloc and fribidi_free should be used instead of malloc and free.
103 * No need to include any headers. */
104 #ifndef fribidi_malloc
106 # ifndef __FRIBIDI_DOC
108 # endif /* __FRIBIDI_DOC */
109 # define fribidi_malloc malloc
110 # else /* !HAVE_STDLIB_H */
111 # define fribidi_malloc (void *) malloc
112 # endif /* !HAVE_STDLIB_H */
113 # define fribidi_free free
114 #else /* fribidi_malloc */
115 # ifndef fribidi_free
116 # error You should define fribidi_free too when you define fribidi_malloc.
117 # endif /* !fribidi_free */
118 #endif /* fribidi_malloc */
121 # if !STDC_HEADERS && HAVE_MEMORY_H
127 # include <strings.h>
130 /* FRIBIDI_CHUNK_SIZE is the number of bytes in each chunk of memory being
131 * allocated for data structure pools. */
132 #ifndef FRIBIDI_CHUNK_SIZE
134 # ifndef __FRIBIDI_DOC
135 # include <asm/page.h>
136 # endif /* __FRIBIDI_DOC */
137 # define FRIBIDI_CHUNK_SIZE (PAGE_SIZE - 16)
138 # else /* !HAVE_ASM_PAGE_H */
139 # define FRIBIDI_CHUNK_SIZE (4096 - 16)
140 # endif /* !HAVE_ASM_PAGE_H */
141 #else /* FRIBIDI_CHUNK_SIZE */
142 # if FRIBIDI_CHUNK_SIZE < 256
143 # error FRIBIDI_CHUNK_SIZE now should define the size of a chunk in bytes.
144 # endif /* FRIBIDI_CHUNK_SIZE < 256 */
145 #endif /* FRIBIDI_CHUNK_SIZE */
147 /* FRIBIDI_BEGIN_STMT should be used at the beginning of your macro
148 * definitions that are to behave like simple statements. Use
149 * FRIBIDI_END_STMT at the end of the macro after the semicolon or brace. */
150 #ifndef FRIBIDI_BEGIN_STMT
151 # define FRIBIDI_BEGIN_STMT do {
152 # define FRIBIDI_END_STMT } while (0)
153 #endif /* !FRIBIDI_BEGIN_STMT */
155 /* LIKEYLY and UNLIKELY are used to give a hint on branch prediction to the
162 #ifndef FRIBIDI_EMPTY_STMT
163 # define FRIBIDI_EMPTY_STMT FRIBIDI_BEGIN_STMT (void) 0; FRIBIDI_END_STMT
164 #endif /* !FRIBIDI_EMPTY_STMT */
167 # define STRINGIZE(symbol) #symbol
168 #else /* !HAVE_STRINGIZE */
169 # define STRINGIZE(symbol) (no stringize operator available)
170 #endif /* !HAVE_STRINGIZE */
172 /* As per recommendation of GNU Coding Standards. */
175 #endif /* !_GNU_SOURCE */
177 /* We respect our own rules. */
178 #define FRIBIDI_NO_DEPRECATED
183 #endif /* !_COMMON_H */
184 /* Editor directions:
185 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent