Skip to content

Commit 2fef7b0

Browse files
committed
Try to Fix Windows "definition of dllimport function not allowed"
Properly skip test on unsupported version Use newer php versions in appveyor
1 parent 14ef530 commit 2fef7b0

9 files changed

Lines changed: 34 additions & 33 deletions

File tree

.appveyor.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ environment:
3737
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
3838
ARCH: x86
3939
VC: vs16
40-
PHP_VER: 8.2.0beta2
40+
PHP_VER: 8.2.0RC3
4141
TS: 1
4242
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
4343
ARCH: x64
4444
VC: vs16
45-
PHP_VER: 8.2.0beta2
45+
PHP_VER: 8.2.0RC3
4646
TS: 0
4747
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
4848
ARCH: x64
4949
VC: vs16
50-
PHP_VER: 8.1.9
50+
PHP_VER: 8.1.11
5151
TS: 0
5252
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
5353
ARCH: x64
5454
VC: vs16
55-
PHP_VER: 8.0.22
55+
PHP_VER: 8.0.24
5656
TS: 0
5757
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
5858
ARCH: x64

config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if test "$PHP_SIMDJSON" != "no"; then
3737
src/simdjson.cpp],
3838
$ext_shared,, "-std=c++17 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DSIMDJSON_EXCEPTIONS=0 -DSIMDJSON_DEVELOPMENT_CHECKS=0", cxx)
3939

40-
PHP_INSTALL_HEADERS([ext/simdjson], [php_simdjson.h, src/bindings.h src/bindings_impl.h])
40+
PHP_INSTALL_HEADERS([ext/simdjson], [php_simdjson.h, src/bindings.h src/bindings_defs.h])
4141
PHP_ADD_MAKEFILE_FRAGMENT
4242
PHP_ADD_BUILD_DIR(src, 1)
4343
fi

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ if (PHP_SIMDJSON == "yes") {
1111
'/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /std:c++latest');
1212
ADD_SOURCES(configure_module_dirname + '/src', 'simdjson.cpp bindings.cpp', 'simdjson');
1313
ADD_FLAG('CFLAGS_SIMDJSON', '/I' + configure_module_dirname);
14-
PHP_INSTALL_HEADERS('ext/simdjson', 'php_simdjson.h src/bindings.h src/bindings_impl.h');
14+
PHP_INSTALL_HEADERS('ext/simdjson', 'php_simdjson.h src/bindings.h src/bindings_defs.h');
1515
}
1616
// vim:ft=javascript

package.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<dir name="src">
5454
<file name="bindings.cpp" role="src"/>
5555
<file name="bindings.h" role="src"/>
56-
<file name="bindings_impl.h" role="src"/>
56+
<file name="bindings_defs.h" role="src"/>
5757
<file name="simdjson.cpp" role="src"/>
5858
<file name="simdjson.h" role="src"/>
5959
</dir>
@@ -88,7 +88,6 @@
8888
<dir name="compat">
8989
<file name="001.phpt" role="test"/>
9090
<file name="bug41067.phpt" role="test"/>
91-
<file name="bug41403.phpt" role="test"/>
9291
<file name="bug41504.phpt" role="test"/>
9392
<file name="bug45791.phpt" role="test"/>
9493
<file name="bug47644.phpt" role="test"/>

php_simdjson.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ extern "C" {
2626
#include "simdjson_arginfo.h"
2727
}
2828

29+
// Both the declaration and the definition of ZEND_API variables, functions must be within an 'extern "C"' block for Windows?
30+
zend_class_entry *simdjson_exception_ce;
31+
2932
#include "src/bindings.h"
3033
#include "src/simdjson.h"
3134

3235
ZEND_DECLARE_MODULE_GLOBALS(simdjson);
3336

34-
ZEND_API zend_class_entry *simdjson_exception_ce;
35-
3637
#if PHP_VERSION_ID >= 70200
3738
#define SIMDJSON_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
3839
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null)

src/bindings.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ extern "C" {
1717
#include <Zend/zend_exceptions.h>
1818
#include "php.h"
1919
#include "php_simdjson.h"
20-
#include "bindings.h"
2120
}
2221

