Skip to content

Commit 8a7c49f

Browse files
committed
Fix -Werror=strict-prototypes build
This should fix the rest of -Wstrict-prototypes warnings and -Werror=strict-prototypes build issues. CMake still needs to be adjusted for this to work properly and this might be fully working only in future versions.
1 parent 769fba8 commit 8a7c49f

File tree

4 files changed

+106
-98
lines changed

4 files changed

+106
-98
lines changed

cmake/cmake/ConfigureChecks.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H)
6666
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
6767
check_include_file(sys/uio.h HAVE_SYS_UIO_H)
6868
check_include_file(sys/utsname.h HAVE_SYS_UTSNAME_H)
69-
# Solaris <= 10, other systems have statvfs.h.
69+
# Solaris <= 10, other systems have sys/statvfs.h.
7070
check_include_file(sys/vfs.h HAVE_SYS_VFS_H)
7171
check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
7272
check_include_file(sysexits.h HAVE_SYSEXITS_H)
@@ -242,9 +242,7 @@ endif()
242242
################################################################################
243243

244244
check_symbol_exists(alphasort "dirent.h" HAVE_ALPHASORT)
245-
check_symbol_exists(asctime_r "time.h" HAVE_ASCTIME_R)
246245
check_symbol_exists(chroot "unistd.h" HAVE_CHROOT)
247-
check_symbol_exists(ctime_r "time.h" HAVE_CTIME_R)
248246
check_symbol_exists(explicit_memset "string.h" HAVE_EXPLICIT_MEMSET)
249247
check_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
250248

@@ -274,13 +272,11 @@ check_symbol_exists(getservbyname "netdb.h" HAVE_GETSERVBYNAME)
274272
check_symbol_exists(getservbyport "netdb.h" HAVE_GETSERVBYPORT)
275273
check_symbol_exists(getrusage "sys/resource.h" HAVE_GETRUSAGE)
276274
check_symbol_exists(gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY)
277-
check_symbol_exists(gmtime_r "time.h" HAVE_GMTIME_R)
278275
check_symbol_exists(getpwnam_r "pwd.h" HAVE_GETPWNAM_R)
279276
check_symbol_exists(getgrnam_r "grp.h" HAVE_GETGRNAM_R)
280277
check_symbol_exists(getpwuid_r "pwd.h" HAVE_GETPWUID_R)
281278
check_symbol_exists(getwd "unistd.h" HAVE_GETWD)
282279
check_symbol_exists(glob "glob.h" HAVE_GLOB)
283-
check_symbol_exists(localtime_r "time.h" HAVE_LOCALTIME_R)
284280
check_symbol_exists(lchown "unistd.h" HAVE_LCHOWN)
285281
check_symbol_exists(memcntl "sys/mman.h" HAVE_MEMCNTL)
286282

@@ -330,7 +326,6 @@ cmake_push_check_state(RESET)
330326
check_symbol_exists(strptime "time.h" HAVE_STRPTIME)
331327
cmake_pop_check_state()
332328

333-
check_symbol_exists(strtok_r "string.h" HAVE_STRTOK_R)
334329
check_symbol_exists(symlink "unistd.h" HAVE_SYMLINK)
335330
check_symbol_exists(tzset "time.h" HAVE_TZSET)
336331
check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV)
@@ -361,8 +356,8 @@ check_symbol_exists(strlcat "string.h" HAVE_STRLCAT)
361356
check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY)
362357
check_symbol_exists(explicit_bzero "string.h" HAVE_EXPLICIT_BZERO)
363358

364-
# Check for missing declarations of reentrant functions.
365-
include(PHP/CheckMissingTimeR)
359+
# Check reentrant functions.
360+
include(PHP/CheckReentrantFunctions)
366361

367362
# Check fopencookie.
368363
include(PHP/CheckFopencookie)

cmake/cmake/modules/PHP/CheckFclose.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include_guard(GLOBAL)
1414
include(CheckSourceCompiles)
1515
include(CMakePushCheckState)
1616

17-
message(CHECK_START "Checking for fclose declaration")
17+
message(CHECK_START "Checking fclose declaration")
1818

