X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fcommon.h;h=c05e692ec675d73abd701313b19fccc69a71ca19;hb=54a0ffce86e436416ab1a7fa14562fe8a69eeddf;hp=3e484b03d389ff14a0443874737c3724b1b39f7d;hpb=c93352a5fa892a505dc3d04a651f59f1545e8251;p=platform%2Fupstream%2Ffribidi.git diff --git a/lib/common.h b/lib/common.h index 3e484b0..c05e692 100644 --- a/lib/common.h +++ b/lib/common.h @@ -1,12 +1,6 @@ /* FriBidi * common.h - common include for library sources * - * $Id: common.h,v 1.21 2010-02-24 19:40:04 behdad Exp $ - * $Author: behdad $ - * $Date: 2010-02-24 19:40:04 $ - * $Revision: 1.21 $ - * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/common.h,v $ - * * Author: * Behdad Esfahbod, 2004 * @@ -27,63 +21,17 @@ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA * - * For licensing issues, contact . + * For licensing issues, contact . */ #ifndef _COMMON_H #define _COMMON_H -#if HAVE_CONFIG_H+0 +#ifdef HAVE_CONFIG_H # include #endif #include -/* FRIBIDI_PRIVATESPACE is a macro used to name library internal symbols. */ -#ifndef FRIBIDI_PRIVATESPACE -# define FRIBIDI_PRIVATESPACE1(A,B) A##B -# define FRIBIDI_PRIVATESPACE0(A,B) FRIBIDI_PRIVATESPACE1(A,B) -# define FRIBIDI_PRIVATESPACE(SYMBOL) FRIBIDI_PRIVATESPACE0(_,FRIBIDI_NAMESPACE(_##SYMBOL##__internal__)) -#endif /* !FRIBIDI_PRIVATESPACE */ - -#if FRIBIDI_USE_GLIB+0 -# ifndef SIZEOF_LONG -# define SIZEOF_LONG GLIB_SIZEOF_LONG -# endif /* !SIZEOF_LONG */ -# ifndef SIZEOF_VOID_P -# define SIZEOF_VOID_P GLIB_SIZEOF_VOID_P -# endif /* !SIZEOF_VOID_P */ -# ifndef __FRIBIDI_DOC -# include -# endif /* !__FRIBIDI_DOC */ -# ifndef fribidi_malloc -# define fribidi_malloc g_try_malloc -# define fribidi_free g_free -# endif /* !fribidi_malloc */ -# ifndef fribidi_assert -# ifndef __FRIBIDI_DOC -# include -# endif /* !__FRIBIDI_DOC */ -# define fribidi_assert g_assert -# endif /* !fribidi_assert */ -# ifndef __FRIBIDI_DOC -# include -# endif /* !__FRIBIDI_DOC */ -# ifndef FRIBIDI_BEGIN_STMT -# define FRIBIDI_BEGIN_STMT G_STMT_START { -# define FRIBIDI_END_STMT } G_STMT_END -# endif /* !FRIBIDI_BEGIN_STMT */ -# ifndef LIKELY -# define LIKELY G_LIKELY -# define UNLIKELY G_UNLIKELY -# endif /* !LIKELY */ -# ifndef false -# define false FALSE -# endif /* !false */ -# ifndef true -# define true TRUE -# endif /* !true */ -#endif /* FRIBIDI_USE_GLIB */ - #ifndef false # define false (0) # endif /* !false */ @@ -113,37 +61,20 @@ # define fribidi_free free #else /* fribidi_malloc */ # ifndef fribidi_free -# error You should define fribidi_free too when you define fribidi_malloc. +# error "You should define fribidi_free too when you define fribidi_malloc." # endif /* !fribidi_free */ #endif /* fribidi_malloc */ -#if HAVE_STRING_H+0 +#ifdef HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif -#if HAVE_STRINGS_H+0 +#ifdef HAVE_STRINGS_H # include #endif -/* FRIBIDI_CHUNK_SIZE is the number of bytes in each chunk of memory being - * allocated for data structure pools. */ -#ifndef FRIBIDI_CHUNK_SIZE -# if HAVE_ASM_PAGE_H -# ifndef __FRIBIDI_DOC -# include -# endif /* __FRIBIDI_DOC */ -# define FRIBIDI_CHUNK_SIZE (PAGE_SIZE - 16) -# else /* !HAVE_ASM_PAGE_H */ -# define FRIBIDI_CHUNK_SIZE (4096 - 16) -# endif /* !HAVE_ASM_PAGE_H */ -#else /* FRIBIDI_CHUNK_SIZE */ -# if FRIBIDI_CHUNK_SIZE < 256 -# error FRIBIDI_CHUNK_SIZE now should define the size of a chunk in bytes. -# endif /* FRIBIDI_CHUNK_SIZE < 256 */ -#endif /* FRIBIDI_CHUNK_SIZE */ - /* FRIBIDI_BEGIN_STMT should be used at the beginning of your macro * definitions that are to behave like simple statements. Use * FRIBIDI_END_STMT at the end of the macro after the semicolon or brace. */ @@ -155,18 +86,32 @@ /* LIKEYLY and UNLIKELY are used to give a hint on branch prediction to the * compiler. */ #ifndef LIKELY -# define LIKELY -# define UNLIKELY +# if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) +# define FRIBIDI_BOOLEAN_EXPR(expr) \ + __extension__ ({ \ + int fribidi_bool_var; \ + if (expr) \ + fribidi_bool_var = 1; \ + else \ + fribidi_bool_var = 0; \ + fribidi_bool_var; \ + }) +# define LIKELY(expr) (__builtin_expect (FRIBIDI_BOOLEAN_EXPR(expr), 1)) +# define UNLIKELY(expr) (__builtin_expect (FRIBIDI_BOOLEAN_EXPR(expr), 0)) +# else +# define LIKELY +# define UNLIKELY +# endif /* _GNUC_ */ #endif /* !LIKELY */ #ifndef FRIBIDI_EMPTY_STMT # define FRIBIDI_EMPTY_STMT FRIBIDI_BEGIN_STMT (void) 0; FRIBIDI_END_STMT #endif /* !FRIBIDI_EMPTY_STMT */ -#if HAVE_STRINGIZE+0 +#ifdef HAVE_STRINGIZE # define STRINGIZE(symbol) #symbol #else /* !HAVE_STRINGIZE */ -# define STRINGIZE(symbol) (no stringize operator available) +# error "No stringize operator available?" #endif /* !HAVE_STRINGIZE */ /* As per recommendation of GNU Coding Standards. */ @@ -175,7 +120,9 @@ #endif /* !_GNU_SOURCE */ /* We respect our own rules. */ -#define FRIBIDI_NO_DEPRECATED +#ifndef FRIBIDI_NO_DEPRECATED +# define FRIBIDI_NO_DEPRECATED +#endif /* !FRIBIDI_NO_DEPRECATED */ #include "debug.h"