Skip to content

Commit f7aaec2

Browse files
committed
Revert "Replace CheckPrototypeDefinition with CheckSourceCompiles"
This reverts commit c3b32df. The CheckPrototypeDefinition module is unique among C build systems and should be fixed in the future. Use CheckPrototypeDefinition anyway.
1 parent c3b32df commit f7aaec2

File tree

3 files changed

+42
-52
lines changed

3 files changed

+42
-52
lines changed

cmake/cmake/checks/CheckGethostbynameR.cmake

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See also:
2121
https://www.gnu.org/software/autoconf-archive/ax_func_which_gethostbyname_r.html
2222
#]=============================================================================]
2323

24-
include(CheckSourceCompiles)
24+
include(CheckPrototypeDefinition)
2525
include(CMakePushCheckState)
2626
include(PHP/SearchLibraries)
2727

@@ -61,53 +61,44 @@ function(_php_check_gethostbyname_r)
6161
set(CMAKE_REQUIRED_QUIET TRUE)
6262

6363
# Check for 6 arguments signature.
64-
check_source_compiles(C [[
65-
#include <netdb.h>
66-
int gethostbyname_r(
67-
const char *name,
68-
struct hostent *ret,
69-
char *buf,
70-
size_t buflen,
71-
struct hostent **result,
72-
int *h_errnop
73-
);
74-
int main(void) { return 0; }
75-
]] PHP_HAVE_FUNC_GETHOSTBYNAME_R_6)
76-
64+
check_prototype_definition(
65+
gethostbyname_r
66+
"int gethostbyname_r(const char *name, struct hostent *ret, char *buf, \
67+
size_t buflen, struct hostent **result, int *h_errnop)"
68+
"0"
69+
netdb.h
70+
PHP_HAVE_FUNC_GETHOSTBYNAME_R_6
71+
)
7772
if(PHP_HAVE_FUNC_GETHOSTBYNAME_R_6)
7873
cmake_pop_check_state()
7974
message(CHECK_PASS "six")
8075
return()
8176
endif()
8277

8378
# Check for 5 arguments signature.
84-
check_source_compiles(C [[
85-
#include <netdb.h>
86-
struct hostent *gethostbyname_r(
87-
const char *name,
88-
struct hostent *result,
89-
char *buffer,
90-
int buflen,
91-
int *h_errnop
92-
);
93-
int main(void) { return 0; }
94-
]] PHP_HAVE_FUNC_GETHOSTBYNAME_R_5)
79+
check_prototype_definition(
80+
gethostbyname_r
81+
"struct hostent *gethostbyname_r(const char *name, struct hostent *result, \
82+
char *buffer, int buflen, int *h_errnop)"
83+
"0"
84+
netdb.h
85+
PHP_HAVE_FUNC_GETHOSTBYNAME_R_5
86+
)
9587
if(PHP_HAVE_FUNC_GETHOSTBYNAME_R_5)
9688
cmake_pop_check_state()
9789
message(CHECK_PASS "five")
9890
return()
9991
endif()
10092

10193
# Check for 3 arguments signature.
102-
check_source_compiles(C [[
103-
#include <netdb.h>
104-
int gethostbyname_r(
105-
const char *name,
106-
struct hostent *htent,
107-
struct hostent_data *data
108-
);
109-
int main(void) { return 0; }
110-
]] PHP_HAVE_FUNC_GETHOSTBYNAME_R_3)
94+
check_prototype_definition(
95+
gethostbyname_r
96+
"int gethostbyname_r(const char *name, struct hostent *htent, \
97+
struct hostent_data *data)"
98+
"0"
99+
netdb.h
100+
PHP_HAVE_FUNC_GETHOSTBYNAME_R_3
101+
)
111102
if(PHP_HAVE_FUNC_GETHOSTBYNAME_R_3)
112103
cmake_pop_check_state()
113104
message(CHECK_PASS "three")

cmake/ext/iconv/CMakeLists.txt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ project(
2828
LANGUAGES C
2929
)
3030

31-
include(CheckSourceCompiles)
31+
include(CheckPrototypeDefinition)
3232
include(CheckSourceRuns)
3333
include(CheckSymbolExists)
3434
include(CMakeDependentOption)
@@ -288,17 +288,14 @@ if(TARGET Iconv::Iconv)
288288
cmake_push_check_state(RESET)
289289
set(CMAKE_REQUIRED_LIBRARIES Iconv::Iconv)
290290

291-
check_source_compiles(C [[
292-
#include <iconv.h>
293-
size_t iconv(
294-
iconv_t cd,
295-
const char **src,
296-
size_t *srcleft,
297-
char **dst,
298-
size_t *dstleft
299-
);
300-
int main(void) { return 0; }
301-
]] PHP_EXT_ICONV_CONST)
291+
check_prototype_definition(
292+
iconv
293+
"size_t iconv(iconv_t cd, const char **src, size_t *srcleft, char **dst, \
294+
size_t *dstleft)"
295+
"0"
296+
"iconv.h"
297+
PHP_EXT_ICONV_CONST
298+
)
302299
cmake_pop_check_state()
303300

304301
if(PHP_EXT_ICONV_CONST)

cmake/ext/posix/cmake/CheckTtynameR.cmake

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ On modern systems a simpler check is sufficient in the future:
1010
check_symbol_exists(ttyname_r unistd.h <result-var>)
1111
#]=============================================================================]
1212

13-
include(CheckSourceCompiles)
13+
include(CheckPrototypeDefinition)
1414
include(CheckSourceRuns)
1515
include(CMakePushCheckState)
1616
include(PHP/SystemExtensions)
@@ -41,11 +41,13 @@ function(_php_ext_posix_check_ttyname_r result)
4141
# - _DARWIN_C_SOURCE on older Mac OS X 10.4
4242
set(CMAKE_REQUIRED_LIBRARIES PHP::SystemExtensions)
4343

44-
check_source_compiles(C [[
45-
#include <unistd.h>
46-
int ttyname_r(int fd, char *buf, size_t buflen);
47-
int main(void) { return 0; }
48-
]] PHP_EXT_POSIX_HAVE_TTYNAME_R_SYMBOL)
44+
check_prototype_definition(
45+
ttyname_r
46+
"int ttyname_r(int fd, char *buf, size_t buflen)"
47+
"0"
48+
"unistd.h"
49+
PHP_EXT_POSIX_HAVE_TTYNAME_R_SYMBOL
50+
)
4951

5052
if(NOT PHP_EXT_POSIX_HAVE_TTYNAME_R_SYMBOL)
5153
message(CHECK_FAIL "no (non-standard declaration)")

0 commit comments

Comments
 (0)