Skip to content

Commit 5dcf1fa

Browse files
committed
feat: weakly define forwarded syscalls
1 parent 356e67a commit 5dcf1fa

File tree

8 files changed

+308
-60
lines changed

8 files changed

+308
-60
lines changed

newlib/libc/sys/hermit/fcntl.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#include <errno.h>
22
#include <fcntl.h>
33
#include <stdarg.h>
4+
#include <stdio.h>
45
#include <sys/stat.h>
56

6-
int sys_fcntl(int fildes, int cmd, int arg);
7+
__attribute__((weak)) int sys_fcntl(int fildes, int cmd, int arg) {
8+
fprintf(stderr, "weak sys_fcntl() called. Symbol was not replaced!\n");
9+
errno = ENOSYS;
10+
return -1;
11+
}
712

813
int fcntl(int fildes, int cmd, ...) {
914
int arg = 0;
@@ -28,7 +33,11 @@ int fcntl(int fildes, int cmd, ...) {
2833
return ret;
2934
}
3035

31-
int sys_open(const char *path, int oflag, mode_t mode);
36+
__attribute__((weak)) int sys_open(const char *path, int oflag, mode_t mode) {
37+
fprintf(stderr, "weak sys_open() called. Symbol was not replaced!\n");
38+
errno = ENOSYS;
39+
return -1;
40+
}
3241

3342
int open(const char *path, int oflag, ...) {
3443
mode_t mode = 0;

newlib/libc/sys/hermit/forward-in.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <dirent.h>
2+
#include <errno.h>
23
#include <fcntl.h>
34
#include <poll.h>
5+
#include <stdio.h>
46
#include <sys/mman.h>
57
#include <sys/socket.h>
68
#include <sys/stat.h>

0 commit comments

Comments
 (0)