Commit 711d605d authored by jan.koester's avatar jan.koester
Browse files

Names musl and glibc programs import: timers, _Fork, mincore, ...

Found running the musl build of Claude Code on systempp (its interpreter
and libc name pointed at systempp): 14 functions were missing.

- timer_create/settime/gettime/getoverrun/delete (timer_t holds the
  kernel id; SIGEV_SIGNAL and SIGEV_NONE, SIGEV_THREAD gives ENOTSUP)
- _Fork (fork without the pthread_atfork handlers; the allocator's own
  hooks still run), mincore, process_vm_readv/writev,
  tcgetwinsize/tcsetwinsize (POSIX.1-2024)
- exported htonl/htons/ntohl/ntohs (inline in <arpa/inet.h>),
  __ctype_get_mb_cur_max (MB_CUR_MAX in glibc/musl), getdents (musl:
  getdents64 records, no prototype here), pidfd_getpid (glibc 2.39)

e2e_foreign_abi tests them all.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 2f35ddb8
Loading
Loading
Loading
Loading
+2 −0
Changes for include/sys/mman.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -133,6 +133,8 @@ void *mremap (void *old_address, size_t old_size, size_t new_size, int flags, ..
int msync (void *addr, size_t length, int flags);
int madvise (void *addr, size_t length, int advice);
int posix_madvise (void *addr, size_t length, int advice);
/* which pages of a mapping are in memory: one byte per page, bit 0 set when resident */
int mincore (void *addr, size_t length, unsigned char *vec);
int mlock (const void *addr, size_t len);
int mlock2 (const void *addr, size_t len, unsigned int flags);
int munlock (const void *addr, size_t len);
+5 −0
Changes for include/sys/uio.h: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@ ssize_t pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset);
#define RWF_APPEND 0x10
ssize_t preadv2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags);
ssize_t pwritev2(int fd, const struct iovec* iov, int iovcnt, off_t offset, int flags);
/* another process's memory (debuggers, Bun's crash handler) */
ssize_t process_vm_readv(pid_t pid, const struct iovec* local_iov, unsigned long liovcnt,
                         const struct iovec* remote_iov, unsigned long riovcnt, unsigned long flags);
ssize_t process_vm_writev(pid_t pid, const struct iovec* local_iov, unsigned long liovcnt,
                          const struct iovec* remote_iov, unsigned long riovcnt, unsigned long flags);

#ifdef __cplusplus
}
+5 −0
Changes for include/termios.h: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -78,6 +78,11 @@ extern "C" {
    pid_t tcgetpgrp(int fd);
    int tcsetpgrp(int fd, pid_t pgrp);

    /* POSIX.1-2024: the terminal's size (TIOCGWINSZ/TIOCSWINSZ) */
    struct winsize;
    int tcgetwinsize(int fd, struct winsize* ws);
    int tcsetwinsize(int fd, const struct winsize* ws);

#ifdef __cplusplus
};
#endif
+13 −0
Changes for include/time.h: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -115,6 +115,19 @@ extern "C" {
#define TIMER_ABSTIME 1
    int clock_nanosleep(int clk_id, int flags, const struct timespec* req, struct timespec* rem);

    /* POSIX per-process timers (timer_create(2)): the kernel's timer id in a
     * pointer-sized timer_t, as musl and glibc keep it. Notification by
     * signal (SIGEV_SIGNAL) or none (SIGEV_NONE); SIGEV_THREAD is not
     * supported (ENOTSUP). Real users: Bun (Claude Code), Node, CPython. */
    typedef void* timer_t;
    struct sigevent;
    int timer_create(clockid_t clockid, struct sigevent* sevp, timer_t* timerid);
    int timer_delete(timer_t timerid);
    int timer_settime(timer_t timerid, int flags, const struct itimerspec* new_value,
                      struct itimerspec* old_value);
    int timer_gettime(timer_t timerid, struct itimerspec* curr_value);
    int timer_getoverrun(timer_t timerid);

    time_t time(time_t* tloc);
    double difftime(time_t end, time_t start);
    clock_t clock(void);
+2 −0
Changes for include/unistd.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -221,6 +221,8 @@ extern "C" {
    long fpathconf(int fd, int name);
    int ttyname_r(int fd, char* buf, size_t len);
    pid_t fork(void);
    /* fork() without the pthread_atfork() handlers (POSIX.1-2024, glibc 2.34, musl) */
    pid_t _Fork(void);

    int close(int fd);
    
Loading