Skip to content

Commit

Permalink
Use proper feature flags instead of #ifdef __linux__
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Jul 17, 2024
1 parent e27036d commit 53d0069
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if test "$PHP_XDEBUG" != "no"; then
AC_CHECK_HEADERS([netinet/in.h poll.h sys/poll.h])
case $host_os in
linux*)
AC_DEFINE(HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT,1,[ do have control socket support? ])
AC_CHECK_HEADERS([linux/rtnetlink.h], [], [
case $host_os in
linux-musl*)
Expand Down
10 changes: 6 additions & 4 deletions src/base/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include "base.h"
#include "filter.h"
#ifdef __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
# include "ctrl_socket.h"
#endif
#include "develop/develop.h"
Expand Down Expand Up @@ -762,7 +762,7 @@ static void xdebug_execute_user_code_begin(zend_execute_data *execute_data)
(fse - 1)->user_defined = XDEBUG_USER_DEFINED;
}

#ifdef __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
xdebug_control_socket_dispatch();
#endif

Expand Down Expand Up @@ -1318,7 +1318,9 @@ void xdebug_base_minit(INIT_FUNC_ARGS)
XG_BASE(private_tmp) = NULL;
#ifdef __linux__
read_systemd_private_tmp_directory(&XG_BASE(private_tmp));
#endif

#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
XG_BASE(control_socket_path) = NULL;
XG_BASE(control_socket_fd) = 0;
XG_BASE(control_socket_last_trigger) = 0;
Expand Down Expand Up @@ -1379,7 +1381,7 @@ void xdebug_base_rinit()
XG_BASE(in_var_serialisation) = 0;
zend_ce_closure->serialize = xdebug_closure_serialize_deny_wrapper;

#ifdef __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
/* Set-up Control Socket */

# if HAVE_XDEBUG_CLOCK_GETTIME
Expand Down Expand Up @@ -1445,7 +1447,7 @@ void xdebug_base_post_deactivate()
XG_BASE(filters_tracing) = NULL;
XG_BASE(filters_code_coverage) = NULL;

#ifdef __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
/* Close Down Control Socket */
xdebug_control_socket_teardown();
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/base/base_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef struct _xdebug_base_globals_t {
/* Systemd Private Temp */
char *private_tmp;

#ifdef __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
/* Control Socket */
char *control_socket_path;
int control_socket_fd;
Expand All @@ -86,7 +86,7 @@ typedef struct _xdebug_base_globals_t {
} xdebug_base_globals_t;

typedef struct _xdebug_base_settings_t {
#ifdef __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
int control_socket_granularity;
zend_long control_socket_threshold_ms;
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/base/ctrl_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
+----------------------------------------------------------------------+
*/

#ifdef __linux__

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand All @@ -28,6 +26,8 @@

#include "php_xdebug.h"

#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT

#include "ctrl_socket.h"
#include "lib/cmd_parser.h"
#include "lib/log.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ int xdebug_lib_set_mode(const char *mode)
return result;
}

#if __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
int xdebug_lib_set_control_socket_granularity(char *value)
{
if (strcmp(value, "no") == 0 || value[0] == '\0') {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ int xdebug_lib_set_start_upon_error(char *value);
int xdebug_lib_start_upon_error(void);
int xdebug_lib_get_start_upon_error(void);

#if __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
# define XDEBUG_CONTROL_SOCKET_OFF 1
# define XDEBUG_CONTROL_SOCKET_DEFAULT 2
# define XDEBUG_CONTROL_SOCKET_TIME 3
Expand Down
10 changes: 5 additions & 5 deletions xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "php_xdebug_arginfo.h"

#include "base/base.h"
#ifdef __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
# include "base/ctrl_socket.h"
#endif
#include "base/filter.h"
Expand Down Expand Up @@ -198,7 +198,7 @@ static PHP_INI_MH(OnUpdateChangedSetting)
return FAILURE;
}

#if __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
static PHP_INI_MH(OnUpdateCtrlSocket)
{
if (!new_value) {
Expand Down Expand Up @@ -233,7 +233,7 @@ ZEND_INI_DISP(display_changed_setting)
ZEND_PUTS("(setting renamed in Xdebug 3)");
}

#if __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
ZEND_INI_DISP(display_control_socket)
{
switch (XINI_BASE(control_socket_granularity))
Expand Down Expand Up @@ -312,7 +312,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("xdebug.trigger_value", "", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, settings.library.trigger_value, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.file_link_format", "", PHP_INI_ALL, OnUpdateString, settings.library.file_link_format, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.filename_format", "", PHP_INI_ALL, OnUpdateString, settings.library.filename_format, zend_xdebug_globals, xdebug_globals)
#if __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
PHP_INI_ENTRY_EX("xdebug.control_socket", "default", PHP_INI_ALL, OnUpdateCtrlSocket, display_control_socket)
#endif

Expand Down Expand Up @@ -776,7 +776,7 @@ ZEND_DLEXPORT void xdebug_statement_call(zend_execute_data *frame)
xdebug_debugger_statement_call(op_array->filename, lineno);
}

#ifdef __linux__
#if HAVE_XDEBUG_CONTROL_SOCKET_SUPPORT
xdebug_control_socket_dispatch();
#endif
}
Expand Down

0 comments on commit 53d0069

Please sign in to comment.