Skip to content

Commit ca48818

Browse files
committed
fix build errors
1 parent e2fce83 commit ca48818

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

TSRM/TSRM.c

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*/
1212

1313
#include "TSRM.h"
14-
#include <bits/pthreadtypes.h>
15-
#include <pthread.h>
1614

1715

1816
#ifdef TSRM_DEBUG

TSRM/TSRM.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
#ifndef TSRM_H
1414
#define TSRM_H
1515

16-
#ifdef TSRM_WIN32
17-
# ifndef TSRM_INCLUDE_FULL_WINDOWS_HEADERS
18-
# define WIN32_LEAN_AND_MEAN
19-
# endif
20-
#else
21-
# include <pthread.h>
22-
#endif
23-
2416
#if !defined(__CYGWIN__) && defined(WIN32)
2517
# define TSRM_WIN32
2618
# include "Zend/zend_config.w32.h"
@@ -31,6 +23,14 @@
3123
#include <stdint.h>
3224
#include <stdbool.h>
3325

26+
#ifdef TSRM_WIN32
27+
# ifndef TSRM_INCLUDE_FULL_WINDOWS_HEADERS
28+
# define WIN32_LEAN_AND_MEAN
29+
# endif
30+
#else
31+
# include <pthread.h>
32+
#endif
33+
3434
#ifdef TSRM_WIN32
3535
# ifdef TSRM_EXPORTS
3636
# define TSRM_API __declspec(dllexport)
@@ -50,6 +50,7 @@ typedef uintptr_t tsrm_uintptr_t;
5050
#ifdef TSRM_WIN32
5151
# define THREAD_T DWORD
5252
# define MUTEX_T CRITICAL_SECTION *
53+
# define COND_T PCONDITION_VARIABLE
5354
#else
5455
# define THREAD_T pthread_t
5556
# define MUTEX_T pthread_mutex_t *

ext/ffi/ffi.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "main/SAPI.h"
3131
#include "TSRM.h"
3232
#include "zend_fibers.h"
33+
#include "zend_call_stack.h"
3334

3435
#include <sys/types.h>
3536
#include <sys/stat.h>
@@ -932,9 +933,10 @@ static void zend_ffi_callback_hash_dtor(zval *zv) /* {{{ */
932933
if (callback_data->fcc.function_handler->common.fn_flags & ZEND_ACC_CLOSURE) {
933934
OBJ_RELEASE(ZEND_CLOSURE_OBJECT(callback_data->fcc.function_handler));
934935
}
936+
ffi_type **arg_types = callback_data->arg_types;
935937
for (int i = 0; i < callback_data->arg_count; ++i) {
936-
if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) {
937-
efree(callback_data->arg_types[i]);
938+
if (arg_types[i]->type == FFI_TYPE_STRUCT) {
939+
efree(arg_types[i]);
938940
}
939941
}
940942
if (callback_data->ret_type->type == FFI_TYPE_STRUCT) {
@@ -1076,7 +1078,7 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v
10761078

10771079
if (zend_atomic_bool_load_ex(&FFI_G(callback_in_progress))) {
10781080
// call PHP function
1079-
zend_fiber_transfer transfer = zend_fiber_resume(&call_data.data->fiber, NULL, false);
1081+
zend_fiber_resume(&call_data.data->fiber, NULL, false);
10801082
zend_ffi_type *ret_type = ZEND_FFI_TYPE(call_data.data->type->func.ret_type);
10811083
if(ret_type->kind != ZEND_FFI_TYPE_VOID){
10821084
// extract return value from fiber
@@ -1139,15 +1141,16 @@ static void *zend_ffi_create_callback(zend_ffi_type *type, zval *value) /* {{{ *
11391141
if (type->func.args) {
11401142
int n = 0;
11411143
zend_ffi_type *arg_type;
1144+
ffi_type **arg_types = callback_data->arg_types;
11421145

11431146
ZEND_HASH_PACKED_FOREACH_PTR(type->func.args, arg_type) {
11441147
arg_type = ZEND_FFI_TYPE(arg_type);
1145-
callback_data->arg_types[n] = zend_ffi_get_type(arg_type);
1146-
if (!callback_data->arg_types[n]) {
1148+
arg_types[n] = zend_ffi_get_type(arg_type);
1149+
if (!arg_types[n]) {
11471150
zend_ffi_pass_unsupported(arg_type);
11481151
for (int i = 0; i < n; ++i) {
1149-
if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) {
1150-
efree(callback_data->arg_types[i]);
1152+
if (arg_types[i]->type == FFI_TYPE_STRUCT) {
1153+
efree(arg_types[i]);
11511154
}
11521155
}
11531156
efree(callback_data);
@@ -1178,9 +1181,10 @@ static void *zend_ffi_create_callback(zend_ffi_type *type, zval *value) /* {{{ *
11781181
if (ffi_prep_closure_loc(callback, &callback_data->cif, zend_ffi_callback_trampoline, callback_data, code) != FFI_OK) {
11791182
zend_throw_error(zend_ffi_exception_ce, "Cannot prepare callback");
11801183
free_on_failure: ;
1184+
ffi_type **arg_types = callback_data->arg_types;
11811185
for (int i = 0; i < callback_data->arg_count; ++i) {
1182-
if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) {
1183-
efree(callback_data->arg_types[i]);
1186+
if (arg_types[i]->type == FFI_TYPE_STRUCT) {
1187+
efree(arg_types);
11841188
}
11851189
}
11861190
if (callback_data->ret_type->type == FFI_TYPE_STRUCT) {

0 commit comments

Comments
 (0)