Skip to content

Commit 5082f67

Browse files
committed
Add initial support for Cosmopolitan Libc
1 parent 8e06a81 commit 5082f67

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cmake/cmake/modules/PHP/StandardLibrary.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Determine the C standard library used for the build.
99
1010
Lowercase name of the C standard library:
1111
12+
* `cosmopolitan`
1213
* `dietlibc`
1314
* `glibc`
1415
* `llvm`
@@ -65,6 +66,17 @@ if(_PHP_C_STANDARD_LIBRARY_DIETLIBC)
6566
return()
6667
endif()
6768

69+
# The Cosmopolitan Libc.
70+
cmake_push_check_state(RESET)
71+
set(CMAKE_REQUIRED_QUIET TRUE)
72+
check_symbol_exists(__COSMOPOLITAN__ "" _PHP_C_STANDARD_LIBRARY_COSMOPOLITAN)
73+
cmake_pop_check_state()
74+
if(_PHP_C_STANDARD_LIBRARY_COSMOPOLITAN)
75+
set_property(CACHE PHP_C_STANDARD_LIBRARY PROPERTY VALUE "cosmopolitan")
76+
message(CHECK_PASS "Cosmopolitan Libc")
77+
return()
78+
endif()
79+
6880
# The GNU C standard library has __GLIBC__ and __GLIBC_MINOR__ symbols since the
6981
# very early version 2.0.
7082
cmake_push_check_state(RESET)

cmake/cmake/modules/PHP/SystemExtensions.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ target_compile_definitions(
118118
PHP::SystemExtensions
119119
INTERFACE
120120
_ALL_SOURCE=1
121+
_COSMO_SOURCE
121122
_DARWIN_C_SOURCE=1
122123
_GNU_SOURCE
123124
_NETBSD_SOURCE=1
@@ -228,6 +229,10 @@ set(PHP_SYSTEM_EXTENSIONS_CODE [[
228229
#ifndef _ALL_SOURCE
229230
# define _ALL_SOURCE 1
230231
#endif
232+
/* Enable extensions on Cosmopolitan Libc. */
233+
#ifndef _COSMO_SOURCE
234+
# define _COSMO_SOURCE
235+
#endif
231236
/* Enable general extensions on macOS. */
232237
#ifndef _DARWIN_C_SOURCE
233238
# define _DARWIN_C_SOURCE 1

0 commit comments

Comments
 (0)