Organized modules, added indirection for FFI vs extension loading (#10)

* mv src -> ext, lib -> src to be more in line with PHP module expectations

* Fixed dependency for ffi test

* Fixed path in format-check to C source

* CRT will now try the extension first, then FFI
This commit is contained in:
Justin Boswell
2021-02-16 10:31:42 -08:00
committed by GitHub
parent aee57a929d
commit c30c1486fe
17 changed files with 141 additions and 46 deletions
+2
View File
@@ -0,0 +1,2 @@
*.so
api.h
+73
View File
@@ -0,0 +1,73 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include "php_aws_crt.h"
ZEND_DECLARE_MODULE_GLOBALS(awscrt);
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY(
"awscrt.log_level",
"",
PHP_INI_ALL,
OnUpdateLongGEZero,
log_level,
zend_awscrt_globals,
awscrt_globals)
PHP_INI_END()
static PHP_MINIT_FUNCTION(awscrt) {
REGISTER_INI_ENTRIES();
return SUCCESS;
}
static PHP_MSHUTDOWN_FUNCTION(awscrt) {
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
static PHP_GINIT_FUNCTION(awscrt) {
#if defined(COMPILE_DL_ASTKIT) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
awscrt_globals->log_level = 0;
}
ZEND_BEGIN_ARG_INFO(awscrt_version_arginfo, 0)
ZEND_END_ARG_INFO()
PHP_FUNCTION(awscrt_version) {
static const char *version = "1.0.0-dev";
AWS_RETURN_STRING(version);
}
/* clang-format off */
const zend_function_entry awscrt_functions[] = {
PHP_FE(awscrt_version, awscrt_version_arginfo)
PHP_FE_END
};
zend_module_entry awscrt_module_entry = {
STANDARD_MODULE_HEADER,
"awscrt",
awscrt_functions, /* functions */
PHP_MINIT(awscrt),
PHP_MSHUTDOWN(awscrt),
NULL, /* RINIT */
NULL, /* RSHUTDOWN */
NULL, /* MINFO */
NO_VERSION_YET,
PHP_MODULE_GLOBALS(awscrt),
PHP_GINIT(awscrt),
NULL, /* GSHUTDOWN */
NULL, /* RPOSTSHUTDOWN */
STANDARD_MODULE_PROPERTIES_EX};
/* clang-format on */
#ifdef COMPILE_DL_AWSCRT
ZEND_GET_MODULE(awscrt)
#endif
+39
View File
@@ -0,0 +1,39 @@
#ifndef PHP_AWS_CRT_H
#define PHP_AWS_CRT_H
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "php.h"
#include "Zend/zend_extensions.h" /* for ZEND_EXTENSION_API_NO */
#if ZEND_EXTENSION_API_NO < 220131226
# error "PHP >= 5.6 is required"
#endif
#define AWS_PHP_AT_LEAST_7 defined(ZEND_EXTENSION_API_NO_7_0_X) || (ZEND_EXTENSION_API_NO >= 320151012)
ZEND_BEGIN_MODULE_GLOBALS(awscrt)
long log_level;
ZEND_END_MODULE_GLOBALS(awscrt)
ZEND_EXTERN_MODULE_GLOBALS(awscrt)
#define AWSCRT_GLOBAL(v) ZEND_MODULE_GLOBALS_ACCESSOR(awscrt, v)
/* PHP 7 removed the string duplicate parameter */
#if AWS_PHP_AT_LEAST_7
# define AWS_RETURN_STRING(s) RETURN_STRING(s)
#else
# define AWS_RETURN_STRING(s) RETURN_STRING(s, 1)
#endif
#endif /* PHP_AWS_CRT_H */