|
14 | 14 | //===----------------------------------------------------------------------===//
|
15 | 15 |
|
16 | 16 | #include "sanitizer_platform.h"
|
| 17 | +#include "sanitizer_platform_limits_posix.h" |
17 | 18 | #include "sanitizer_common.h"
|
18 | 19 | #include "sanitizer_stoptheworld.h"
|
19 | 20 |
|
| 21 | +#include <fcntl.h> |
20 | 22 | #include <signal.h>
|
21 | 23 | #include <time.h>
|
| 24 | +#include <unistd.h> |
| 25 | +#include <math.h> |
22 | 26 |
|
23 | 27 | #if SANITIZER_EMSCRIPTEN
|
24 | 28 |
|
| 29 | +#include <sys/stat.h> |
| 30 | +#include <sys/types.h> |
| 31 | + |
25 | 32 | #include <emscripten.h>
|
26 | 33 | #include <emscripten/stack.h>
|
27 |
| -#include <sys/types.h> |
28 | 34 |
|
29 | 35 | #include "emscripten_internal.h"
|
30 | 36 |
|
@@ -128,6 +134,82 @@ u64 MonotonicNanoTime() {
|
128 | 134 |
|
129 | 135 | void GetMemoryProfile(fill_profile_f cb, uptr *stats) {}
|
130 | 136 |
|
| 137 | +int internal_madvise(uptr addr, uptr length, int advice) { |
| 138 | + return 0; // madvise is currently ignored |
| 139 | +} |
| 140 | + |
| 141 | +uptr internal_close(fd_t fd) { |
| 142 | + return close(fd); |
| 143 | +} |
| 144 | + |
| 145 | +uptr internal_open(const char *filename, int flags) { |
| 146 | + return open(filename, flags); |
| 147 | +} |
| 148 | + |
| 149 | +uptr internal_open(const char *filename, int flags, u32 mode) { |
| 150 | + return open(filename, flags, mode); |
| 151 | +} |
| 152 | + |
| 153 | +uptr internal_read(fd_t fd, void *buf, uptr count) { |
| 154 | + return read(fd, buf, count); |
| 155 | +} |
| 156 | + |
| 157 | +uptr internal_write(fd_t fd, const void *buf, uptr count) { |
| 158 | + return write(fd, buf, count); |
| 159 | +} |
| 160 | + |
| 161 | +uptr internal_stat(const char *path, void *buf) { |
| 162 | + return stat(path, (struct stat *)buf); |
| 163 | +} |
| 164 | + |
| 165 | +uptr internal_fstat(fd_t fd, void *buf) { |
| 166 | + return fstat(fd, (struct stat *)buf); |
| 167 | +} |
| 168 | + |
| 169 | +uptr internal_filesize(fd_t fd) { |
| 170 | + struct stat st; |
| 171 | + if (internal_fstat(fd, &st)) |
| 172 | + return -1; |
| 173 | + return (uptr)st.st_size; |
| 174 | +} |
| 175 | + |
| 176 | +uptr internal_dup(int oldfd) { |
| 177 | + return dup(oldfd); |
| 178 | +} |
| 179 | + |
| 180 | +uptr internal_getpid() { |
| 181 | + return 42; |
| 182 | +} |
| 183 | + |
| 184 | +uptr internal_sched_yield() { |
| 185 | + return sched_yield(); |
| 186 | +} |
| 187 | + |
| 188 | +void internal_sigfillset(__sanitizer_sigset_t *set) { |
| 189 | + sigfillset(set); |
| 190 | +} |
| 191 | + |
| 192 | +uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set, |
| 193 | + __sanitizer_sigset_t *oldset) { |
| 194 | + return sigprocmask(how, set, oldset); |
| 195 | +} |
| 196 | + |
| 197 | +void internal_usleep(u64 useconds) { |
| 198 | + usleep(useconds); |
| 199 | +} |
| 200 | + |
| 201 | +void internal__exit(int exitcode) { |
| 202 | + _exit(exitcode); |
| 203 | +} |
| 204 | + |
| 205 | +tid_t GetTid() { |
| 206 | + return gettid(); |
| 207 | +} |
| 208 | + |
| 209 | +uptr internal_clock_gettime(__sanitizer_clockid_t clk_id, void *tp) { |
| 210 | + return clock_gettime(clk_id, (struct timespec *)tp); |
| 211 | +} |
| 212 | + |
131 | 213 | } // namespace __sanitizer
|
132 | 214 |
|
133 | 215 | #endif
|
0 commit comments