Skip to content

Commit c7e9273

Browse files
committed
#46: fix shared issue
1 parent ac0c633 commit c7e9273

File tree

8 files changed

+43
-55
lines changed

8 files changed

+43
-55
lines changed

async.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
#include "async_API.h"
3030
#include "async_arginfo.h"
3131
#include "zend_interfaces.h"
32-
#ifdef PHP_ASYNC_LIBUV
3332
#include "libuv_reactor.h"
34-
#endif
3533

3634
zend_class_entry *async_ce_awaitable = NULL;
3735
zend_class_entry *async_ce_timeout = NULL;
@@ -889,8 +887,6 @@ static PHP_GINIT_FUNCTION(async)
889887
#endif
890888

891889
async_globals->reactor_started = false;
892-
893-
#ifdef PHP_ASYNC_LIBUV
894890
async_globals->signal_handlers = NULL;
895891
async_globals->signal_events = NULL;
896892
async_globals->process_events = NULL;
@@ -906,7 +902,6 @@ static PHP_GINIT_FUNCTION(async)
906902
async_globals->uvloop_wakeup = NULL;
907903
async_globals->pid_queue = NULL;
908904
#endif
909-
#endif
910905
}
911906

912907
/* {{{ PHP_GSHUTDOWN_FUNCTION */
@@ -932,23 +927,16 @@ ZEND_MINIT_FUNCTION(async)
932927
// async_register_future_ce();
933928

934929
async_scheduler_startup();
935-
936930
async_api_register();
937-
938-
#ifdef PHP_ASYNC_LIBUV
939931
async_libuv_reactor_register();
940-
#endif
941932

942933
return SUCCESS;
943934
}
944935

945936
ZEND_MSHUTDOWN_FUNCTION(async)
946937
{
947938
// async_scheduler_shutdown();
948-
949-
#ifdef PHP_ASYNC_LIBUV
950939
// async_libuv_shutdown();
951-
#endif
952940

953941
return SUCCESS;
954942
}
@@ -959,11 +947,7 @@ PHP_MINFO_FUNCTION(async)
959947
php_info_print_table_header(2, "Module", PHP_ASYNC_NAME);
960948
php_info_print_table_row(2, "Version", PHP_ASYNC_VERSION);
961949
php_info_print_table_row(2, "Support", "Enabled");
962-
#ifdef PHP_ASYNC_LIBUV
963950
php_info_print_table_row(2, "LibUv Reactor", "Enabled");
964-
#else
965-
php_info_print_table_row(2, "LibUv Reactor", "Disabled");
966-
#endif
967951
php_info_print_table_end();
968952
}
969953

