Skip to content

Commit

Permalink
Support macos, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dixyes committed Dec 13, 2023
1 parent 133db4c commit 207fb2a
Show file tree
Hide file tree
Showing 9 changed files with 525 additions and 33 deletions.
6 changes: 6 additions & 0 deletions ext/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ EOF
swow_signal.c \
swow_watchdog.c \
swow_closure.c \
swow_siritz.c \
swow_ipaddress.c \
swow_http.c \
swow_websocket.c \
Expand All @@ -402,6 +403,11 @@ EOF
SWOW_ADD_SOURCES(src, swow_weak_symbol.c, SWOW_INCLUDES, SWOW_CFLAGS)
fi

dnl check if pthread have pthread_timedjoin_np
AC_CHECK_FUNCS([pthread_timedjoin_np], [
AC_DEFINE([HAVE_PTHREAD_TIMEDJOIN_NP], 1, [Have pthread_timedjoin_np])
])

dnl TODO: may use separate libcat
if test "libcat" != ""; then

Expand Down
13 changes: 13 additions & 0 deletions ext/include/swow_siritz.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@

#include "swow.h"

/* globals */

CAT_GLOBALS_STRUCT_BEGIN(swow_siritz) {
HashTable threads; // sub-threads for this thread
} CAT_GLOBALS_STRUCT_END(swow_siritz);

#define SWOW_SIRITZ_G(x) CAT_GLOBALS_GET(swow_siritz, x)

/* Siritz object */
typedef struct swow_siritz_s {
smart_str callable;
smart_str args;
uv_thread_t thread;
zend_object std;
} swow_siritz_t;

/* Siritz run struct */
typedef struct swow_siritz_run_s {
smart_str callable;
smart_str args;
Expand All @@ -26,4 +36,7 @@ static zend_always_inline swow_siritz_t *swow_siritz_get_from_object(zend_object
zend_result swow_siritz_module_init(INIT_FUNC_ARGS);
zend_result swow_siritz_module_shutdown(INIT_FUNC_ARGS);

zend_result swow_siritz_runtime_init(INIT_FUNC_ARGS);
zend_result swow_siritz_runtime_shutdown(INIT_FUNC_ARGS);

#endif // _SWOW_SIRITZ_H
2 changes: 2 additions & 0 deletions ext/src/swow_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ PHP_RINIT_FUNCTION(swow)
swow_dns_runtime_init,
swow_stream_runtime_init,
swow_watchdog_runtime_init,
swow_siritz_runtime_init,
#ifdef CAT_OS_WAIT
swow_proc_open_runtime_init,
#endif
Expand Down Expand Up @@ -369,6 +370,7 @@ PHP_RSHUTDOWN_FUNCTION(swow)
#ifdef CAT_OS_WAIT
swow_proc_open_runtime_shutdown,
#endif
swow_siritz_runtime_shutdown,
swow_watchdog_runtime_shutdown,
swow_stream_runtime_shutdown,
swow_event_runtime_shutdown,
Expand Down
Loading

0 comments on commit 207fb2a

Please sign in to comment.