diff --git a/.github/workflows/styling.yml b/.github/workflows/styling.yml new file mode 100644 index 0000000000000..9fb65a5fb30e1 --- /dev/null +++ b/.github/workflows/styling.yml @@ -0,0 +1,75 @@ +name: Code Styling Check +on: + push: + paths-ignore: + - docs/* + - NEWS + - UPGRADING + - UPGRADING.INTERNALS + - '**/README.*' + - CONTRIBUTING.md + - CODING_STANDARDS.md + - .cirrus.yml + - .travis.yml + - travis/* + - .circleci/* + branches: + - PHP-8.1 + - PHP-8.2 + - PHP-8.3 + - master + pull_request: + paths-ignore: + - docs/* + - NEWS + - UPGRADING + - UPGRADING.INTERNALS + - '**/README.*' + - CONTRIBUTING.md + - CODING_STANDARDS.md + - .cirrus.yml + - .travis.yml + - travis/* + - .circleci/* + branches: + - '**' +permissions: + contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }} + cancel-in-progress: true +jobs: + CODE_FORMATTING_CHECK: + name: Code formatting check +# if: github.repository_owner == 'php' || github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install packages + run: | + set -x + sudo apt-get update + sudo apt-get install \ + git \ + clang-format \ + php-cli \ + netcat-openbsd + - name: Check code formatting + run: | + set -x + echo "foobar" > format.patch + - name: 'Upload artifacts' + uses: actions/upload-artifact@v4 + id: artifact-upload-step + with: + name: 'format.patch' + path: format.patch + if-no-files-found: ignore + - name: 'Show summary' + run: | + echo 'Artifact ID is ${{ steps.artifact-upload-step.outputs.artifact-id }}' + echo 'Artifact URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' + cat 'Run curl ${{ steps.artifact-upload-step.outputs.artifact-url }} | git patch apply' > $GITHUB_STEP_SUMMARY diff --git a/CODEOWNERS b/CODEOWNERS index c5f9f4397578a..688acb40fce16 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -39,12 +39,14 @@ /Zend/zend.* @dstogov /Zend/zend_alloc.* @dstogov /Zend/zend_API.* @dstogov +/Zend/zend_call_stack.* @arnaud-lb /Zend/zend_closures.* @dstogov /Zend/zend_execute.* @dstogov /Zend/zend_execute_API.c @dstogov -/Zend/zend_gc.* @dstogov +/Zend/zend_gc.* @dstogov @arnaud-lb /Zend/zend_hash.* @dstogov /Zend/zend_inheritance.* @dstogov +/Zend/zend_max_execution_timer.* @arnaud-lb /Zend/zend_object_handlers.* @dstogov /Zend/zend_objects.* @dstogov /Zend/zend_objects_API.* @dstogov diff --git a/NEWS b/NEWS index 7e50c4be37f1c..fe4f98f4a6cc5 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ PHP NEWS array to hashed). (ilutov) . Fixed zend fiber build for solaris default mode (32 bits). (David Carlier) . Fixed zend call stack size for macOs/arm64. (David Carlier) + . Added support for Zend Max Execution Timers on FreeBSD (Kévin Dunglas) - Curl: . Deprecated the CURLOPT_BINARYTRANSFER constant. (divinity76) @@ -174,6 +175,7 @@ PHP NEWS . Add support for 4 new rounding modes to the round() function. (Jorg Sowa) . debug_zval_dump() now indicates whether an array is packed. (Max Semenik) . Fix GH-12143 (Optimize round). (SakiTakamachi) + . Changed return type of long2ip to string from string|false. (Jorg Sowa) - XML: . Added XML_OPTION_PARSE_HUGE parser option. (nielsdos) diff --git a/UPGRADING b/UPGRADING index 44594ad40ab61..6f97856999af2 100644 --- a/UPGRADING +++ b/UPGRADING @@ -364,6 +364,7 @@ PHP 8.4 UPGRADE NOTES decimal number and round it to 0.29. However, "pre-rounding" incorrectly rounds certain numbers, so this fix removes "pre-rounding" and changes the way numbers are compared, so that the values ​​are correctly rounded as decimal numbers. + . long2ip() now returns string instead of string|false. ======================================== 6. New Functions diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 820705e8b6d2f..bb5e9c10dd098 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -69,6 +69,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES - M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h). - M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH). - M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES). + - M4 macro PHP_SOCKADDR_CHECKS has been removed (use AC_CHECK_TYPES and + AC_CHECK_MEMBERS). c. Windows build system changes - The configure options --with-oci8-11g, --with-oci8-12c, --with-oci8-19 have diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 16971fc178ea7..d1799ad0de821 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -468,7 +468,7 @@ static const func_info_t func_infos[] = { FN("array_rand", MAY_BE_LONG|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING), F1("base64_encode", MAY_BE_STRING), F1("base64_decode", MAY_BE_STRING|MAY_BE_FALSE), - F1("long2ip", MAY_BE_STRING|MAY_BE_FALSE), + F1("long2ip", MAY_BE_STRING), F1("getenv", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE), F1("getopt", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_FALSE|MAY_BE_FALSE), #if defined(HAVE_NANOSLEEP) diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index 832045f23e00e..feb2fcc2a63e4 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -306,7 +306,7 @@ AC_ARG_ENABLE([zend-max-execution-timers], [ZEND_MAX_EXECUTION_TIMERS=$enableval], [ZEND_MAX_EXECUTION_TIMERS=$ZEND_ZTS]) -AS_CASE(["$host_alias"], [*linux*], [], [ZEND_MAX_EXECUTION_TIMERS='no']) +AS_CASE(["$host_alias"], [*linux*|*freebsd*], [], [ZEND_MAX_EXECUTION_TIMERS='no']) PHP_CHECK_FUNC(timer_create, rt) if test "$ac_cv_func_timer_create" != "yes"; then diff --git a/Zend/tests/stack_limit/stack_limit_010.phpt b/Zend/tests/stack_limit/stack_limit_010.phpt index 9e37555e6decc..4f8358fb41e71 100644 --- a/Zend/tests/stack_limit/stack_limit_010.phpt +++ b/Zend/tests/stack_limit/stack_limit_010.phpt @@ -27,6 +27,7 @@ $expectedMaxSize = match(php_uname('s')) { 'true' => 16*1024*1024, // https://github.com/actions/runner-images/pull/3328 default => 8*1024*1024, }, + 'SunOS' => 10 * 1024 * 1024, 'Windows NT' => 67108864 - 4*4096, // Set by sapi/cli/config.w32 }; diff --git a/Zend/zend_call_stack.c b/Zend/zend_call_stack.c index a89e9898ee864..ad6c1932553a9 100644 --- a/Zend/zend_call_stack.c +++ b/Zend/zend_call_stack.c @@ -68,6 +68,7 @@ typedef int boolean_t; #include #include #include +#include #endif #ifdef ZEND_CHECK_STACK_LIMIT @@ -664,43 +665,17 @@ static bool zend_call_stack_get_netbsd(zend_call_stack *stack) #endif /* defined(__NetBSD__) */ #if defined(__sun) -# if defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack) { - pthread_attr_t attr; - int error; - void *addr; - size_t max_size, guard_size; - - error = pthread_attr_get_np(pthread_self(), &attr); - if (error) { - return false; - } - - error = pthread_attr_getstack(&attr, &addr, &max_size); - if (error) { - return false; - } - - error = pthread_attr_getguardsize(&attr, &guard_size); - if (error) { + stack_t s; + if (thr_stksegment(&s) < 0) { return false; } - addr = (char *)addr + guard_size; - max_size -= guard_size; - - stack->base = (char *)addr + max_size; - stack->max_size = max_size; - + stack->max_size = s.ss_size; + stack->base = s.ss_sp; return true; } -# else /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */ -static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack) -{ - return false; -} -# endif /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */ static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack) { @@ -723,7 +698,7 @@ static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack) } size = (1 << 20); - snprintf(path, sizeof(path), "/proc/%d/map", pid); + snprintf(path, sizeof(path), "/proc/%d/map", (int)pid); if ((fd = open(path, O_RDONLY)) == -1) { Prelease(proc, 0); diff --git a/Zend/zend_max_execution_timer.c b/Zend/zend_max_execution_timer.c index 48a4d1bd66415..92b70fbb2a6ad 100644 --- a/Zend/zend_max_execution_timer.c +++ b/Zend/zend_max_execution_timer.c @@ -23,6 +23,9 @@ #include #include #include +# ifdef __FreeBSD__ +# include +# endif #include "zend.h" #include "zend_globals.h" @@ -33,6 +36,13 @@ # define sigev_notify_thread_id _sigev_un._tid # endif +// FreeBSD doesn't support CLOCK_BOOTTIME +# ifdef __FreeBSD__ +# define ZEND_MAX_EXECUTION_TIMERS_CLOCK CLOCK_MONOTONIC +# else +# define ZEND_MAX_EXECUTION_TIMERS_CLOCK CLOCK_BOOTTIME +# endif + ZEND_API void zend_max_execution_timer_init(void) /* {{{ */ { pid_t pid = getpid(); @@ -45,10 +55,14 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */ sev.sigev_notify = SIGEV_THREAD_ID; sev.sigev_value.sival_ptr = &EG(max_execution_timer_timer); sev.sigev_signo = SIGRTMIN; +# ifdef __FreeBSD__ + sev.sigev_notify_thread_id = pthread_getthreadid_np(); +# else sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid); +# endif // Measure wall time instead of CPU time as originally planned now that it is possible https://github.com/php/php-src/pull/6504#issuecomment-1370303727 - if (timer_create(CLOCK_BOOTTIME, &sev, &EG(max_execution_timer_timer)) != 0) { + if (timer_create(ZEND_MAX_EXECUTION_TIMERS_CLOCK, &sev, &EG(max_execution_timer_timer)) != 0) { zend_strerror_noreturn(E_ERROR, errno, "Could not create timer"); } diff --git a/build/php.m4 b/build/php.m4 index 326c312674dfc..8b915d65aff2e 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1242,31 +1242,6 @@ AC_DEFUN([PHP_MISSING_TIME_R_DECL],[ AC_MSG_RESULT([done]) ]) -dnl -dnl PHP_SOCKADDR_CHECKS -dnl -AC_DEFUN([PHP_SOCKADDR_CHECKS], [ - dnl Check for struct sockaddr_storage exists. - AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_sockaddr_storage, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -#include ]], - [[struct sockaddr_storage s; s]])], - [ac_cv_sockaddr_storage=yes], [ac_cv_sockaddr_storage=no]) - ]) - if test "$ac_cv_sockaddr_storage" = "yes"; then - AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage]) - fi - dnl Check if field sa_len exists in struct sockaddr. - AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -#include ]], [[static struct sockaddr sa; int n = (int) sa.sa_len; return n;]])], - [ac_cv_sockaddr_sa_len=yes], [ac_cv_sockaddr_sa_len=no]) - ]) - if test "$ac_cv_sockaddr_sa_len" = "yes"; then - AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has field sa_len]) - fi -]) - dnl dnl PHP_EBCDIC dnl diff --git a/configure.ac b/configure.ac index 1e74b29669244..f807bf215594a 100644 --- a/configure.ac +++ b/configure.ac @@ -552,7 +552,8 @@ dnl Checks for types. AC_TYPE_UID_T dnl Checks for sockaddr_storage and sockaddr.sa_len. -PHP_SOCKADDR_CHECKS +AC_CHECK_TYPES([struct sockaddr_storage],,,[#include ]) +AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[#include ]) dnl Checks for GCC function attributes on all systems except ones without glibc dnl Fix for these systems is already included in GCC 7, but not on GCC 6. diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt index 7fc24684c8f14..1b4ea8e9a11fd 100644 --- a/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic.phpt @@ -15,7 +15,6 @@ foreach([ LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, LDAP_OPT_X_TLS_PROTOCOL_TLS1_1, LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, - LDAP_OPT_X_TLS_PROTOCOL_TLS1_3, ] as $option) { $result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MAX, $option); var_dump($result); @@ -35,5 +34,3 @@ bool(true) int(770) bool(true) int(771) -bool(true) -int(772) diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic_tls13.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic_tls13.phpt new file mode 100644 index 0000000000000..2f83b807c4a4d --- /dev/null +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_max_basic_tls13.phpt @@ -0,0 +1,45 @@ +--TEST-- +ldap_set_option() - Basic test for TLS protocol max ldap option +--CREDITS-- +Chad Sikorra +--EXTENSIONS-- +ldap +--SKIPIF-- + +--EXPECT-- +bool(true) +int(512) +bool(true) +int(768) +bool(true) +int(769) +bool(true) +int(770) +bool(true) +int(771) +bool(true) +int(772) diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt index 5c4da7368b62d..44abaeb9d9a3b 100644 --- a/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic.phpt @@ -15,7 +15,6 @@ foreach([ LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, LDAP_OPT_X_TLS_PROTOCOL_TLS1_1, LDAP_OPT_X_TLS_PROTOCOL_TLS1_2, - LDAP_OPT_X_TLS_PROTOCOL_TLS1_3, ] as $option) { $result = ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MIN, $option); var_dump($result); @@ -35,5 +34,3 @@ bool(true) int(770) bool(true) int(771) -bool(true) -int(772) diff --git a/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic_tls13.phpt b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic_tls13.phpt new file mode 100644 index 0000000000000..e2f2af8763bf0 --- /dev/null +++ b/ext/ldap/tests/ldap_set_option_tls_protocol_min_basic_tls13.phpt @@ -0,0 +1,45 @@ +--TEST-- +ldap_set_option() - Basic test for TLS protocol min ldap option +--CREDITS-- +Chad Sikorra +--EXTENSIONS-- +ldap +--SKIPIF-- + +--EXPECT-- +bool(true) +int(512) +bool(true) +int(768) +bool(true) +int(769) +bool(true) +int(770) +bool(true) +int(771) +bool(true) +int(772) diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4 index 398354fdb9a99..d0f630c5502ca 100644 --- a/ext/sockets/config.m4 +++ b/ext/sockets/config.m4 @@ -9,20 +9,8 @@ if test "$PHP_SOCKETS" != "no"; then AC_CHECK_HEADERS([sys/sockio.h linux/filter.h]) AC_DEFINE([HAVE_SOCKETS], 1, [ ]) - dnl Check for fied ss_family in sockaddr_storage (missing in AIX until 5.3) - AC_CACHE_CHECK([for field ss_family in struct sockaddr_storage], ac_cv_ss_family, - [ - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include - ]], [[struct sockaddr_storage sa_store; sa_store.ss_family = AF_INET6;]])], - [ac_cv_ss_family=yes], [ac_cv_ss_family=no]) - ]) - - if test "$ac_cv_ss_family" = yes; then - AC_DEFINE(HAVE_SA_SS_FAMILY,1,[Whether you have sockaddr_storage.ss_family]) - fi + dnl Check for field ss_family in sockaddr_storage (missing in AIX until 5.3) + AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],,,[#include ]) dnl Check for AI_V4MAPPED flag AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ac_cv_gai_ai_v4mapped], diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index 82672e68f2bab..82287cfa1fe49 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -790,7 +790,7 @@ zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, uns struct ifreq cur_req; memcpy(&cur_req, p, sizeof(struct ifreq)); -#ifdef HAVE_SOCKADDR_SA_LEN +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN entry_len = cur_req.ifr_addr.sa_len + sizeof(cur_req.ifr_name); #else /* if there's no sa_len, assume the ifr_addr field is a sockaddr */ diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 93eba9da0731a..42db7679522ed 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -132,7 +132,7 @@ PHP_SOCKETS_API bool socket_import_file_descriptor(PHP_SOCKET socket, php_socket #define phpext_sockets_ptr NULL #endif -#if defined(_AIX) && !defined(HAVE_SA_SS_FAMILY) +#if defined(_AIX) && !defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY) # define ss_family __ss_family #endif diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d62951b63ff26..ed4309818275a 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -643,11 +643,10 @@ PHP_FUNCTION(long2ip) ip = (zend_ulong)sip; myaddr.s_addr = htonl(ip); - if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) { - RETURN_STRING(str); - } else { - RETURN_FALSE; - } + const char* result = inet_ntop(AF_INET, &myaddr, str, sizeof(str)); + ZEND_ASSERT(result != NULL); + + RETURN_STRING(str); } /* }}} */ diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index ed73d16d6d0b9..899d29ea3b078 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1945,7 +1945,7 @@ function constant(string $name): mixed {} function ip2long(string $ip): int|false {} /** @refcount 1 */ -function long2ip(int $ip): string|false {} +function long2ip(int $ip): string {} /** * @return string|array|false diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 4efdcb54546b6..7a1812d7ca565 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 0bd0ac5d23881670cac81cda3e274cbee1e9a8dc */ + * Stub hash: 1350cc5169dbd48df08513f01c10d5706d47b8d4 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -381,7 +381,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ip2long, 0, 1, MAY_BE_LONG|MAY_B ZEND_ARG_TYPE_INFO(0, ip, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_long2ip, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_long2ip, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, ip, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/standard/tests/network/ip_x86_64.phpt b/ext/standard/tests/network/ip_x86_64.phpt index dd81bde55c89b..16e855188aafa 100644 --- a/ext/standard/tests/network/ip_x86_64.phpt +++ b/ext/standard/tests/network/ip_x86_64.phpt @@ -26,6 +26,8 @@ var_dump(ip2long("777.777.777.777")); var_dump(ip2long("111.111.111.111")); var_dump(long2ip(-110000)); +var_dump(long2ip(PHP_INT_MAX)); +var_dump(long2ip(PHP_INT_MIN)); echo "Done\n"; ?> @@ -46,4 +48,6 @@ bool(false) bool(false) int(1869573999) string(13) "255.254.82.80" +string(15) "255.255.255.255" +string(7) "0.0.0.0" Done diff --git a/main/php_network.h b/main/php_network.h index 7cc3609c44089..0f155211d8fc7 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -247,11 +247,11 @@ static inline bool _php_check_fd_setsize(php_socket_t *max_fd, int setsize) #define PHP_SOCK_CHUNK_SIZE 8192 -#ifdef HAVE_SOCKADDR_STORAGE +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE typedef struct sockaddr_storage php_sockaddr_storage; #else typedef struct { -#ifdef HAVE_SOCKADDR_SA_LEN +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN unsigned char ss_len; unsigned char ss_family; #else diff --git a/scripts/dev/format_pull_request.php b/scripts/dev/format_pull_request.php new file mode 100644 index 0000000000000..6d3d74043e9fa --- /dev/null +++ b/scripts/dev/format_pull_request.php @@ -0,0 +1,91 @@ + 'WebKit', + 'UseTab' => 'ForIndentation', + // clang-format's support for tabs isn't great, and we have to say "4 spaces" to get 1 tab + 'IndentWidth' => 4, + 'TabWidth' => 4, +); +$cmd = array( + 'git diff -U0 --no-color --relative HEAD^ |', + 'clang-format-diff -i -p1 -style=' . escapeshellarg(json_encode($clangFormatOptions)), + '-iregex=' . escapeshellarg('.*\.(c|cc|cpp|c\+\+|cxx|h|hh|hpp|h\+\+|h)$'), +); +$cmd = implode(' ', $cmd); +passthru($cmd, $ret); +if ($ret !== 0) { + fwrite(STDERR, "Error: clang-format-diff failed with exit code {$ret}\n"); + fwrite(STDERR, "cmd:\n{$cmd}\n"); + if (!$force) { + // remove last commit and reset + passthru('git reset --hard HEAD^ --quiet'); + } + exit(1); +} +passthru('git diff'); +if (!$force) { + // remove last commit and reset + passthru('git reset --hard HEAD^ --quiet'); +}