Skip to content

Commit

Permalink
Allow building against cosmopolitan libc
Browse files Browse the repository at this point in the history
  • Loading branch information
jjsullivan5196 committed May 30, 2024
1 parent fa451a1 commit 2959ffa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
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

0 comments on commit 2959ffa

Please sign in to comment.