Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions ext/gmp/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ PHP_GMP_API zend_class_entry *php_gmp_class_entry(void) {
((__GNU_MP_VERSION >= 6) || (__GNU_MP_VERSION >= 5 && __GNU_MP_VERSION_MINOR >= 1))

#define IS_GMP(zval) \
(Z_TYPE_P(zval) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zval), gmp_ce))
(Z_TYPE_P(zval) == IS_OBJECT && Z_OBJCE_P(zval) == gmp_ce)

#define GET_GMP_OBJECT_FROM_OBJ(obj) \
php_gmp_object_from_zend_object(obj)
Expand All @@ -116,7 +116,7 @@ static bool gmp_zend_parse_arg_into_mpz_ex(
bool is_operator
) {
if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
if (EXPECTED(instanceof_function(Z_OBJCE_P(arg), gmp_ce))) {
if (EXPECTED(Z_OBJCE_P(arg) == gmp_ce)) {
*destination_mpz_ptr = GET_GMP_FROM_ZVAL(arg);
return true;
}
Expand Down Expand Up @@ -404,7 +404,7 @@ typeof_op_failure: ;

static zend_result gmp_do_operation_ex(uint8_t opcode, zval *result, zval *op1, zval *op2) /* {{{ */
{
mpz_ptr gmp_op1, gmp_result;
mpz_ptr gmp_result;
switch (opcode) {
case ZEND_ADD:
return binop_operator_helper(mpz_add, result, op1, op2);
Expand All @@ -429,11 +429,9 @@ static zend_result gmp_do_operation_ex(uint8_t opcode, zval *result, zval *op1,
case ZEND_BW_XOR:
return binop_operator_helper(mpz_xor, result, op1, op2);
case ZEND_BW_NOT: {
if (!gmp_zend_parse_arg_into_mpz_ex(op1, &gmp_op1, 1, false)) {
return FAILURE;
}
ZEND_ASSERT(Z_TYPE_P(op1) == IS_OBJECT && Z_OBJCE_P(op1) == gmp_ce);
gmp_create(result, &gmp_result);
mpz_com(gmp_result, gmp_op1);
mpz_com(gmp_result, GET_GMP_FROM_ZVAL(op1));
return SUCCESS;
}

Expand Down