Skip to content

Commit bc10c37

Browse files
committed
Deduplicate arch/emscripten/bits directory
And resync Emscripten specific headers with arch/i386/bits (if possible).
1 parent c7c77bf commit bc10c37

File tree

13 files changed

+75
-33
lines changed

13 files changed

+75
-33
lines changed

src/library_syscall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ var SyscallsLibrary = {
6666
{{{ makeSetValue('buf', C_STRUCTS.stat.st_size, 'stat.size', 'i64') }}};
6767
{{{ makeSetValue('buf', C_STRUCTS.stat.st_blksize, '4096', 'i32') }}};
6868
{{{ makeSetValue('buf', C_STRUCTS.stat.st_blocks, 'stat.blocks', 'i32') }}};
69+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ino, 'stat.ino', 'i64') }}};
6970
{{{ makeSetValue('buf', C_STRUCTS.stat.st_atim.tv_sec, '(stat.atime.getTime() / 1000)|0', 'i32') }}};
7071
{{{ makeSetValue('buf', C_STRUCTS.stat.st_atim.tv_nsec, '0', 'i32') }}};
7172
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mtim.tv_sec, '(stat.mtime.getTime() / 1000)|0', 'i32') }}};
7273
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mtim.tv_nsec, '0', 'i32') }}};
7374
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ctim.tv_sec, '(stat.ctime.getTime() / 1000)|0', 'i32') }}};
7475
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ctim.tv_nsec, '0', 'i32') }}};
75-
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ino, 'stat.ino', 'i64') }}};
7676
return 0;
7777
},
7878
doMsync: function(addr, stream, len, flags, offset) {

src/struct_info.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"st_size",
5656
"st_blksize",
5757
"st_blocks",
58+
"st_ino",
5859
{
5960
"st_atim": [
6061
"tv_sec",
@@ -72,8 +73,7 @@
7273
"tv_sec",
7374
"tv_nsec"
7475
]
75-
},
76-
"st_ino"
76+
}
7777
]
7878
}
7979
},

system/lib/libc/musl/arch/emscripten/bits/fenv.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
#define FE_ALL_EXCEPT 0
1+
// XXX Emscripten in sync with musl/arch/x86_64/bits/fenv.h expect for these defines:
2+
// #define FE_INVALID 1
3+
// #define __FE_DENORM 2
4+
// #define FE_DIVBYZERO 4
5+
// #define FE_OVERFLOW 8
6+
// #define FE_UNDERFLOW 16
7+
// #define FE_INEXACT 32
8+
//
9+
// #define FE_ALL_EXCEPT 63
10+
#define FE_ALL_EXCEPT 0 // XXX Emscripten in sync with musl/arch/generic/bits/fenv.h
11+
// TODO(kleisauke): Perhaps we should sync this with musl/arch/i386/bits/fenv.h instead?
212

313
#define FE_TONEAREST 0
414
#define FE_DOWNWARD 0x400
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// XXX Emscripten in sync with musl/arch/i386/bits/mman.h
2+
#define MAP_32BIT 0x40
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
// XXX Emscripten in sync with musl/arch/i386/bits/posix.h
12
#define _POSIX_V6_ILP32_OFFBIG 1
23
#define _POSIX_V7_ILP32_OFFBIG 1

system/lib/libc/musl/arch/emscripten/bits/reg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// XXX Emscripten in sync with musl/arch/i386/bits/reg.h
12
#undef __WORDSIZE
23
#define __WORDSIZE 32
34
#define EBX 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// XXX Emscripten in sync with musl/arch/i386/bits/setjmp.h
12
typedef unsigned long __jmp_buf[6];

system/lib/libc/musl/arch/emscripten/bits/signal.h

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// XXX Emscripten in sync with musl/arch/i386/bits/signal.h
12
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
23
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
34

@@ -7,25 +8,44 @@
78
#endif
89