1919
cmake_push_check_state(RESET)
2020
set(CMAKE_REQUIRED_QUIET TRUE)
@@ -23,7 +23,7 @@ cmake_push_check_state(RESET)
2323
#include <stdio.h>
2424
2525
int main(void) {
26-
int (*func)() = fclose;
26+
int (*func)(void) = fclose;
2727
2828
return 0;
2929
}
@@ -38,5 +38,5 @@ if(NOT HAVE_FCLOSE_DECL)
3838
CACHE INTERNAL "Whether fclose declaration is missing"
3939
)
4040
else()
41-
message(CHECK_PASS "ok")
41+
message(CHECK_PASS "found")
4242
endif()

cmake/cmake/modules/PHP/CheckMissingTimeR.cmake

Lines changed: 0 additions & 87 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#[=============================================================================[
2+
Check for reentrant functions and their declarations.
3+
4+
Some systems didn't declare some reentrant functions if _REENTRANT was not
5+
defined. This is mostly obsolete and is intended for the PHP code specific
6+
usage. The check_symbol_exists() is sufficient to check for reentrant functions
7+
on current systems and this module might be obsolete in the future.
8+
9+
Cache variables:
10+
11+
HAVE_LOCALTIME_R
12+
Whether localtime_r() is available.
13+
MISSING_LOCALTIME_R_DECL
14+
Whether localtime_r is not declared.
15+
HAVE_GMTIME_R
16+
Whether gmtime_r() is available.
17+
MISSING_GMTIME_R_DECL
18+
Whether gmtime_r is not declared.
19+
HAVE_ASCTIME_R
20+
Whether asctime_r() is available.
21+
MISSING_ASCTIME_R_DECL
22+
Whether asctime_r is not declared.
23+
HAVE_CTIME_R
24+
Whether ctime_r() is available.
25+
MISSING_CTIME_R_DECL
26+
Whether ctime_r is not declared.
27+
HAVE_STRTOK_R
28+
Whether strtok_r() is available.
29+
MISSING_STRTOK_R_DECL
30+
Whether strtok_r is not declared.
31+
]=============================================================================]#
32+
33+
include_guard(GLOBAL)
34+
35+
include(CheckFunctionExists)
36+
include(CheckSourceCompiles)
37+
include(CMakePushCheckState)
38+
39+
# Define HAVE_<symbol> if linker sees the function, and MISSING_<symbol>_DECL if
40+
# function is not declared by checking the required header and given test body.
41+
function(_php_check_reentrant_function symbol header body)
42+
string(TOUPPER "${symbol}" const)
43+
44+
# Check if linker sees the function.
45+
check_function_exists(${symbol} HAVE_${const})
46+
47+
message(CHECK_START "Checking ${symbol} declaration")
48+
49+
cmake_push_check_state(RESET)
50+
set(CMAKE_REQUIRED_QUIET TRUE)
51+
52+
check_source_compiles(C "
53+
#include <${header}>
54+
int main(void) {
55+
${body};
56+
return 0;
57+
}
58+
" _have_${symbol}_declaration)
59+
cmake_pop_check_state()
60+
61+
if(NOT _have_${symbol}_declaration)
62+
message(CHECK_FAIL "missing")
63+
64+
set(
65+
MISSING_${const}_DECL 1
66+
CACHE INTERNAL "Define if ${symbol} is not declared."
67+
)
68+
else()
69+
message(CHECK_PASS "found")
70+
endif()
71+
endfunction()
72+
73+
_php_check_reentrant_function(
74+
localtime_r
75+
time.h
76+
"struct tm *(*func)(void) = localtime_r"
77+
)
78+
79+
_php_check_reentrant_function(
80+
gmtime_r
81+
time.h
82+
"struct tm *(*func)(void) = gmtime_r"
83+
)
84+
85+
_php_check_reentrant_function(
86+
asctime_r
87+
time.h
88+
"char *(*func)(void) = asctime_r"
89+
)
90+
_php_check_reentrant_function(
91+
ctime_r
92+
time.h
93+
"char *(*func)(void) = ctime_r"
94+
)
95+
96+
_php_check_reentrant_function(
97+
strtok_r
98+
string.h
99+
"char *(*func)(void) = strtok_r"
100+
)

0 commit comments

Comments
 (0)