Skip to content

Commit 17129d6

Browse files
committed
Make write() check more consistent and sync io.h header checks
The <io.h> header is always available on Windows as part of the Windows SDK.
1 parent 7521fb6 commit 17129d6

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

cmake/cmake/checks/CheckWrite.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
#[=============================================================================[
22
Check whether write(2) can successfully write to stdout.
3-
43
On Windows, _write() (and its deprecated alias write()) can also write to stdout
5-
but this PHP code uses this for POSIX targets only.
4+
but PHP code uses this for POSIX targets only.
65
76
Result/cache variables:
87
9-
* PHP_WRITE_STDOUT - Whether 'write()' can write to stdout.
8+
* PHP_WRITE_STDOUT
109
#]=============================================================================]
1110

1211
include(CheckIncludeFiles)
1312
include(CheckSourceRuns)
1413
include(CMakePushCheckState)
1514

16-
# On Windows below check succeeds, however PHP implementation has it disabled.
1715
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
1816
set(PHP_WRITE_STDOUT FALSE)
1917
return()
@@ -49,12 +47,17 @@ cmake_push_check_state(RESET)
4947
# include <unistd.h>
5048
#endif
5149
50+
#ifdef _WIN32
51+
# include <io.h>
52+
# undef write
53+
# define write _write
54+
#endif
55+
5256
#define TEXT "This is the test message -- "
5357
5458
int main(void)
5559
{
5660
int n;
57-
5861
n = write(1, TEXT, sizeof(TEXT)-1);
5962
return (!(n == sizeof(TEXT)-1));
6063
}

cmake/cmake/platforms/Windows.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
8888
set(HAVE_IF_NAMETOINDEX FALSE)
8989
set(HAVE_IFADDRS_H FALSE)
9090
set(HAVE_IMMINTRIN_H TRUE)
91-
set(HAVE_IO_H TRUE)
9291
set(HAVE_ISSETUGID FALSE)
9392
set(HAVE_KILL FALSE)
9493
set(HAVE_LANGINFO_H FALSE)

cmake/ext/date/cmake/config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
/* Define to 1 if you have the <io.h> header file. */
2-
#cmakedefine HAVE_IO_H 1
3-
41
/* Define to 1 if you have the <timelib_config.h> header file. */
52
#cmakedefine HAVE_TIMELIB_CONFIG_H 1

cmake/ext/date/lib/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ project(
3535
VERSION ${timelib_VERSION}
3636
)
3737

38-
include(CheckIncludeFiles)
39-
4038
if(NOT TIMELIB_TARGET)
4139
set(TIMELIB_TARGET timelib)
4240
add_library(${TIMELIB_TARGET})
@@ -82,7 +80,9 @@ target_compile_definitions(
8280
HAVE_STRTOLL
8381
)
8482

85-
check_include_files(io.h HAVE_IO_H)
83+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
84+
set(HAVE_IO_H TRUE)
85+
endif()
8686

8787
cmake_path(
8888
RELATIVE_PATH

0 commit comments

Comments
 (0)