910
#ifdef _GNU_SOURCE
10-
#define REG_GS 0
11-
#define REG_FS 1
12-
#define REG_ES 2
13-
#define REG_DS 3
14-
#define REG_EDI 4
15-
#define REG_ESI 5
16-
#define REG_EBP 6
17-
#define REG_ESP 7
18-
#define REG_EBX 8
19-
#define REG_EDX 9
20-
#define REG_ECX 10
21-
#define REG_EAX 11
22-
#define REG_TRAPNO 12
23-
#define REG_ERR 13
24-
#define REG_EIP 14
25-
#define REG_CS 15
26-
#define REG_EFL 16
27-
#define REG_UESP 17
28-
#define REG_SS 18
11+
enum { REG_GS = 0 };
12+
#define REG_GS REG_GS
13+
enum { REG_FS = 1 };
14+
#define REG_FS REG_FS
15+
enum { REG_ES = 2 };
16+
#define REG_ES REG_ES
17+
enum { REG_DS = 3 };
18+
#define REG_DS REG_DS
19+
enum { REG_EDI = 4 };
20+
#define REG_EDI REG_EDI
21+
enum { REG_ESI = 5 };
22+
#define REG_ESI REG_ESI
23+
enum { REG_EBP = 6 };
24+
#define REG_EBP REG_EBP
25+
enum { REG_ESP = 7 };
26+
#define REG_ESP REG_ESP
27+
enum { REG_EBX = 8 };
28+
#define REG_EBX REG_EBX
29+
enum { REG_EDX = 9 };
30+
#define REG_EDX REG_EDX
31+
enum { REG_ECX = 10 };
32+
#define REG_ECX REG_ECX
33+
enum { REG_EAX = 11 };
34+
#define REG_EAX REG_EAX
35+
enum { REG_TRAPNO = 12 };
36+
#define REG_TRAPNO REG_TRAPNO
37+
enum { REG_ERR = 13 };
38+
#define REG_ERR REG_ERR
39+
enum { REG_EIP = 14 };
40+
#define REG_EIP REG_EIP
41+
enum { REG_CS = 15 };
42+
#define REG_CS REG_CS
43+
enum { REG_EFL = 16 };
44+
#define REG_EFL REG_EFL
45+
enum { REG_UESP = 17 };
46+
#define REG_UESP REG_UESP
47+
enum { REG_SS = 18 };
48+
#define REG_SS REG_SS
2949
#endif
3050

3151
struct sigaltstack {

system/lib/libc/musl/arch/emscripten/bits/stat.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
// XXX Emscripten in sync with musl/arch/i386/bits/stat.h expect for the _REDIR_TIME64 change.
2+
13
/* copied from kernel definition, but with padding replaced
24
* by the corresponding correctly-sized userspace types. */
3-
4-
struct stat
5-
{
5+
struct stat {
66
dev_t st_dev;
77
int __st_dev_padding;
88
long __st_ino_truncated;
@@ -15,8 +15,14 @@ struct stat
1515
off_t st_size;
1616
blksize_t st_blksize;
1717
blkcnt_t st_blocks;
18+
#if _REDIR_TIME64 // XXX Emscripten no need to activate the symbol redirections for 64-bit time_t.
19+
struct {
20+
long tv_sec;
21+
long tv_nsec;
22+
} __st_atim32, __st_mtim32, __st_ctim32;
23+
#endif
24+
ino_t st_ino;
1825
struct timespec st_atim;
1926
struct timespec st_mtim;
2027
struct timespec st_ctim;
21-
ino_t st_ino;
2228
};

system/lib/libc/musl/arch/emscripten/bits/stdarg.h

Lines changed: 0 additions & 4 deletions
This file was deleted.

system/lib/libc/musl/arch/emscripten/bits/stdint.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// XXX Emscripten in sync with musl/arch/x86_64/bits/stdint.h
2+
// TODO(kleisauke): Perhaps we should sync this with musl/arch/i386/bits/stdint.h instead?
13
typedef int32_t int_fast16_t;
24
typedef int32_t int_fast32_t;
35
typedef uint32_t uint_fast16_t;

system/lib/libc/musl/arch/emscripten/bits/user.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// XXX Emscripten in sync with musl/arch/i386/bits/user.h
12
#undef __WORDSIZE
23
#define __WORDSIZE 32
34

@@ -41,8 +42,8 @@ struct user
4142
int u_debugreg[8];
4243
};
4344

44-
#define PAGE_MASK (~(PAGE_SIZE-1))
45-
#define NBPG PAGE_SIZE
45+
#define PAGE_MASK (~(PAGESIZE-1))
46+
#define NBPG PAGESIZE
4647
#define UPAGES 1
4748
#define HOST_TEXT_START_ADDR (u.start_code)
4849
#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)

system/lib/libc/musl/arch/emscripten/syscall_arch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ long __syscall_recvfrom(long sockfd, long level, long optname, long optval, long
128128
long __syscall_recvmsg(long sockfd, long level, long optname, long optval, long optlen, long dummy);
129129
long __syscall_shutdown(long sockfd, long level, long optname, long optval, long optlen, long dummy);
130130

131+
#define IPC_64 0
132+
131133
#ifdef __cplusplus
132134
}
133135
#endif

0 commit comments

Comments
 (0)