Skip to content
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
1 change: 0 additions & 1 deletion arch/emscripten/bits/endian.h

This file was deleted.

15 changes: 1 addition & 14 deletions arch/emscripten/bits/fenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,7 @@
typedef unsigned short fexcept_t;

typedef struct {
unsigned short __control_word;
unsigned short __unused1;
unsigned short __status_word;
unsigned short __unused2;
unsigned short __tags;
unsigned short __unused3;
unsigned int __eip;
unsigned short __cs_selector;
unsigned int __opcode:11;
unsigned int __unused4:5;
unsigned int __data_offset;
unsigned short __data_selector;
unsigned short __unused5;
unsigned int __mxcsr;
unsigned __cw;
} fenv_t;

#define FE_DFL_ENV ((const fenv_t *) -1)
2 changes: 1 addition & 1 deletion arch/emscripten/bits/limits.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define PAGE_SIZE 65536
#define PAGESIZE 65536
4 changes: 4 additions & 0 deletions arch/emscripten/bits/mman.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// XXX Emscripten in sync with both:
// - musl/arch/x86_64/bits/mman.h
// - musl/arch/i386/bits/mman.h
#define MAP_32BIT 0x40
2 changes: 0 additions & 2 deletions arch/emscripten/bits/posix.h

This file was deleted.

6 changes: 0 additions & 6 deletions arch/emscripten/bits/reg.h

This file was deleted.

1 change: 1 addition & 0 deletions arch/emscripten/bits/setjmp.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// XXX Emscripten in sync with musl/arch/i386/bits/setjmp.h
typedef unsigned long __jmp_buf[6];
70 changes: 45 additions & 25 deletions arch/emscripten/bits/signal.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// XXX Emscripten in sync with musl/arch/i386/bits/signal.h
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)

Expand All @@ -7,33 +8,46 @@
#endif

#ifdef _GNU_SOURCE
#define REG_GS 0
#define REG_FS 1
#define REG_ES 2
#define REG_DS 3
#define REG_EDI 4
#define REG_ESI 5
#define REG_EBP 6
#define REG_ESP 7
#define REG_EBX 8
#define REG_EDX 9
#define REG_ECX 10
#define REG_EAX 11
#define REG_TRAPNO 12
#define REG_ERR 13
#define REG_EIP 14
#define REG_CS 15
#define REG_EFL 16
#define REG_UESP 17
#define REG_SS 18
enum { REG_GS = 0 };
#define REG_GS REG_GS
enum { REG_FS = 1 };
#define REG_FS REG_FS
enum { REG_ES = 2 };
#define REG_ES REG_ES
enum { REG_DS = 3 };
#define REG_DS REG_DS
enum { REG_EDI = 4 };
#define REG_EDI REG_EDI
enum { REG_ESI = 5 };
#define REG_ESI REG_ESI
enum { REG_EBP = 6 };
#define REG_EBP REG_EBP
enum { REG_ESP = 7 };
#define REG_ESP REG_ESP
enum { REG_EBX = 8 };
#define REG_EBX REG_EBX
enum { REG_EDX = 9 };
#define REG_EDX REG_EDX
enum { REG_ECX = 10 };
#define REG_ECX REG_ECX
enum { REG_EAX = 11 };
#define REG_EAX REG_EAX
enum { REG_TRAPNO = 12 };
#define REG_TRAPNO REG_TRAPNO
enum { REG_ERR = 13 };
#define REG_ERR REG_ERR
enum { REG_EIP = 14 };
#define REG_EIP REG_EIP
enum { REG_CS = 15 };
#define REG_CS REG_CS
enum { REG_EFL = 16 };
#define REG_EFL REG_EFL
enum { REG_UESP = 17 };
#define REG_UESP REG_UESP
enum { REG_SS = 18 };
#define REG_SS REG_SS
#endif

struct sigaltstack {
void *ss_sp;
int ss_flags;
size_t ss_size;
};

