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., 59 Temple Place, Suite 330,
28 * Boston, MA 02111-1307, 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 (defined(WIN32)) || (defined(_WIN32_WCE))
49 # define FRIBIDI_ENTRY __declspec(dllexport)
52 #if FRIBIDI_USE_GLIB+0
54 # define SIZEOF_LONG GLIB_SIZEOF_LONG
55 # endif /* !SIZEOF_LONG */
56 # ifndef SIZEOF_VOID_P
57 # define SIZEOF_VOID_P GLIB_SIZEOF_VOID_P
58 # endif /* !SIZEOF_VOID_P */
59 # ifndef __FRIBIDI_DOC
61 # endif /* !__FRIBIDI_DOC */
62 # ifndef fribidi_malloc
63 # define fribidi_malloc g_try_malloc
64 # define fribidi_free g_free
65 # endif /* !fribidi_malloc */
66 # ifndef fribidi_assert
67 # ifndef __FRIBIDI_DOC
69 # endif /* !__FRIBIDI_DOC */
70 # define fribidi_assert g_assert
71 # endif /* !fribidi_assert */
72 # ifndef __FRIBIDI_DOC
74 # endif /* !__FRIBIDI_DOC */
75 # ifndef FRIBIDI_BEGIN_STMT
76 # define FRIBIDI_BEGIN_STMT G_STMT_START {
77 # define FRIBIDI_END_STMT } G_STMT_END
78 # endif /* !FRIBIDI_BEGIN_STMT */
80 # define LIKELY G_LIKELY
81 # define UNLIKELY G_UNLIKELY
89 #endif /* FRIBIDI_USE_GLIB */
95 # define true (!false)
101 # else /* !__cplusplus */
102 # define NULL ((void*) 0)
103 # endif /* !__cplusplus */
106 /* fribidi_malloc and fribidi_free should be used instead of malloc and free.
107 * No need to include any headers. */
108 #ifndef fribidi_malloc
110 # ifndef __FRIBIDI_DOC
112 # endif /* __FRIBIDI_DOC */
113 # define fribidi_malloc malloc
114 # else /* !HAVE_STDLIB_H */
115 # define fribidi_malloc (void *) malloc
116 # endif /* !HAVE_STDLIB_H */
117 # define fribidi_free free
118 #else /* fribidi_malloc */
119 # ifndef fribidi_free
120 # error You should define fribidi_free too when you define fribidi_malloc.
121 # endif /* !fribidi_free */
122 #endif /* fribidi_malloc */
125 # if !STDC_HEADERS && HAVE_MEMORY_H
131 # include <strings.h>
134 /* FRIBIDI_CHUNK_SIZE is the number of bytes in each chunk of memory being
135 * allocated for data structure pools. */
136 #ifndef FRIBIDI_CHUNK_SIZE
138 # ifndef __FRIBIDI_DOC
139 # include <asm/page.h>
140 # endif /* __FRIBIDI_DOC */
141 # define FRIBIDI_CHUNK_SIZE (PAGE_SIZE - 16)
142 # else /* !HAVE_ASM_PAGE_H */
143 # define FRIBIDI_CHUNK_SIZE (4096 - 16)
144 # endif /* !HAVE_ASM_PAGE_H */
145 #else /* FRIBIDI_CHUNK_SIZE */
146 # if FRIBIDI_CHUNK_SIZE < 256
147 # error FRIBIDI_CHUNK_SIZE now should define the size of a chunk in bytes.
148 # endif /* FRIBIDI_CHUNK_SIZE < 256 */
149 #endif /* FRIBIDI_CHUNK_SIZE */
151 /* FRIBIDI_BEGIN_STMT should be used at the beginning of your macro
152 * definitions that are to behave like simple statements. Use
153 * FRIBIDI_END_STMT at the end of the macro after the semicolon or brace. */
154 #ifndef FRIBIDI_BEGIN_STMT
155 # define FRIBIDI_BEGIN_STMT do {
156 # define FRIBIDI_END_STMT } while (0)
157 #endif /* !FRIBIDI_BEGIN_STMT */
159 /* LIKEYLY and UNLIKELY are used to give a hint on branch prediction to the
166 #ifndef FRIBIDI_EMPTY_STMT
167 # define FRIBIDI_EMPTY_STMT FRIBIDI_BEGIN_STMT (void) 0; FRIBIDI_END_STMT
168 #endif /* !FRIBIDI_EMPTY_STMT */
171 # define STRINGIZE(symbol) #symbol
172 #else /* !HAVE_STRINGIZE */
173 # define STRINGIZE(symbol) (no stringize operator available)
174 #endif /* !HAVE_STRINGIZE */
176 /* As per recommendation of GNU Coding Standards. */
179 #endif /* !_GNU_SOURCE */
181 /* We respect our own rules. */
182 #define FRIBIDI_NO_DEPRECATED
187 #endif /* !_COMMON_H */
188 /* Editor directions:
189 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent