xref: /PHP-8.1/Zend/zend_strtod_int.h (revision f91f7260)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) Zend Technologies Ltd. (http://www.zend.com)           |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 2.00 of the Zend license,     |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.zend.com/license/2_00.txt.                                |
11    | If you did not receive a copy of the Zend license and are unable to  |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@zend.com so we can mail you a copy immediately.              |
14    +----------------------------------------------------------------------+
15    | Authors: Anatol Belski <ab@php.net>                                  |
16    +----------------------------------------------------------------------+
17 */
18 
19 #ifndef ZEND_STRTOD_INT_H
20 #define ZEND_STRTOD_INT_H
21 
22 #ifdef ZTS
23 #include <TSRM.h>
24 #endif
25 
26 #include <stddef.h>
27 #include <stdio.h>
28 #include <ctype.h>
29 #include <stdarg.h>
30 #include <math.h>
31 
32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
35 
36 /* TODO check to undef this option, this might
37 	make more perf. destroy_freelist()
38 	should be adapted then. */
39 #define Omit_Private_Memory 1
40 
41 /* HEX strings aren't supported as per
42 	https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings */
43 #define NO_HEX_FP 1
44 
45 #include <inttypes.h>
46 
47 #ifndef HAVE_INT32_T
48 # if SIZEOF_INT == 4
49 typedef int int32_t;
50 # elif SIZEOF_LONG == 4
51 typedef long int int32_t;
52 # endif
53 #endif
54 
55 #ifndef HAVE_UINT32_T
56 # if SIZEOF_INT == 4
57 typedef unsigned int uint32_t;
58 # elif SIZEOF_LONG == 4
59 typedef unsigned long int uint32_t;
60 # endif
61 #endif
62 
63 #ifdef USE_LOCALE
64 #undef USE_LOCALE
65 #endif
66 
67 #ifndef NO_INFNAN_CHECK
68 #define NO_INFNAN_CHECK
69 #endif
70 
71 #ifndef NO_ERRNO
72 #define NO_ERRNO
73 #endif
74 
75 #ifdef WORDS_BIGENDIAN
76 #define IEEE_BIG_ENDIAN 1
77 #else
78 #define IEEE_LITTLE_ENDIAN 1
79 #endif
80 
81 #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
82 # if defined(__LITTLE_ENDIAN__)
83 #  undef WORDS_BIGENDIAN
84 # else
85 #  if defined(__BIG_ENDIAN__)
86 #   define WORDS_BIGENDIAN
87 #  endif
88 # endif
89 #endif
90 
91 #if defined(__arm__) && !defined(__VFP_FP__)
92 /*
93  *  * Although the CPU is little endian the FP has different
94  *   * byte and word endianness. The byte order is still little endian
95  *    * but the word order is big endian.
96  *     */
97 #define IEEE_BIG_ENDIAN
98 #undef IEEE_LITTLE_ENDIAN
99 #endif
100 
101 #ifdef __vax__
102 #define VAX
103 #undef IEEE_LITTLE_ENDIAN
104 #endif
105 
106 #ifdef IEEE_LITTLE_ENDIAN
107 #define IEEE_8087 1
108 #endif
109 
110 #ifdef IEEE_BIG_ENDIAN
111 #define IEEE_MC68k 1
112 #endif
113 
114 #if defined(_MSC_VER)
115 #ifndef int32_t
116 #define int32_t __int32
117 #endif
118 #ifndef uint32_t
119 #define uint32_t unsigned __int32
120 #endif
121 #endif
122 
123 #ifdef ZTS
124 #define MULTIPLE_THREADS 1
125 
126 #define  ACQUIRE_DTOA_LOCK(x) \
127 	if (0 == x) { \
128 		tsrm_mutex_lock(dtoa_mutex); \
129 	} else if (1 == x) { \
130 		tsrm_mutex_lock(pow5mult_mutex); \
131 	}
132 
133 #define FREE_DTOA_LOCK(x) \
134 	if (0 == x) { \
135 		tsrm_mutex_unlock(dtoa_mutex); \
136 	} else if (1 == x) { \
137 		tsrm_mutex_unlock(pow5mult_mutex); \
138 	}
139 
140 
141 #endif
142 
143 #endif /* ZEND_STRTOD_INT_H */
144