Skip to content
Open
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
5 changes: 4 additions & 1 deletion Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
29 changes: 26 additions & 3 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# include <pathcch.h>
#endif

#include "libc/thread/pthread_kill.c"

#ifdef __VXWORKS__
# include "pycore_bitutils.h" // _Py_popcount32()
#endif
Expand Down Expand Up @@ -226,7 +228,27 @@ corresponding Unix manual entries for more information on calls.");
#endif

#ifdef HAVE_SYSEXITS_H
# include <sysexits.h>
#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
Expand Down Expand Up @@ -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!

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions superconfigure
Original file line number Diff line number Diff line change
@@ -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"

Expand Down