config.m4

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ if test "$PHP_ASYNC" = "yes"; then
3232
LIBUV_LIBLINE=`$PKG_CONFIG libuv --libs`
3333
LIBUV_VERSION=`$PKG_CONFIG libuv --modversion`
3434
AC_MSG_RESULT(from pkgconfig: found version $LIBUV_VERSION)
35-
AC_DEFINE(PHP_ASYNC_LIBUV,1,[ ])
3635
else
3736
AC_MSG_ERROR(system libuv must be upgraded to version >= 1.44.0 (fixes UV_RUN_ONCE busy loop issue))
3837
fi
@@ -57,7 +56,6 @@ if test "$PHP_ASYNC" = "yes"; then
5756
PHP_CHECK_LIBRARY(uv, uv_version,
5857
[
5958
PHP_ADD_LIBRARY_WITH_PATH(uv, $UV_DIR/$PHP_LIBDIR, UV_SHARED_LIBADD)
60-
AC_DEFINE(PHP_ASYNC_LIBUV,1,[ ])
6159
],[
6260
AC_MSG_ERROR([wrong uv library version or library not found])
6361
],[

config.w32

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,7 @@ ARG_ENABLE('async', 'Enable True Async', 'no');
44

55
if (PHP_ASYNC == "yes") {
66

7-
if(typeof PHP_ASYNC_API == "undefined" && typeof PHP_EXPERIMENTAL_ASYNC_API != "undefined") {
8-
var PHP_ASYNC_API = PHP_EXPERIMENTAL_ASYNC_API;
9-
}
10-
11-
if (!PHP_ASYNC_API || PHP_ASYNC_API != "yes") {
12-
ERROR("PHP TRUE ASYNC API is required. Please configure PHP with --with-async-api.");
13-
}
14-
15-
EXTENSION("async", "async.c coroutine.c scope.c scheduler.c exceptions.c iterator.c async_API.c");
16-
ADD_SOURCES("ext/async","zend_common.c context.c");
7+
EXTENSION("async", "async.c coroutine.c scope.c scheduler.c exceptions.c iterator.c async_API.c zend_common.c context.c libuv_reactor.c");
178
ADD_SOURCES("ext/async/internal", "allocator.c circular_buffer.c");
189

1910
ADD_FLAG("CFLAGS", "/D PHP_ASYNC");
@@ -27,17 +18,14 @@ if (PHP_ASYNC == "yes") {
2718
PHP_INSTALL_HEADERS("ext/async", "iterator.h");
2819
PHP_INSTALL_HEADERS("ext/async", "async_API.h");
2920
PHP_INSTALL_HEADERS("ext/async", "context.h");
21+
PHP_INSTALL_HEADERS("ext/async", "libuv_reactor.h");
3022

3123
if (CHECK_HEADER_ADD_INCLUDE("libuv/uv.h", "CFLAGS_UV", PHP_PHP_BUILD + "\\include")
3224
&& CHECK_LIB("libuv.lib", "libuv")) {
3325

3426
// Note: libuv >= 1.44.0 is required for UV_RUN_ONCE busy loop fix
3527
// For Windows builds, manually verify libuv version meets requirements
36-
37-
PHP_INSTALL_HEADERS("ext/async", "libuv_reactor.h");
3828

39-
ADD_SOURCES("ext/async", "libuv_reactor.c");
40-
ADD_FLAG("CFLAGS", "/D PHP_ASYNC_LIBUV");
4129
ADD_FLAG("LIBS", "libuv.lib Dbghelp.lib Userenv.lib");
4230
} else {
4331
ERROR("Libuv components are not found. The search was performed in the directory: '" + PHP_PHP_BUILD +

coroutine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef COROUTINE_H
1717
#define COROUTINE_H
1818

19-
#include "php_async.h"
19+
#include "php_async_api.h"
2020
#include <Zend/zend_async_API.h>
2121

2222
ZEND_STACK_ALIGNED void async_coroutine_execute(zend_fiber_transfer *transfer);

exceptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void async_apply_exception(zend_object **to_exception)
321321
}
322322
}
323323

324-
void async_rethrow_exception(zend_object *exception)
324+
PHP_ASYNC_API void async_rethrow_exception(zend_object *exception)
325325
{
326326
if (EG(current_execute_data)) {
327327
zend_throw_exception_internal(exception);

exceptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <zend_portability.h>
2020
#include <zend_property_hooks.h>
2121
#include <Zend/zend_async_API.h>
22+
#include "php_async_api.h"
2223

2324
BEGIN_EXTERN_C()
2425

@@ -42,7 +43,7 @@ PHP_ASYNC_API void async_composite_exception_add_exception(zend_object *composit
4243
bool async_spawn_and_throw(zend_object *exception, zend_async_scope_t *scope, int32_t priority);
4344
void async_apply_exception_to_context(zend_object *exception);
4445
zend_object *async_extract_exception(void);
45-
void async_rethrow_exception(zend_object *exception);
46+
PHP_ASYNC_API void async_rethrow_exception(zend_object *exception);
4647
void async_apply_exception(zend_object **to_exception);
4748

4849
END_EXTERN_C()

php_async.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818

1919
#include <php.h>
2020

21-
#ifdef PHP_ASYNC_LIBUV
2221
#ifdef PHP_WIN32
2322
#include "libuv/uv.h"
2423
#else
2524
#include <uv.h>
2625
#endif
27-
#endif
2826

2927
#include "coroutine.h"
3028
#include "internal/circular_buffer.h"
@@ -38,26 +36,14 @@
3836
extern zend_module_entry async_module_entry;
3937
#define phpext_async_ptr &async_module_entry
4038

41-
#ifdef PHP_WIN32
42-
# ifdef ASYNC_EXPORTS
43-
# define PHP_ASYNC_API __declspec(dllexport)
44-
# else
45-
# define PHP_ASYNC_API __declspec(dllimport)
46-
# endif
47-
#else
48-
# if defined(__GNUC__) && __GNUC__ >= 4
49-
# define PHP_ASYNC_API __attribute__ ((visibility("default")))
50-
# else
51-
# define PHP_ASYNC_API
52-
# endif
53-
#endif
39+
#include "php_async_api.h"
5440

5541
PHP_ASYNC_API extern zend_class_entry *async_ce_awaitable;
5642
PHP_ASYNC_API extern zend_class_entry *async_ce_timeout;
5743

58-
#define PHP_ASYNC_NAME "TrueAsync"
59-
#define PHP_ASYNC_VERSION "0.5.0"
60-
#define PHP_ASYNC_NAME_VERSION "TrueAsync v0.5.0"
44+
#define PHP_ASYNC_NAME "true_async"
45+
#define PHP_ASYNC_VERSION "0.4.0"
46+
#define PHP_ASYNC_NAME_VERSION "true async v0.4.0"
6147

6248
typedef struct
6349
{
@@ -96,7 +82,6 @@ zend_async_context_t *root_context;
9682
/* The default concurrency */
9783
int default_concurrency;
9884

99-
#ifdef PHP_ASYNC_LIBUV
10085
/* The reactor */
10186
uv_loop_t uvloop;
10287
bool reactor_started;
@@ -115,7 +100,6 @@ uv_async_t *uvloop_wakeup;
115100
/* Circular buffer of libuv_process_t ptr */
116101
circular_buffer_t *pid_queue;
117102
#endif
118-
#endif
119103

120104
#ifdef PHP_WIN32
121105
#endif

php_async_api.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Copyright (c) The PHP Group |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 3.01 of the PHP license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| https://www.php.net/license/3_01.txt |
9+
| If you did not receive a copy of the PHP license and are unable to |
10+
| obtain it through the world-wide-web, please send a note to |
11+
| license@php.net so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
| Author: Edmond |
14+
+----------------------------------------------------------------------+
15+
*/
16+
#ifndef PHP_ASYNC_API_H
17+
#define PHP_ASYNC_API_H
18+
19+
#ifdef PHP_WIN32
20+
# ifdef ASYNC_EXPORTS
21+
# define PHP_ASYNC_API __declspec(dllexport)
22+
# else
23+
# define PHP_ASYNC_API __declspec(dllimport)
24+
# endif
25+
#else
26+
# if defined(__GNUC__) && __GNUC__ >= 4
27+
# define PHP_ASYNC_API __attribute__ ((visibility("default")))
28+
# else
29+
# define PHP_ASYNC_API
30+
# endif
31+
#endif
32+
33+
#endif // PHP_ASYNC_API_H

0 commit comments

Comments
 (0)