1 /* 2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg 3 * Copyright (C) 2006 Behdad Esfahbod 4 * 5 * This is part of HarfBuzz, an OpenType Layout engine library. 6 * 7 * Permission is hereby granted, without written agreement and without 8 * license or royalty fees, to use, copy, modify, and distribute this 9 * software and its documentation for any purpose, provided that the 10 * above copyright notice and the following two paragraphs appear in 11 * all copies of this software. 12 * 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 17 * DAMAGE. 18 * 19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 24 */ 25 26 #ifndef HARFBUZZ_IMPL_H 27 #define HARFBUZZ_IMPL_H 28 29 #include "harfbuzz-global.h" 30 31 #include <stdlib.h> 32 33 HB_BEGIN_HEADER 34 35 #ifndef HB_INTERNAL 36 # ifndef __MINGW32__ 37 # define HB_INTERNAL __attribute__((__visibility__("hidden"))) 38 # else 39 # define HB_INTERNAL 40 # endif 41 #endif 42 43 #ifndef NULL 44 # define NULL ((void *)0) 45 #endif 46 47 #ifndef FALSE 48 # define FALSE 0 49 #endif 50 51 #ifndef TRUE 52 # define TRUE 1 53 #endif 54 55 #ifndef TTAG_GDEF 56 # define TTAG_GDEF HB_MAKE_TAG( 'G', 'D', 'E', 'F' ) 57 #endif 58 #ifndef TTAG_GPOS 59 # define TTAG_GPOS HB_MAKE_TAG( 'G', 'P', 'O', 'S' ) 60 #endif 61 #ifndef TTAG_GSUB 62 # define TTAG_GSUB HB_MAKE_TAG( 'G', 'S', 'U', 'B' ) 63 #endif 64 65 #ifndef HB_UNUSED 66 # define HB_UNUSED(arg) ((arg) = (arg)) 67 #endif 68 69 #define HB_LIKELY(cond) (cond) 70 #define HB_UNLIKELY(cond) (cond) 71 72 #define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0])) 73 74 75 76 #define HB_IsHighSurrogate(ucs) \ 77 (((ucs) & 0xfc00) == 0xd800) 78 79 #define HB_IsLowSurrogate(ucs) \ 80 (((ucs) & 0xfc00) == 0xdc00) 81 82 #define HB_SurrogateToUcs4(high, low) \ 83 (((HB_UChar32)(high))<<10) + (low) - 0x35fdc00; 84 85 86 87 88 89 #define ALLOC(_ptr,_size) \ 90 ( (_ptr) = _hb_alloc( _size, &error ), error != 0 ) 91 92 #define REALLOC(_ptr,_newsz) \ 93 ( (_ptr) = _hb_realloc( (_ptr), (_newsz), &error ), error != 0 ) 94 95 #define FREE(_ptr) \ 96 do { \ 97 if ( (_ptr) ) \ 98 { \ 99 _hb_free( _ptr ); \ 100 _ptr = NULL; \ 101 } \ 102 } while (0) 103 104 #define ALLOC_ARRAY(_ptr,_count,_type) \ 105 ALLOC(_ptr,(_count)*sizeof(_type)) 106 107 #define REALLOC_ARRAY(_ptr,_newcnt,_type) \ 108 REALLOC(_ptr,(_newcnt)*sizeof(_type)) 109 110 #define MEM_Copy(dest,source,count) memcpy( (char*)(dest), (const char*)(source), (size_t)(count) ) 111 112 #define ERR(err) _hb_err (err) 113 114 115 HB_INTERNAL HB_Pointer 116 _hb_alloc( size_t size, 117 HB_Error *perror_ ); 118 119 HB_INTERNAL HB_Pointer 120 _hb_realloc( HB_Pointer block, 121 size_t new_size, 122 HB_Error *perror_ ); 123 124 HB_INTERNAL void 125 _hb_free( HB_Pointer block ); 126 127 128 /* helper func to set a breakpoint on */ 129 HB_INTERNAL HB_Error 130 _hb_err (HB_Error code); 131 132 133 HB_END_HEADER 134 135 #endif /* HARFBUZZ_IMPL_H */ 136