bugfix
This commit is contained in:
parent
8dafe932a8
commit
c74a1b90aa
|
@ -25,11 +25,11 @@ install:
|
||||||
- sudo apt-get install -qq libsuperlu-dev libhdf5-dev
|
- sudo apt-get install -qq libsuperlu-dev libhdf5-dev
|
||||||
- pushd armadillo-${ARMA_VERSION} && cmake . && make && sudo make install && popd
|
- pushd armadillo-${ARMA_VERSION} && cmake . && make && sudo make install && popd
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- phpenv config-rm xdebug.ini
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpize
|
- phpize
|
||||||
- ./configure --enable-arma-operators --enable-arma-pch
|
- ./configure --enable-arma-operators --enable-arma-pch
|
||||||
- make -j$(nproc)
|
- make -j$(nproc)
|
||||||
- make test
|
- make test
|
||||||
|
|
||||||
after_failure:
|
|
||||||
- cat tests/*.out
|
|
||||||
|
|
|
@ -15,34 +15,26 @@
|
||||||
|
|
||||||
#if PHP_VERSION_ID < 70300
|
#if PHP_VERSION_ID < 70300
|
||||||
// Before PHP 7.3, `-$a` is compile to `MUL -1, $a, ~` instead of `MUL $a, -1, ~`.
|
// Before PHP 7.3, `-$a` is compile to `MUL -1, $a, ~` instead of `MUL $a, -1, ~`.
|
||||||
#define CONVERT_NEG_1_TO_COMPLEX(zv, type) \
|
#define CONVERT_NEG_1_TO_COMPLEX \
|
||||||
else if (Z_TYPE_P(zv) == IS_LONG && Z_LVAL_P(zv) == -1) { \
|
else if (Z_TYPE_P(zv1) == IS_LONG && Z_LVAL_P(zv1) == -1) { \
|
||||||
zval_set_scalar(&tmp, std::complex<type>(-1)); \
|
std::swap(zv1, zv2); \
|
||||||
zv1 = &tmp; \
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define CONVERT_NEG_1_TO_COMPLEX(zv, type)
|
#define CONVERT_NEG_1_TO_COMPLEX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For non-assignment operators, first operand can be of type double.
|
// For non-assignment operators, first operand can be of type double.
|
||||||
#define PHP_ARMA_COMPLEX_OPERATOR_EX(type, func) \
|
#define PHP_ARMA_COMPLEX_OPERATOR_EX(type, func) \
|
||||||
if (instanceof_function(ce, complex<type>::ce)) { \
|
if (instanceof_function(ce, complex<type>::ce)) { \
|
||||||
zval tmp; \
|
|
||||||
ZVAL_UNDEF(&tmp); \
|
|
||||||
if (zval_is_scalar<type>(zv1)) { \
|
if (zval_is_scalar<type>(zv1)) { \
|
||||||
auto real = zval_get_scalar<type>(zv1); \
|
std::swap(zv1, zv2); \
|
||||||
zval_set_scalar(&tmp, std::complex<type>(real)); \
|
|
||||||
zv1 = &tmp; \
|
|
||||||
} \
|
} \
|
||||||
CONVERT_NEG_1_TO_COMPLEX(zv1, type) \
|
CONVERT_NEG_1_TO_COMPLEX \
|
||||||
else if (UNEXPECTED(Z_TYPE_P(zv1) != IS_OBJECT)) { \
|
else if (UNEXPECTED(Z_TYPE_P(zv1) != IS_OBJECT)) { \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
auto v = complex<type>::operators::func(zv1, zv2, rv); \
|
ZVAL_UNDEF(rv); \
|
||||||
if (Z_TYPE(tmp) != IS_UNDEF) { \
|
return complex<type>::operators::func(zv1, zv2, rv); \
|
||||||
zval_ptr_dtor_nogc(&tmp); \
|
|
||||||
} \
|
|
||||||
return v; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PHP_ARMA_COMPLEX_OPERATOR(func) \
|
#define PHP_ARMA_COMPLEX_OPERATOR(func) \
|
||||||
|
@ -227,13 +219,11 @@ namespace php_arma
|
||||||
zval_set_scalar(retval, v1 * zval_get_scalar<T>(zv2));
|
zval_set_scalar(retval, v1 * zval_get_scalar<T>(zv2));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#if PHP_VERSION_ID >= 70300
|
|
||||||
if (Z_TYPE_P(zv2) == IS_LONG && Z_LVAL_P(zv2) == -1) {
|
if (Z_TYPE_P(zv2) == IS_LONG && Z_LVAL_P(zv2) == -1) {
|
||||||
// Negation operator is compiled as multiplication to -1.
|
// Negation operator is compiled as multiplication to -1.
|
||||||
neg(zv1, retval);
|
neg(zv1, retval);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace php_arma
|
||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
zend_always_inline
|
zend_always_inline
|
||||||
int op_handler(zend_execute_data *execute_data, F handler)
|
int op_handler(zend_execute_data *execute_data, F&& handler)
|
||||||
{
|
{
|
||||||
const zend_op *opline = EX(opline);
|
const zend_op *opline = EX(opline);
|
||||||
zend_free_op free_op1 = nullptr;
|
zend_free_op free_op1 = nullptr;
|
||||||
|
|
Reference in New Issue
Block a user