Skip to content

Commit

Permalink
fixup! Fix X32 build
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb committed Oct 25, 2024
1 parent e1e5b09 commit 257b7ad
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 64 deletions.
17 changes: 14 additions & 3 deletions rdkafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ PHP_METHOD(RdKafka, setLogLevel)
/* }}} */

#ifdef HAS_RD_KAFKA_OAUTHBEARER
/* {{{ proto void RdKafka::oauthbearerSetToken(string $token_value, int $lifetime_ms, string $principal_name, array $extensions = [])
/* {{{ proto void RdKafka::oauthbearerSetToken(string $token_value, int|float $lifetime_ms, string $principal_name, array $extensions = [])
* Set SASL/OAUTHBEARER token and metadata
*
* The SASL/OAUTHBEARER token refresh callback or event handler should cause
Expand All @@ -449,18 +449,29 @@ PHP_METHOD(RdKafka, oauthbearerSetToken)
kafka_object *intern;
char *token_value;
size_t token_value_len;
zend_long lifetime_ms;
zval *zlifetime_ms;
int64_t lifetime_ms;
char *principal_name;
size_t principal_len;
HashTable *extensions_hash = NULL;

char errstr[512];
rd_kafka_resp_err_t ret = 0;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "sls|h", &token_value, &token_value_len, &lifetime_ms, &principal_name, &principal_len, &extensions_hash) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "szs|h", &token_value, &token_value_len, &zlifetime_ms, &principal_name, &principal_len, &extensions_hash) == FAILURE) {
return;
}

switch (Z_TYPE_P(zlifetime_ms)) {
case IS_LONG:
lifetime_ms = (int64_t) Z_LVAL_P(zlifetime_ms);
break;
case IS_DOUBLE:
lifetime_ms = (int64_t) Z_DVAL_P(zlifetime_ms);
break;
EMPTY_SWITCH_DEFAULT_CASE();
}

intern = get_kafka_object(getThis());
if (!intern) {
return;
Expand Down
2 changes: 1 addition & 1 deletion rdkafka.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function resumePartitions(array $topic_partitions): array {}

#ifdef HAS_RD_KAFKA_OAUTHBEARER
/** @tentative-return-type */
public function oauthbearerSetToken(string $token_value, int $lifetime_ms, string $principal_name, array $extensions = []): void {}
public function oauthbearerSetToken(string $token_value, int|float $lifetime_ms, string $principal_name, array $extensions = []): void {}

/** @tentative-return-type */
public function oauthbearerSetTokenFailure(string $error): void {}
Expand Down
67 changes: 38 additions & 29 deletions rdkafka_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ea957a110b42c19bcb4a244655c1eaf99a1e3961 */
* Stub hash: ac271309a726a9656d3ede7e687a6635d037d966 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RdKafka___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
Expand Down Expand Up @@ -126,11 +126,13 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_RdKafka_oauthbea
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RdKafka_oauthbearerSetToken, 0, 0, 3)
#endif
ZEND_ARG_TYPE_INFO(0, token_value, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, lifetime_ms, IS_LONG, 0)
ZEND_ARG_TYPE_MASK(0, lifetime_ms, MAY_BE_LONG|MAY_BE_DOUBLE, NULL)
ZEND_ARG_TYPE_INFO(0, principal_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, extensions, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
#endif

#if defined(HAS_RD_KAFKA_OAUTHBEARER)
#if (PHP_VERSION_ID >= 80100)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_RdKafka_oauthbearerSetTokenFailure, 0, 1, IS_VOID, 0)
#else
Expand Down Expand Up @@ -161,19 +163,26 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RdKafka_Producer_initTransactions, 0, 0, 1)
#endif
ZEND_ARG_TYPE_INFO(0, timeout_ms, IS_LONG, 0)
ZEND_END_ARG_INFO()
#endif

#if defined(HAS_RD_KAFKA_TRANSACTIONS)
#if (PHP_VERSION_ID >= 80100)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_RdKafka_Producer_beginTransaction, 0, 0, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RdKafka_Producer_beginTransaction, 0, 0, 0)
#endif
ZEND_END_ARG_INFO()
#endif