2322
#include "simdjson.h"
24-
#include "bindings_impl.h"
23+
#include "bindings.h"
24+
#include "bindings_defs.h"
2525

2626
#if PHP_VERSION_ID < 70300
2727
#define zend_string_release_ex(s, persistent) zend_string_release((s))
2828
#endif
2929

3030
#define SIMDJSON_DEPTH_CHECK_THRESHOLD 100000
3131

32-
ZEND_API void cplus_simdjson_throw_jsonexception(simdjson_php_error_code error)
32+
void cplus_simdjson_throw_jsonexception(simdjson_php_error_code error)
3333
{
3434
zend_throw_exception(simdjson_exception_ce, simdjson::error_message((simdjson::error_code) error), (zend_long) error);
3535
}
@@ -300,15 +300,15 @@ static zval create_object(simdjson::dom::element element) /* {{{ */ {
300300

301301
/* }}} */
302302

303-
ZEND_API simdjson_php_parser* cplus_simdjson_create_parser(void) /* {{{ */ {
303+
simdjson_php_parser* cplus_simdjson_create_parser(void) /* {{{ */ {
304304
return new simdjson_php_parser();
305305
}
306306

307-
ZEND_API void cplus_simdjson_free_parser(simdjson_php_parser* parser) /* {{{ */ {
307+
void cplus_simdjson_free_parser(simdjson_php_parser* parser) /* {{{ */ {
308308
delete parser;
309309
}
310310

311-
ZEND_API bool cplus_simdjson_is_valid(simdjson_php_parser* parser, const char *json, size_t len, size_t depth) /* {{{ */ {
311+
bool cplus_simdjson_is_valid(simdjson_php_parser* parser, const char *json, size_t len, size_t depth) /* {{{ */ {
312312
simdjson::dom::element doc;
313313
/* The depth is passed in to ensure this behaves the same way for the same arguments */
314314
auto error = build_parsed_json_cust(parser, doc, json, len, true, depth);
@@ -320,7 +320,7 @@ ZEND_API bool cplus_simdjson_is_valid(simdjson_php_parser* parser, const char *j
320320

321321
/* }}} */
322322

323-
ZEND_API simdjson_php_error_code cplus_simdjson_parse(simdjson_php_parser* parser, const char *json, size_t len, zval *return_value, unsigned char assoc, size_t depth) /* {{{ */ {
323+
simdjson_php_error_code cplus_simdjson_parse(simdjson_php_parser* parser, const char *json, size_t len, zval *return_value, unsigned char assoc, size_t depth) /* {{{ */ {
324324
simdjson::dom::element doc;
325325
simdjson::error_code error = build_parsed_json_cust(parser, doc, json, len, true, depth);
326326
if (error) {
@@ -335,7 +335,7 @@ ZEND_API simdjson_php_error_code cplus_simdjson_parse(simdjson_php_parser* parse
335335
return simdjson::SUCCESS;
336336
}
337337
/* }}} */
338-
ZEND_API simdjson_php_error_code cplus_simdjson_key_value(simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, unsigned char assoc,
338+
simdjson_php_error_code cplus_simdjson_key_value(simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, unsigned char assoc,
339339
size_t depth) /* {{{ */ {
340340
simdjson::dom::element doc;
341341
simdjson::dom::element element;
@@ -351,7 +351,7 @@ ZEND_API simdjson_php_error_code cplus_simdjson_key_value(simdjson_php_parser* p
351351

352352
/* }}} */
353353

354-
ZEND_API u_short cplus_simdjson_key_exists(simdjson_php_parser* parser, const char *json, size_t len, const char *key, size_t depth) /* {{{ */ {
354+
u_short cplus_simdjson_key_exists(simdjson_php_parser* parser, const char *json, size_t len, const char *key, size_t depth) /* {{{ */ {
355355
simdjson::dom::element doc;
356356
auto error = build_parsed_json_cust(parser, doc, json, len, true, depth);
357357
if (error) {
@@ -366,7 +366,7 @@ ZEND_API u_short cplus_simdjson_key_exists(simdjson_php_parser* parser, const ch
366366

367367
/* }}} */
368368

369-
ZEND_API simdjson_php_error_code cplus_simdjson_key_count(simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, size_t depth) /* {{{ */ {
369+
simdjson_php_error_code cplus_simdjson_key_count(simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, size_t depth) /* {{{ */ {
370370
simdjson::dom::element doc;
371371
simdjson::dom::element element;
372372

src/bindings.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,27 @@
1717
#include "Zend/zend.h"
1818
#include "Zend/zend_portability.h"
1919

20-
// NOTE: All code in this header file should be made compatible with C, so that pecls written in C can use this functionality.
20+
// TODO: All code in this header file should be changed to go within BEGIN_EXTERN_C/END_EXTERN_C macros (both header definitions, and C++ declarations, including function implementations),
21+
// so that pecls written in C can use this functionality without separate C++ files to load bindings.h.
2122
// BEGIN_EXTERN_C is needed for symbols to be mangled using C rules instead of C++ rules in all includers.
22-
BEGIN_EXTERN_C()
23-
extern ZEND_API zend_class_entry *simdjson_exception_ce;
23+
// When I add ZEND_API to declarations and possibly definitions, I get linker errors.
24+
extern zend_class_entry *simdjson_exception_ce;
2425

2526
// NOTE: Namespaces and references(&) are C++ only functionality.
2627
// To expose this functionality to other C PECLs,
2728
// switch to a forward class declaration of a class that only wraps simdjson::dom::parser
2829
class simdjson_php_parser;
2930
typedef uint8_t simdjson_php_error_code;
3031

31-
ZEND_API void cplus_simdjson_throw_jsonexception(simdjson_php_error_code);
32-
ZEND_API simdjson_php_parser* cplus_simdjson_create_parser(void);
33-
ZEND_API void cplus_simdjson_free_parser(simdjson_php_parser* parser);
34-
ZEND_API bool cplus_simdjson_is_valid(simdjson_php_parser* parser, const char *json, size_t len, size_t depth);
35-
ZEND_API simdjson_php_error_code cplus_simdjson_parse(simdjson_php_parser* parser, const char *json, size_t len, zval *return_value, unsigned char assoc, size_t depth);
36-
ZEND_API simdjson_php_error_code cplus_simdjson_key_value(simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, unsigned char assoc, size_t depth);
37-
ZEND_API u_short cplus_simdjson_key_exists(simdjson_php_parser* parser, const char *json, size_t len, const char *key, size_t depth);
38-
ZEND_API simdjson_php_error_code cplus_simdjson_key_count(simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, size_t depth);
32+
void cplus_simdjson_throw_jsonexception(simdjson_php_error_code);
33+
simdjson_php_parser* cplus_simdjson_create_parser(void);
34+
void cplus_simdjson_free_parser(simdjson_php_parser* parser);
35+
bool cplus_simdjson_is_valid(simdjson_php_parser* parser, const char *json, size_t len, size_t depth);
36+
simdjson_php_error_code cplus_simdjson_parse(simdjson_php_parser* parser, const char *json, size_t len, zval *return_value, unsigned char assoc, size_t depth);
37+
simdjson_php_error_code cplus_simdjson_key_value(simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, unsigned char assoc, size_t depth);
38+
u_short cplus_simdjson_key_exists(simdjson_php_parser* parser, const char *json, size_t len, const char *key, size_t depth);
39+
simdjson_php_error_code cplus_simdjson_key_count(simdjson_php_parser* parser, const char *json, size_t len, const char *key, zval *return_value, size_t depth);
3940

40-
END_EXTERN_C()
41+
// END_EXTERN_C()
4142

4243
#endif
File renamed without changes.

tests/compat/bug68546.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
Bug #68546 compat (json_decode() Fatal error: Cannot access property started with '\0')
33
--SKIPIF--
4-
<?php if (!function_exists('json_encode')) echo "output test requires json_encode\n"; ?>
4+
<?php if (!function_exists('json_encode')) echo "skip output test requires json_encode\n"; ?>
55
--FILE--
66
<?php
77

0 commit comments

Comments
 (0)