Skip to content

Commit 650086f

Browse files
authored
Exclude unused functions from compilation units (phpGH-17686)
This avoids Clang complaining with `-Wunused-function`. We also introduce the macro `PRELOAD_SUPPORT` for clarification.
1 parent 6deaaf6 commit 650086f

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

ext/opcache/ZendAccelerator.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,15 @@ static zend_result (*orig_post_startup_cb)(void);
136136
static zend_result accel_post_startup(void);
137137
static zend_result accel_finish_startup(void);
138138

139+
#ifndef ZEND_WIN32
140+
# define PRELOAD_SUPPORT
141+
#endif
142+
143+
#ifdef PRELOAD_SUPPORT
139144
static void preload_shutdown(void);
140145
static void preload_activate(void);
141146
static void preload_restart(void);
147+
#endif
142148

143149
#ifdef ZEND_WIN32
144150
# define INCREMENT(v) InterlockedIncrement64(&ZCSG(v))
@@ -2713,9 +2719,11 @@ zend_result accel_activate(INIT_FUNC_ARGS)
27132719
}
27142720

27152721
zend_shared_alloc_restore_state();
2722+
#ifdef PRELOAD_SUPPORT
27162723
if (ZCSG(preload_script)) {
27172724
preload_restart();
27182725
}
2726+
#endif
27192727

27202728
#ifdef HAVE_JIT
27212729
zend_jit_restart();
@@ -2757,9 +2765,11 @@ zend_result accel_activate(INIT_FUNC_ARGS)
27572765
zend_jit_activate();
27582766
#endif
27592767

2768+
#ifdef PRELOAD_SUPPORT
27602769
if (ZCSG(preload_script)) {
27612770
preload_activate();
27622771
}
2772+
#endif
27632773

27642774
return SUCCESS;
27652775
}
@@ -3455,9 +3465,11 @@ void accel_shutdown(void)
34553465
return;
34563466
}
34573467

3468+
#ifdef PRELOAD_SUPPORT
34583469
if (ZCSG(preload_script)) {
34593470
preload_shutdown();
34603471
}
3472+
#endif
34613473

34623474
_file_cache_only = file_cache_only;
34633475

@@ -3566,6 +3578,7 @@ void accelerator_shm_read_unlock(void)
35663578
}
35673579

35683580
/* Preloading */
3581+
#ifdef PRELOAD_SUPPORT
35693582
static HashTable *preload_scripts = NULL;
35703583
static zend_op_array *(*preload_orig_compile_file)(zend_file_handle *file_handle, int type);
35713584

@@ -4665,7 +4678,6 @@ static void preload_send_header(sapi_header_struct *sapi_header, void *server_co
46654678
{
46664679
}
46674680

4668-
#ifndef ZEND_WIN32
46694681
static zend_result accel_finish_startup_preload(bool in_child)
46704682
{
46714683
zend_result ret = SUCCESS;

ext/standard/proc_open.c

+4
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ static zend_result convert_command_to_use_shell(wchar_t **cmdw, size_t cmdw_len)
776776
}
777777
#endif
778778

779+
#ifndef PHP_WIN32
779780
/* Convert command parameter array passed as first argument to `proc_open` into command string */
780781
static zend_string* get_command_from_array(HashTable *array, char ***argv, int num_elems)
781782
{
@@ -807,6 +808,7 @@ static zend_string* get_command_from_array(HashTable *array, char ***argv, int n
807808
(*argv)[i] = NULL;
808809
return command;
809810
}
811+
#endif
810812

811813
static descriptorspec_item* alloc_descriptor_array(HashTable *descriptorspec)
812814
{
@@ -1177,6 +1179,7 @@ static void close_all_descriptors(descriptorspec_item *descriptors, int ndesc)
11771179
}
11781180
}
11791181

1182+
#ifndef PHP_WIN32
11801183
static void efree_argv(char **argv)
11811184
{
11821185
if (argv) {
@@ -1188,6 +1191,7 @@ static void efree_argv(char **argv)
11881191
efree(argv);
11891192
}
11901193
}
1194+
#endif
11911195

11921196
/* {{{ Execute a command, with specified files used for input/output */
11931197
PHP_FUNCTION(proc_open)

sapi/cli/php_cli.c

+2
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ static void print_extensions(void) /* {{{ */
221221
#define STDERR_FILENO 2
222222
#endif
223223

224+
#ifdef PHP_WRITE_STDOUT
224225
static inline bool sapi_cli_select(php_socket_t fd)
225226
{
226227
fd_set wfd;
@@ -238,6 +239,7 @@ static inline bool sapi_cli_select(php_socket_t fd)
238239

239240
return ret != -1;
240241
}
242+
#endif
241243

242244
PHP_CLI_API ssize_t sapi_cli_single_write(const char *str, size_t str_length) /* {{{ */
243245
{

sapi/phpdbg/phpdbg.c

+2
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ typedef struct {
851851
int fd;
852852
} php_stdio_stream_data;
853853

854+
#ifndef _WIN32
854855
static ssize_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t count) {
855856
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
856857

@@ -877,6 +878,7 @@ static ssize_t phpdbg_stdiop_write(php_stream *stream, const char *buf, size_t c
877878

878879
return PHPDBG_G(php_stdiop_write)(stream, buf, count);
879880
}
881+
#endif
880882

881883
/* copied from sapi/cli/php_cli.c cli_register_file_handles */
882884
void phpdbg_register_file_handles(void) /* {{{ */

0 commit comments

Comments
 (0)