#if defined(HAS_RD_KAFKA_TRANSACTIONS)
#define arginfo_class_RdKafka_Producer_commitTransaction arginfo_class_RdKafka_Producer_initTransactions
#endif

#if defined(HAS_RD_KAFKA_TRANSACTIONS)
#define arginfo_class_RdKafka_Producer_abortTransaction arginfo_class_RdKafka_Producer_initTransactions
#endif


ZEND_METHOD(RdKafka, __construct);
ZEND_METHOD(RdKafka, addBrokers);
ZEND_METHOD(RdKafka, getMetadata);
Expand All @@ -195,18 +204,27 @@ ZEND_METHOD(RdKafka, pausePartitions);
ZEND_METHOD(RdKafka, resumePartitions);
#if defined(HAS_RD_KAFKA_OAUTHBEARER)
ZEND_METHOD(RdKafka, oauthbearerSetToken);
#endif
#if defined(HAS_RD_KAFKA_OAUTHBEARER)
ZEND_METHOD(RdKafka, oauthbearerSetTokenFailure);
#endif
ZEND_METHOD(RdKafka_Consumer, __construct);
ZEND_METHOD(RdKafka_Consumer, newQueue);
ZEND_METHOD(RdKafka_Producer, __construct);
#if defined(HAS_RD_KAFKA_TRANSACTIONS)
ZEND_METHOD(RdKafka_Producer, initTransactions);
#endif
#if defined(HAS_RD_KAFKA_TRANSACTIONS)
ZEND_METHOD(RdKafka_Producer, beginTransaction);
#endif
#if defined(HAS_RD_KAFKA_TRANSACTIONS)
ZEND_METHOD(RdKafka_Producer, commitTransaction);
#endif
#if defined(HAS_RD_KAFKA_TRANSACTIONS)
ZEND_METHOD(RdKafka_Producer, abortTransaction);
#endif


