1 /*******************************************************************************
2 Copyright (c) 2016, Michael Wallner <mike@php.net>.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
18 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *******************************************************************************/
26 #ifndef PSI_TYPES_IMPL_VAL_H
27 #define PSI_TYPES_IMPL_VAL_H
29 #include "Zend/zend_types.h"
30 #include "Zend/zend_API.h"
32 typedef struct zend_fcall
{
34 zend_fcall_info_cache fcc
;
37 typedef union impl_val
{
52 #ifdef HAVE_LONG_DOUBLE
63 char _dbg
[sizeof(void *)];
72 # define CASE_IMPLVAL_LD_DUMP(dump, ival, with_suffix) \
73 case PSI_T_LONG_DOUBLE: \
74 if (isinfl(ival.ldval)) { \
75 PSI_DUMP(dump, "\\INF"); \
76 } else if (isnanl(ival.ldval)) { \
77 PSI_DUMP(dump, "\\NAN"); \
79 /* bug in long double formatting of xbuf_fmt_conv? */ \
80 char buf[0x100] = {0}; \
81 snprintf(buf, sizeof(buf) - 1, "%" PRIldval, ival.ldval); \
82 PSI_DUMP(dump, "%s%s", buf, (with_suffix) ? "L" : ""); \
86 # define CASE_IMPLVAL_LD_DUMP(dump, ival, with_suffix)
89 #define CASE_IMPLVAL_FLOAT_DUMP(dump, ival, with_suffix) \
90 CASE_IMPLVAL_LD_DUMP(dump, ival, with_suffix); \
92 if (isinf(ival.dval)) { \
93 PSI_DUMP(dump, "\\INF"); \
94 } else if (isnan(ival.dval)) { \
95 PSI_DUMP(dump, "\\NAN"); \
97 PSI_DUMP(dump, "%" PRIfval "%s", ival.fval, (with_suffix) ? "F" : ""); \
101 if (isinf(ival.dval)) { \
102 PSI_DUMP(dump, "\\INF"); \
103 } else if (isnan(ival.dval)) { \
104 PSI_DUMP(dump, "\\NAN"); \
106 PSI_DUMP(dump, "%" PRIdval, ival.dval); \
110 #define CASE_IMPLVAL_INT_DUMP(dump, ival, with_suffix) \
112 PSI_DUMP(dump, "%" PRId8, ival.i8); \
115 PSI_DUMP(dump, "%" PRIu8, ival.u8); \
118 PSI_DUMP(dump, "%" PRId16, ival.i16); \
121 PSI_DUMP(dump, "%" PRIu16, ival.u16); \
124 PSI_DUMP(dump, "%" PRId32, ival.i32); \
127 PSI_DUMP(dump, "%" PRIu32 "%s", ival.u32, (with_suffix) ? "U" : ""); \
130 PSI_DUMP(dump, "%" PRId64 "%s", ival.i64, (with_suffix) ? "L" : ""); \
133 PSI_DUMP(dump, "%" PRIu64 "%s", ival.u64, (with_suffix) ? "UL" : ""); \
136 #define CASE_IMPLVAL_NUM_DUMP(dump, ival, with_suffix) \
137 CASE_IMPLVAL_INT_DUMP(dump, ival, with_suffix); \
138 CASE_IMPLVAL_FLOAT_DUMP(dump, ival, with_suffix)