Skip to content

Commit

Permalink
Add clang-format to CI
Browse files Browse the repository at this point in the history
 +  small fixes
 +  clang-format *.c files
  • Loading branch information
pawelchcki committed Oct 1, 2018
1 parent e3edde3 commit 9303070
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 22 deletions.
22 changes: 20 additions & 2 deletions .circleci/config.yml
Expand Up @@ -91,6 +91,21 @@ jobs:
- run:
name: Running phpcs
command: composer lint -- --report=junit | tee test-results/phpcs/results.xml
- run:
name: Install clang-format 6.0
command: sudo apt -y install clang-format-6.0/testing
- run:
name: Run clang-format
command: |
find ./ -iname *.h -o -iname *.c | while read fname; do
changes=$(clang-format-6.0 -output-replacements-xml $fname | grep -c "<replacement " || true)
if [ $changes != 0 ]
then
clang-format-6.0 -output-replacements-xml $fname
echo "$fname did not pass clang-format, consider running: find ./ -iname *.h -o -iname *.c | xargs clang-format -i"
exit 1
fi
done
- <<: *STEP_STORE_TEST_RESULTS
- <<: *STEP_STORE_ARTIFACTS

Expand Down Expand Up @@ -153,17 +168,20 @@ jobs:
"build 7.0":
<<: *BASE_BUILD
docker: [ image: 'circleci/php:7.0' ]

"build 7.1":
<<: *BASE_BUILD
docker: [ image: 'circleci/php:7.1' ]

"build 7.2":
<<: *BASE_BUILD
docker: [ image: 'circleci/php:7.2' ]


"php-5.6":
<<: *JOB_PHP_DEFAULTS
docker: [ image: 'circleci/php:5.6', *IMAGE_DOCKER_DD_AGENT ]
docker:
- image: 'circleci/php:5.6'
- <<: *IMAGE_DOCKER_DD_AGENT

"php-7.0":
<<: *JOB_PHP_DEFAULTS
Expand Down
2 changes: 1 addition & 1 deletion config.m4
@@ -1,4 +1,4 @@
PHP_ARG_ENABLE(ddtrace, whether to enable Datadog tracing support,[ --enable-ddtrace Enable Datadog traing support])
PHP_ARG_ENABLE(ddtrace, whether to enable Datadog tracing support,[ --enable-ddtrace Enable Datadog training support])

PHP_ARG_WITH(ddtrace-sanitize, whether to enable AddressSanitizer for ddtrace,[ --with-ddtrace-sanitize Build Datadog tracing with AddressSanitizer support], no, no)

Expand Down
17 changes: 12 additions & 5 deletions src/ext/ddtrace.c
Expand Up @@ -15,11 +15,19 @@

#include "debug.h"


#define UNUSED_1(x) (void)(x)
#define UNUSED_2(x, y) do { UNUSED_1(x); UNUSED_1(y); } while (0)
#define UNUSED_3(x, y, z) do { UNUSED_1(x); UNUSED_1(y); UNUSED_1(z); } while (0)
#define _GET_UNUSED_MACRO_OF_ARITY(_1,_2,_3, ARITY,...) UNUSED_ ## ARITY
#define UNUSED_2(x, y) \
do { \
UNUSED_1(x); \
UNUSED_1(y); \
} while (0)
#define UNUSED_3(x, y, z) \
do { \
UNUSED_1(x); \
UNUSED_1(y); \
UNUSED_1(z); \
} while (0)
#define _GET_UNUSED_MACRO_OF_ARITY(_1, _2, _3, ARITY, ...) UNUSED_##ARITY
#define UNUSED(...) _GET_UNUSED_MACRO_OF_ARITY(__VA_ARGS__, 3, 2, 1)(__VA_ARGS__)

#if PHP_VERSION_ID < 70000
Expand Down Expand Up @@ -85,7 +93,6 @@ static PHP_RINIT_FUNCTION(ddtrace) {
return SUCCESS;
}


zend_hash_init(&DDTRACE_G(class_lookup), 8, NULL, (dtor_func_t)table_dtor, 0);
zend_hash_init(&DDTRACE_G(function_lookup), 8, NULL, (dtor_func_t)ddtrace_class_lookup_free, 0);

Expand Down
28 changes: 14 additions & 14 deletions src/ext/dispatch_setup.c
Expand Up @@ -29,22 +29,22 @@ static void php_execute(zend_execute_data *execute_data TSRMLS_DC) {
#endif

void ddtrace_dispatch_init() {
/**
* Replacing zend_execute_ex with anything other than original
* changes some of the bevavior in PHP compilation and execution
*
* e.g. it changes compilation of function calls to produce ZEND_DO_FCALL
* opcode instead of ZEND_DO_UCALL for user defined functions
*
* While this extension could be developed by using zend_execute_ex to hook
* into every execution. However hooking into opcode processing has the
* advantage of not hooking into some executable things like generators which
* gives a slight performance advantage.
*/
#if PHP_VERSION_ID >= 70000
/**
* Replacing zend_execute_ex with anything other than original
* changes some of the bevavior in PHP compilation and execution
*
* e.g. it changes compilation of function calls to produce ZEND_DO_FCALL
* opcode instead of ZEND_DO_UCALL for user defined functions
*
* While this extension could be developed by using zend_execute_ex to hook
* into every execution. However hooking into opcode processing has the
* advantage of not hooking into some executable things like generators which
* gives a slight performance advantage.
*/
#if PHP_VERSION_ID >= 70000
ddtrace_original_execute_ex = zend_execute_ex;
zend_execute_ex = php_execute;
#endif
#endif

ddtrace_old_fcall_handler = zend_get_user_opcode_handler(ZEND_DO_FCALL);
zend_set_user_opcode_handler(ZEND_DO_FCALL, ddtrace_wrap_fcall);
Expand Down

0 comments on commit 9303070

Please sign in to comment.