static const zend_function_entry class_RdKafka_methods[] = {
ZEND_ME(RdKafka, __construct, arginfo_class_RdKafka___construct, ZEND_ACC_PRIVATE)
ZEND_ME(RdKafka, addBrokers, arginfo_class_RdKafka_addBrokers, ZEND_ACC_PUBLIC)
Expand All @@ -215,18 +233,10 @@ static const zend_function_entry class_RdKafka_methods[] = {
ZEND_ME(RdKafka, getControllerId, arginfo_class_RdKafka_getControllerId, ZEND_ACC_PUBLIC)
#endif
ZEND_ME(RdKafka, getOutQLen, arginfo_class_RdKafka_getOutQLen, ZEND_ACC_PUBLIC)
#if (PHP_VERSION_ID >= 80400)
ZEND_RAW_FENTRY("metadata", zim_RdKafka_getMetadata, arginfo_class_RdKafka_metadata, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, NULL)
#else
ZEND_RAW_FENTRY("metadata", zim_RdKafka_getMetadata, arginfo_class_RdKafka_metadata, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
#endif
ZEND_MALIAS(RdKafka, metadata, getMetadata, arginfo_class_RdKafka_metadata, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
ZEND_ME(RdKafka, setLogLevel, arginfo_class_RdKafka_setLogLevel, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
ZEND_ME(RdKafka, newTopic, arginfo_class_RdKafka_newTopic, ZEND_ACC_PUBLIC)
#if (PHP_VERSION_ID >= 80400)
ZEND_RAW_FENTRY("outqLen", zim_RdKafka_getOutQLen, arginfo_class_RdKafka_outqLen, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, NULL)
#else
ZEND_RAW_FENTRY("outqLen", zim_RdKafka_getOutQLen, arginfo_class_RdKafka_outqLen, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
#endif
ZEND_MALIAS(RdKafka, outqLen, getOutQLen, arginfo_class_RdKafka_outqLen, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
ZEND_ME(RdKafka, poll, arginfo_class_RdKafka_poll, ZEND_ACC_PUBLIC)
ZEND_ME(RdKafka, flush, arginfo_class_RdKafka_flush, ZEND_ACC_PUBLIC)
#if defined(HAS_RD_KAFKA_PURGE)
Expand All @@ -239,23 +249,38 @@ static const zend_function_entry class_RdKafka_methods[] = {
ZEND_ME(RdKafka, resumePartitions, arginfo_class_RdKafka_resumePartitions, ZEND_ACC_PUBLIC)
#if defined(HAS_RD_KAFKA_OAUTHBEARER)
ZEND_ME(RdKafka, oauthbearerSetToken, arginfo_class_RdKafka_oauthbearerSetToken, ZEND_ACC_PUBLIC)
#endif
#if defined(HAS_RD_KAFKA_OAUTHBEARER)
ZEND_ME(RdKafka, oauthbearerSetTokenFailure, arginfo_class_RdKafka_oauthbearerSetTokenFailure, ZEND_ACC_PUBLIC)
#endif
ZEND_FE_END
};


static const zend_function_entry class_RdKafka_Exception_methods[] = {
ZEND_FE_END
};


static const zend_function_entry class_RdKafka_Consumer_methods[] = {
ZEND_ME(RdKafka_Consumer, __construct, arginfo_class_RdKafka_Consumer___construct, ZEND_ACC_PUBLIC)
ZEND_ME(RdKafka_Consumer, newQueue, arginfo_class_RdKafka_Consumer_newQueue, ZEND_ACC_PUBLIC)
ZEND_FE_END
};


static const zend_function_entry class_RdKafka_Producer_methods[] = {
ZEND_ME(RdKafka_Producer, __construct, arginfo_class_RdKafka_Producer___construct, ZEND_ACC_PUBLIC)
#if defined(HAS_RD_KAFKA_TRANSACTIONS)
ZEND_ME(RdKafka_Producer, initTransactions, arginfo_class_RdKafka_Producer_initTransactions, ZEND_ACC_PUBLIC)
#endif
#if defined(HAS_RD_KAFKA_TRANSACTIONS)
ZEND_ME(RdKafka_Producer, beginTransaction, arginfo_class_RdKafka_Producer_beginTransaction, ZEND_ACC_PUBLIC)
#endif
#if defined(HAS_RD_KAFKA_TRANSACTIONS)
ZEND_ME(RdKafka_Producer, commitTransaction, arginfo_class_RdKafka_Producer_commitTransaction, ZEND_ACC_PUBLIC)
#endif
#if defined(HAS_RD_KAFKA_TRANSACTIONS)
ZEND_ME(RdKafka_Producer, abortTransaction, arginfo_class_RdKafka_Producer_abortTransaction, ZEND_ACC_PUBLIC)
#endif
ZEND_FE_END
Expand All @@ -266,12 +291,8 @@ static zend_class_entry *register_class_RdKafka(void)
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "RdKafka", class_RdKafka_methods);
#if (PHP_VERSION_ID >= 80400)
class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_ABSTRACT);
#else
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_ABSTRACT;
#endif

zval property_error_cb_default_value;
ZVAL_UNDEF(&property_error_cb_default_value);
Expand All @@ -292,12 +313,8 @@ static zend_class_entry *register_class_RdKafka_Exception(zend_class_entry *clas
{
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Exception", NULL);
#if (PHP_VERSION_ID >= 80400)
class_entry = zend_register_internal_class_with_flags(&ce, class_entry_Exception, 0);
#else
INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Exception", class_RdKafka_Exception_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception);
#endif

return class_entry;
}
Expand All @@ -307,11 +324,7 @@ static zend_class_entry *register_class_RdKafka_Consumer(zend_class_entry *class
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Consumer", class_RdKafka_Consumer_methods);
#if (PHP_VERSION_ID >= 80400)
class_entry = zend_register_internal_class_with_flags(&ce, class_entry_RdKafka, 0);
#else
class_entry = zend_register_internal_class_ex(&ce, class_entry_RdKafka);
#endif

return class_entry;
}
Expand All @@ -321,11 +334,7 @@ static zend_class_entry *register_class_RdKafka_Producer(zend_class_entry *class
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "RdKafka", "Producer", class_RdKafka_Producer_methods);
#if (PHP_VERSION_ID >= 80400)
class_entry = zend_register_internal_class_with_flags(&ce, class_entry_RdKafka, 0);
#else
class_entry = zend_register_internal_class_ex(&ce, class_entry_RdKafka);
#endif

return class_entry;
}
Loading

0 comments on commit 257b7ad

Please sign in to comment.