forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary_signals.js
More file actions
165 lines (159 loc) · 4.01 KB
/
library_signals.js
File metadata and controls
165 lines (159 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// 'use strict'
var funs = {
_sigalrm_handler: 0,
signal__deps: ['_sigalrm_handler'],
signal: function(sig, func) {
if (sig == 14 /*SIGALRM*/) {
__sigalrm_handler = func;
} else {
#if ASSERTIONS
Module.printErr('Calling stub instead of signal()');
#endif
}
return 0;
},
sigemptyset: function(set) {
{{{ makeSetValue('set', '0', '0', 'i32') }}};
return 0;
},
sigfillset: function(set) {
{{{ makeSetValue('set', '0', '-1>>>0', 'i32') }}};
return 0;
},
sigaddset: function(set, signum) {
{{{ makeSetValue('set', '0', makeGetValue('set', '0', 'i32') + '| (1 << (signum-1))', 'i32') }}};
return 0;
},
sigdelset: function(set, signum) {
{{{ makeSetValue('set', '0', makeGetValue('set', '0', 'i32') + '& (~(1 << (signum-1)))', 'i32') }}};
return 0;
},
sigismember: function(set, signum) {
return {{{ makeGetValue('set', '0', 'i32') }}} & (1 << (signum-1));
},
sigaction: function(signum, act, oldact) {
//int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#if ASSERTIONS
Module.printErr('Calling stub instead of sigaction()');
#endif
return 0;
},
sigprocmask: function() {
#if ASSERTIONS
Module.printErr('Calling stub instead of sigprocmask()');
#endif
return 0;
},
__libc_current_sigrtmin: function() {
#if ASSERTIONS
Module.printErr('Calling stub instead of __libc_current_sigrtmin');
#endif
return 0;
},
__libc_current_sigrtmax: function() {
#if ASSERTIONS
Module.printErr('Calling stub instead of __libc_current_sigrtmax');
#endif
return 0;
},
kill__deps: ['$ERRNO_CODES', '__setErrNo'],
kill: function(pid, sig) {
// http://pubs.opengroup.org/onlinepubs/000095399/functions/kill.html
// Makes no sense in a single-process environment.
// Should kill itself somtimes depending on `pid`
#if ASSERTIONS
Module.printErr('Calling stub instead of kill()');
#endif
___setErrNo(ERRNO_CODES.EPERM);
return -1;
},
killpg__deps: ['$ERRNO_CODES', '__setErrNo'],
killpg: function() {
#if ASSERTIONS
Module.printErr('Calling stub instead of killpg()');
#endif
___setErrNo(ERRNO_CODES.EPERM);
return -1;
},
siginterrupt: function() {
#if ASSERTIONS
Module.printErr('Calling stub instead of siginterrupt()');
#endif
return 0;
},
raise__deps: ['$ERRNO_CODES', '__setErrNo'],
raise: function(sig) {
#if ASSERTIONS
Module.printErr('Calling stub instead of raise()');
#endif
___setErrNo(ERRNO_CODES.ENOSYS);
#if ASSERTIONS
Runtime.warnOnce('raise() returning an error as we do not support it');
#endif
return -1;
},
// http://pubs.opengroup.org/onlinepubs/000095399/functions/alarm.html
alarm__deps: ['_sigalrm_handler'],
alarm: function(seconds) {
setTimeout(function() {
if (__sigalrm_handler) Runtime.dynCall('vi', __sigalrm_handler, [0]);
}, seconds*1000);
},
ualarm: function() {
throw 'ualarm() is not implemented yet';
},
setitimer: function() {
throw 'setitimer() is not implemented yet';
},
getitimer: function() {
throw 'getitimer() is not implemented yet';
},
pause__deps: ['__setErrNo', '$ERRNO_CODES'],
pause: function() {
// int pause(void);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/pause.html
// We don't support signals, so we return immediately.
#if ASSERTIONS
Module.printErr('Calling stub instead of pause()');
#endif
___setErrNo(ERRNO_CODES.EINTR);
return -1;
},
sigpending: function(set) {
{{{ makeSetValue('set', 0, 0, 'i32') }}};
return 0;
}
//signalfd
//ppoll
//epoll_pwait
//pselect
//sigvec
//sigmask
//sigblock
//sigsetmask
//siggetmask
//sigsuspend
//bsd_signal
//siginterrupt
//sigqueue
//sysv_signal
//signal
//pthread_kill
//gsignal
//ssignal
//psignal
//psiginfo
//sigpause
//sigisemptyset
//sigtimedwait
//sigwaitinfo
//sigreturn
//sigstack
//sigaltstack(2)
//sigsetops(3),
//sighold
//sigrelse
//sigignore
//sigset
};
mergeInto(LibraryManager.library, funs);