Ruby: wasm/missing.c Source File

Ruby 3.4.9p82 (2026-03-11 revision 76cca827ab52ab1d346a728f068d5b8da3e2952b)

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
124mprotect(const void *addr, size_t len, int prot)
125{
126 return 0;
127}
128
129WASM_MISSING_LIBC_FUNC
130int
131pclose(FILE *stream)
132{
133 errno = ENOTSUP;
134 return -1;
135}
136
137WASM_MISSING_LIBC_FUNC
138FILE *
139popen(const char *command, const char *type)
140{
141 errno = ENOTSUP;
142 return NULL;
143}
144
145WASM_MISSING_LIBC_FUNC
146int
147pipe(int pipefd[2])
148{
149 errno = ENOTSUP;
150 return -1;
151}
152
153WASM_MISSING_LIBC_FUNC
154int
155posix_madvise(void *addr, size_t len, int advice)
156{
157 errno = ENOTSUP;
158 return -1;
159}
160
161WASM_MISSING_LIBC_FUNC
162int
163kill(rb_pid_t pid, int sig)
164{
165 errno = ENOTSUP;
166 return -1;
167}
168
169
170WASM_MISSING_LIBC_FUNC
171void
172tzset(void)
173{
174 return;
175}
176
177WASM_MISSING_LIBC_FUNC
178int
179shutdown(int s, int how)
180{
181 errno = ENOTSUP;
182 return -1;
183}
184
185WASM_MISSING_LIBC_FUNC
186int
187system(const char *command)
188{
189 errno = ENOTSUP;
190 return -1;
191}
192
193WASM_MISSING_LIBC_FUNC
194pid_t
195waitpid(pid_t pid, int *wstatus, int options)
196{
197 errno = ENOTSUP;
198 return -1;
199}
len
int len
Length of the buffer.
Definition io.h:8
errno
#define errno
Ractor-aware version of errno.
Definition ruby.h:388