#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
typedef int greg_t, gregset_t[19];
typedef struct _fpstate {
Expand Down Expand Up @@ -64,6 +78,12 @@ typedef struct {
} mcontext_t;
#endif

struct sigaltstack {
void *ss_sp;
int ss_flags;
size_t ss_size;
};

typedef struct __ucontext {
unsigned long uc_flags;
struct __ucontext *uc_link;
Expand Down
13 changes: 10 additions & 3 deletions arch/emscripten/bits/stat.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// XXX Emscripten in sync with musl/arch/i386/bits/stat.h except for the padding,
// 64-bit time_t redirections change and st_ino placement.

/* copied from kernel definition, but with padding replaced
* by the corresponding correctly-sized userspace types. */

struct stat
{
struct stat {
dev_t st_dev;
#ifndef __EMSCRIPTEN__
int __st_dev_padding;
Expand All @@ -19,6 +20,12 @@ struct stat
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
#ifndef __EMSCRIPTEN__ // XXX Emscripten no need to activate the symbol redirections for 64-bit time_t.
struct {
long tv_sec;
long tv_nsec;
} __st_atim32, __st_mtim32, __st_ctim32;
#endif
struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
Expand Down
33 changes: 0 additions & 33 deletions arch/emscripten/bits/stdint.h

This file was deleted.

48 changes: 0 additions & 48 deletions arch/emscripten/bits/user.h
Original file line number Diff line number Diff line change
@@ -1,48 +0,0 @@
#undef __WORDSIZE
#define __WORDSIZE 32

typedef struct user_fpregs_struct
{
long cwd, swd, twd, fip, fcs, foo, fos, st_space[20];
} elf_fpregset_t;

typedef struct user_fpxregs_struct
{
unsigned short cwd, swd, twd, fop;
long fip, fcs, foo, fos, mxcsr, reserved;
long st_space[32], xmm_space[32], padding[56];
} elf_fpxregset_t;

struct user_regs_struct
{
long ebx, ecx, edx, esi, edi, ebp, eax, xds, xes, xfs, xgs;
long orig_eax, eip, xcs, eflags, esp, xss;
};

#define ELF_NGREG 17
typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];

struct user
{
struct user_regs_struct regs;
int u_fpvalid;
struct user_fpregs_struct i387;
unsigned long u_tsize;
unsigned long u_dsize;
unsigned long u_ssize;
unsigned long start_code;
unsigned long start_stack;
long signal;
int reserved;
struct user_regs_struct *u_ar0;
struct user_fpregs_struct *u_fpstate;
unsigned long magic;
char u_comm[32];
int u_debugreg[8];
};

#define PAGE_MASK (~(PAGE_SIZE-1))
#define NBPG PAGE_SIZE
#define UPAGES 1
#define HOST_TEXT_START_ADDR (u.start_code)
#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
6 changes: 5 additions & 1 deletion src/internal/pthread_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ struct pthread {
long off;
volatile void *volatile pending;
} robust_list;
#ifndef __EMSCRIPTEN__
// Emscripten uses C11 _Thread_local instead for h_errno
int h_errno_val;
#endif
volatile int timer_id;
#ifndef __EMSCRIPTEN__
// Emscripten uses C11 _Thread_local instead for locale
locale_t locale;
#endif
// Emscripten doesn't use this field.
volatile int killlock[1];
#endif
char *dlerror_buf;
void *stdio_locks;

Expand Down
10 changes: 0 additions & 10 deletions src/internal/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,9 @@
typedef long syscall_arg_t;
#endif

#ifdef __cplusplus
extern "C" {
#endif
hidden long __syscall_ret(unsigned long),
__syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t);
#ifdef __cplusplus
}
#endif

#ifndef __EMSCRIPTEN__
#define __syscall1(n,a) __syscall1(n,__scc(a))
Expand Down Expand Up @@ -456,11 +450,7 @@ hidden long __emulate_wait4(int, int *, int, void *, int);
#define sys_wait4(a,b,c,d) __syscall_ret(__sys_wait4(a,b,c,d))
#define sys_wait4_cp(a,b,c,d) __syscall_ret(__sys_wait4_cp(a,b,c,d))

#ifdef __cplusplus
hidden void __procfdname(char __buf[], unsigned);
#else
hidden void __procfdname(char __buf[static 15+3*sizeof(int)], unsigned);
#endif

hidden void *__vdsosym(const char *, const char *);

Expand Down
8 changes: 8 additions & 0 deletions src/network/h_errno.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
#undef h_errno
int h_errno;

#ifdef __EMSCRIPTEN__
static _Thread_local int __h_errno_storage;
#endif

int *__h_errno_location(void)
{
#ifdef __EMSCRIPTEN__
return &__h_errno_storage;
#else
if (!__pthread_self()->stack) return &h_errno;
return &__pthread_self()->h_errno_val;
#endif
}
6 changes: 2 additions & 4 deletions src/thread/__timedwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
#include <time.h>
#include <errno.h>
#ifdef __EMSCRIPTEN__
#include <math.h>
#include <emscripten/threading.h>
#include <emscripten/emscripten.h>
#include <math.h> // for INFINITY
#else
#include "futex.h"
#endif
#include "syscall.h"
#endif
#include "pthread_impl.h"

#ifndef __EMSCRIPTEN__
Expand Down
3 changes: 1 addition & 2 deletions src/thread/__wait.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifdef __EMSCRIPTEN__
#include <math.h>
#include <emscripten/threading.h>
#include <math.h> // for INFINITY
#endif

#include "pthread_impl.h"
Expand Down
4 changes: 2 additions & 2 deletions src/thread/pthread_barrier_wait.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifdef __EMSCRIPTEN__
#include <assert.h> // For INFINITY
#include <math.h> // For INFINITY
#include <assert.h> // for assert
#include <math.h> // for INFINITY
#endif

#include "pthread_impl.h"
Expand Down
3 changes: 2 additions & 1 deletion src/thread/pthread_detach.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ static int __pthread_detach(pthread_t t)

weak_alias(__pthread_detach, pthread_detach);
weak_alias(__pthread_detach, thrd_detach);
// XXX EMSCRIPTEN: add extra alias for asan.
#ifdef __EMSCRIPTEN__ // XXX Emscripten add an extra alias for ASan/LSan.
weak_alias(__pthread_detach, emscripten_builtin_pthread_detach);
#endif
4 changes: 0 additions & 4 deletions src/thread/pthread_key_create.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "pthread_impl.h"
#include "fork_impl.h"

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif

volatile size_t __pthread_tsd_size = sizeof(void *) * PTHREAD_KEYS_MAX;
void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 };

Expand Down
2 changes: 0 additions & 2 deletions src/thread/thrd_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
// if we call the internal __pthread_create function here to don't the wrapping
// See pthread_create wrapper in compiler-rt/lib/lsan/lsan_interceptors.cpp.
#define __pthread_create pthread_create
#else
int __pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict);
#endif

int thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
Expand Down
3 changes: 0 additions & 3 deletions src/unistd/isatty.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#ifdef __EMSCRIPTEN__
#include <errno.h>
#endif
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
Expand Down