Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building against cosmopolitan libc #837

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion c/expeditor.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ static void s_ee_set_color(int color_id, IBOOL background) {
# include <unistd.h>
# include <time.h>
#endif
#if !defined(__GLIBC__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__linux__) && !defined(__EMSCRIPTEN__) && !defined(NO_USELOCALE)
#if !defined(__GLIBC__) && !defined(__COSMOPOLITAN__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__linux__) && !defined(__EMSCRIPTEN__) && !defined(NO_USELOCALE)
# include <xlocale.h>
#endif

Expand Down
4 changes: 2 additions & 2 deletions c/prim5.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,8 @@ static ptr s_system(const char *s) {
#ifdef WIN32
return Sinteger(status);
#else
if WIFEXITED(status) return Sinteger(WEXITSTATUS(status));
if WIFSIGNALED(status) return Sinteger(-WTERMSIG(status));
if (WIFEXITED(status)) return Sinteger(WEXITSTATUS(status));
if (WIFSIGNALED(status)) return Sinteger(-WTERMSIG(status));
S_error("system", "cannot determine subprocess exit status");
return 0 /* not reached */;
#endif /* WIN32 */
Expand Down
8 changes: 6 additions & 2 deletions c/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ FORCEINLINE void store_unaligned_uptr(uptr *addr, uptr val) {
/*****************************************/
/* Operating systems */

#if defined(__linux__) || defined(__GNU__) /* Hurd */
#if defined(__linux__) || defined(__COSMOPOLITAN__) || defined(__GNU__) /* Hurd */
#define NOBLOCK O_NONBLOCK
#define LOAD_SHARED_OBJECT
/* cosmo dylib support is experimental, disable when using cosmo libc
https://github.com/jart/cosmopolitan/blob/3.3.10/libc/dlopen/dlopen.c#L801 */
#ifndef __COSMOPOLITAN__
# define LOAD_SHARED_OBJECT
#endif
#define USE_MMAP
#define MMAP_HEAP
#define IEEE_DOUBLE
Expand Down