xref: /PHP-7.4/ext/intl/intl_common.h (revision e271ace5)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | http://www.php.net/license/3_01.txt                                  |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Authors: Vadim Savchuk <vsavchuk@productengine.com>                  |
14    |          Dmitry Lakhtyuk <dlakhtyuk@productengine.com>               |
15    |          Stanislav Malyshev <stas@zend.com>                          |
16    +----------------------------------------------------------------------+
17  */
18 
19 #ifndef INTL_COMMON_H
20 #define INTL_COMMON_H
21 /* Auxiliary macros */
22 
23 BEGIN_EXTERN_C()
24 #include <php.h>
25 END_EXTERN_C()
26 #include <unicode/utypes.h>
27 
28 #ifndef UBYTES
29 # define UBYTES(len) ((len) * sizeof(UChar))
30 #endif
31 
32 #ifndef eumalloc
33 # define eumalloc(size)  (UChar*)safe_emalloc(size, sizeof(UChar), 0)
34 #endif
35 
36 #ifndef eurealloc
37 # define eurealloc(ptr, size)  (UChar*)erealloc((ptr), size * sizeof(UChar))
38 #endif
39 
40 #define USIZE(data) sizeof((data))/sizeof(UChar)
41 #define UCHARS(len) ((len) / sizeof(UChar))
42 
43 #define INTL_Z_STRVAL_P(str) (UChar*) Z_STRVAL_P(str)
44 #define INTL_Z_STRLEN_P(str) UCHARS( Z_STRLEN_P(str) )
45 
46 BEGIN_EXTERN_C()
47 extern zend_class_entry *IntlException_ce_ptr;
48 END_EXTERN_C()
49 
50 #endif /* INTL_COMMON_H */
51