Ruby 3.5.0dev (2025-02-22 revision d6f44535c6482e895483c0c28c9a35bcf5e4fd88)
missing.c
1#include <errno.h>
2#include <sys/types.h>
3#include "ruby/missing.h"
4
5// Produce weak symbols for missing functions to replace them with actual ones if exists.
6#define WASM_MISSING_LIBC_FUNC __attribute__((weak))
7
8WASM_MISSING_LIBC_FUNC
9int
10chmod(const char *pathname, rb_mode_t mode)
11{
12 errno = ENOTSUP;
13 return -1;
14}
15
16WASM_MISSING_LIBC_FUNC
17int
18chown(const char *pathname, rb_uid_t owner, rb_gid_t group)
19{
20 errno = ENOTSUP;
21 return -1;
22}
23
24WASM_MISSING_LIBC_FUNC
25int
26dup(int oldfd)
27{
28 errno = ENOTSUP;
29 return -1;
30}
31
32WASM_MISSING_LIBC_FUNC
33int
34dup2(int oldfd, int newfd)
35{
36 errno = ENOTSUP;
37 return -1;
38}
39
40WASM_MISSING_LIBC_FUNC
41int
42execl(const char *path, const char *arg, ...)
43{
44 errno = ENOTSUP;
45 return -1;
46}
47
48WASM_MISSING_LIBC_FUNC
49int
50execle(const char *path, const char *arg, ...)
51{
52 errno = ENOTSUP;
53 return -1;
54}
55
56WASM_MISSING_LIBC_FUNC
57int
58execv(const char *path, char *const argv[])
59{
60 errno = ENOTSUP;
61 return -1;
62}
63
64WASM_MISSING_LIBC_FUNC
65int
66execve(const char *filename, char *const argv[], char *const envp[])
67{
68 errno = ENOTSUP;
69 return -1;
70}
71
72WASM_MISSING_LIBC_FUNC
73rb_uid_t
74geteuid(void)
75{
76 return 0;
77}
78
79WASM_MISSING_LIBC_FUNC
80rb_uid_t
81getuid(void)
82{
83 return 0;
84}
85
86WASM_MISSING_LIBC_FUNC
87rb_pid_t
88getppid(void)
89{
90 return 0;
91}
92
93WASM_MISSING_LIBC_FUNC
94rb_gid_t
95getegid(void)
96{
97 return 0;
98}
99
100WASM_MISSING_LIBC_FUNC
101rb_gid_t
102getgid(void)
103{
104 return 0;
105}
106
107WASM_MISSING_LIBC_FUNC
108char *
109getlogin(void)
110{
111 errno = ENOTSUP;
112 return NULL;
113}
114
115WASM_MISSING_LIBC_FUNC
116rb_mode_t
117umask(rb_mode_t mask)
118{
119 return 0;
120}
121
122WASM_MISSING_LIBC_FUNC
123int
124pclose(FILE *stream)
125{
126 errno = ENOTSUP;
127 return -1;
128}
129
130WASM_MISSING_LIBC_FUNC
131FILE *
132popen(const char *command, const char *type)
133{
134 errno = ENOTSUP;
135 return NULL;
136}
137
138WASM_MISSING_LIBC_FUNC
139int
140pipe(int pipefd[2])
141{
142 errno = ENOTSUP;
143 return -1;
144}
145
146WASM_MISSING_LIBC_FUNC
147int
148posix_madvise(void *addr, size_t len, int advice)
149{
150 errno = ENOTSUP;
151 return -1;
152}
153
154WASM_MISSING_LIBC_FUNC
155int
156kill(rb_pid_t pid, int sig)
157{
158 errno = ENOTSUP;
159 return -1;
160}
161
162
163WASM_MISSING_LIBC_FUNC
164void
165tzset(void)
166{
167 return;
168}
169
170WASM_MISSING_LIBC_FUNC
171int
172shutdown(int s, int how)
173{
174 errno = ENOTSUP;
175 return -1;
176}
177
178WASM_MISSING_LIBC_FUNC
179int
180system(const char *command)
181{
182 errno = ENOTSUP;
183 return -1;
184}
185
186WASM_MISSING_LIBC_FUNC
187pid_t
188waitpid(pid_t pid, int *wstatus, int options)
189{
190 errno = ENOTSUP;
191 return -1;
192}
int len
Length of the buffer.
Definition io.h:8
#define errno
Ractor-aware version of errno.
Definition ruby.h:388