From 161761bc2393a91c875fdcef38284c63db080729 Mon Sep 17 00:00:00 2001 From: Ariel Nunez <54999+ingenieroariel@users.noreply.github.com> Date: Sun, 6 Nov 2022 12:53:20 -0500 Subject: [PATCH 1/2] Changes for latest cosmo, as of early Nov, 2022 --- Include/Python.h | 5 ++++- Modules/_posixsubprocess.c | 4 +++- Modules/posixmodule.c | 29 ++++++++++++++++++++++++++--- README.md | 10 ++++++++++ superconfigure | 4 ++-- 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Include/Python.h b/Include/Python.h index c3d2db007fd05f..0f3e6b8cf94d3b 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -7,6 +7,9 @@ #define _POSIX_THREADS 1 // Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { +#define IMAGE_BASE_VIRTUAL 0x400000 +#define PTHREAD_SCOPE_SYSTEM 0 + // Include Python header files #include "patchlevel.h" #include "pyconfig.h" @@ -106,7 +109,7 @@ #include "cpython/pyfpe.h" #include "tracemalloc.h" -typedef uint64_t clockid_t; +typedef int32_t clockid_t; #define SSIZE_MAX __INT64_MAX__ #define SSIZE_MIN (-SSIZE_MAX -1) diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index 60c1c0dd286828..c3452e7c621749 100644 --- a/Modules/_posixsubprocess.c +++ b/Modules/_posixsubprocess.c @@ -40,6 +40,8 @@ # define SYS_getdents64 __NR_getdents64 #endif +int sys_getdents(unsigned, void *, unsigned, long *); + #if defined(__linux__) && defined(HAVE_VFORK) && defined(HAVE_SIGNAL_H) && \ defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK) /* If this is ever expanded to non-Linux platforms, verify what calls are @@ -300,7 +302,7 @@ _close_open_fds_safe(int start_fd, PyObject* py_fds_to_keep) } else { char buffer[sizeof(struct linux_dirent64)]; int bytes; - while ((bytes = getdents(fd_dir_fd, + while ((bytes = sys_getdents(fd_dir_fd, (struct linux_dirent64 *)buffer, sizeof(buffer), NULL)) > 0) { struct linux_dirent64 *entry; diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2e5ca8d95c02b9..add8379667b7b2 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -18,6 +18,8 @@ # include #endif +#include "/home/x/c/cosmopolitan/libc/thread/pthread_kill.c" + #ifdef __VXWORKS__ # include "pycore_bitutils.h" // _Py_popcount32() #endif @@ -226,7 +228,27 @@ corresponding Unix manual entries for more information on calls."); #endif #ifdef HAVE_SYSEXITS_H -# include +#define EX_OK0/* successful termination */ + +#define EX__BASE64/* base value for error messages */ + +#define EX_USAGE64/* command line usage error */ +#define EX_DATAERR65/* data format error */ +#define EX_NOINPUT66/* cannot open input */ +#define EX_NOUSER67/* addressee unknown */ +#define EX_NOHOST68/* host name unknown */ +#define EX_UNAVAILABLE69/* service unavailable */ +#define EX_SOFTWARE70/* internal software error */ +#define EX_OSERR71/* system error (e.g., can't fork) */ +#define EX_OSFILE72/* critical OS file missing */ +#define EX_CANTCREAT73/* can't create (user) output file */ +#define EX_IOERR74/* input/output error */ +#define EX_TEMPFAIL75/* temp failure; user is invited to retry */ +#define EX_PROTOCOL76/* remote error in protocol */ +#define EX_NOPERM77/* permission denied */ +#define EX_CONFIG78/* configuration error */ + +#define EX__MAX78/* maximum listed value */ #endif #ifdef HAVE_SYS_LOADAVG_H @@ -354,8 +376,9 @@ extern char *ctermid_r(char *); #endif /* __VXWORKS__ */ #ifdef HAVE_POSIX_SPAWN -# include "libc/stdio/spawna.internal.h" // need cosmo repo! -# include "libc/stdio/spawn.h" // need cosmo repo! +# include "libc/stdio/posix_spawn.h" +# include "libc/stdio/posix_spawn.internal.h" + #endif #include "libc/calls/struct/iovec.h" // need cosmo repo! diff --git a/README.md b/README.md index 98ed4468c34285..77cf121c112b6b 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,16 @@ compile with [Cosmopolitan][cosmo] libc. **Meant for experimental purposes only**. # Steps to compile +0. Install dependencies +``` +git +zip +unzip +gcc 11 +gnumake +bintools (for ar) +pkg-config +``` 1. clone the cosmopolitan repo somewhere nearby (for headers) diff --git a/superconfigure b/superconfigure index de51589ddfa2c5..d6bd45e72202f4 100755 --- a/superconfigure +++ b/superconfigure @@ -1,8 +1,8 @@ #! /bin/sh set -eux -COSMO_LIBDIR=$(realpath "../libcosmo/") -COSMO_REPODIR=$(realpath "../libcosmo/testing/cosmopolitan") +COSMO_LIBDIR=$(realpath "../amalg/") +COSMO_REPODIR=$(realpath "../cosmopolitan/") EXTRA_STUBS=$(realpath "./header_stubs") CC="./gcc-wrapper.bash" From e8478a0f6312e281408245c61d90a836cfa25376 Mon Sep 17 00:00:00 2001 From: Ariel Nunez <54999+ingenieroariel@users.noreply.github.com> Date: Sun, 6 Nov 2022 13:23:50 -0500 Subject: [PATCH 2/2] Avoid hardcoded import --- Modules/posixmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index add8379667b7b2..9b718ff5e545ed 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -18,7 +18,7 @@ # include #endif -#include "/home/x/c/cosmopolitan/libc/thread/pthread_kill.c" +#include "libc/thread/pthread_kill.c" #ifdef __VXWORKS__ # include "pycore_bitutils.h" // _Py_popcount32()