rustix/
not_implemented.rs

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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
//! Documentation about unimplemented functions.
//!
//! This module contains documentation for several functions that rustix does
//! not implement, either because they are out of scope, or because they are
//! could probably be implemented but are not yet.

macro_rules! not_implemented {
    ($func:ident) => {
        /// See the [module comment](self).
        pub fn $func() {
            unimplemented!()
        }
    };
}

/// Memory-allocation functions are out of scope for rustix.
///
/// It is possible to implement `malloc`, `free`, and similar functions in
/// Rust, however rustix itself is focused on syscall-like functions. This
/// module contains an incomplete list of such functions.
///
/// There are several allocator implementations for Rust; one of them is
/// [dlmalloc]. For a rustix-based implementation, see [rustix-dlmalloc].
/// Another allocator implementation is [talc].
///
/// [dlmalloc]: https://crates.io/crates/dlmalloc
/// [talc]: https://crates.io/crates/talc
/// [rustix-dlmalloc]: https://crates.io/crates/rustix-dlmalloc
pub mod memory_allocation {
    not_implemented!(malloc);
    not_implemented!(realloc);
    not_implemented!(calloc);
    not_implemented!(free);
    not_implemented!(posix_memalign);
    not_implemented!(aligned_alloc);
    not_implemented!(malloc_usable_size);
}

/// Functions which need access to libc internals are out of scope for rustix.
///
/// Most Rust programs have a libc present, and when a libc is present, it
/// expects to be the only thing in the process that can do certain operations.
/// For example, there can be only one `atexit` list in a process, only one
/// `pthread_atfork` list in a process, only one implementation of pthreads in
/// a process, and so on, and libc expects to own the one of each of those
/// things. And libc implementations may expect to be involved in signal
/// handling. So, these functions are believed to be out of scope for rustix.
/// This module contains an incomplete list of such functions.
///
/// It would be possible to make a rust library which provides safe or
/// ergonomic wrappers around these libc functions, however that is out of
/// scope for rustix itself.
///
/// If you would like to write a Rust program which does not use a libc, and
/// which does provide APIs for some of these functions, [Eyra] and [origin]
/// are two libraries which may be useful, and which provide public interfaces
/// for some of this functionality.
///
/// If you are otherwise writing Rust code which you know will not share a
/// process with a libc, perhaps because you are writing a libc or similar
/// yourself, rustix's codebase does include experimental implementations of
/// the primitives needed to implement most of these functions.
///
/// [Eyra]: https://github.com/sunfishcode/eyra?tab=readme-ov-file#eyra
/// [origin]: https://github.com/sunfishcode/origin?tab=readme-ov-file#origin
pub mod libc_internals {
    not_implemented!(exit);
    not_implemented!(fork);
    not_implemented!(clone);
    not_implemented!(clone3);
    not_implemented!(brk);
    not_implemented!(sigaction);
    not_implemented!(sigaltstack);
    not_implemented!(sigprocmask);
    not_implemented!(sigwait);
    not_implemented!(sigwaitinfo);
    not_implemented!(sigtimedwait);
    not_implemented!(set_thread_area);
    not_implemented!(set_tid_address);
    not_implemented!(tkill);
    not_implemented!(sched_setscheduler);
    not_implemented!(rseq);
    not_implemented!(setuid);
    not_implemented!(setgid);
    not_implemented!(seteuid);
    not_implemented!(setegid);
    not_implemented!(setreuid);
    not_implemented!(setregid);
    not_implemented!(setresuid);
    not_implemented!(setresgid);
    not_implemented!(setgroups);

    not_implemented!(pthread_atfork);
    not_implemented!(pthread_attr_destroy);
    not_implemented!(pthread_attr_getaffinity_np);
    not_implemented!(pthread_attr_getdetachstate);
    not_implemented!(pthread_attr_getguardsize);
    not_implemented!(pthread_attr_getinheritsched);
    not_implemented!(pthread_attr_getschedparam);
    not_implemented!(pthread_attr_getschedpolicy);
    not_implemented!(pthread_attr_getscope);
    not_implemented!(pthread_attr_getsigmask_np);
    not_implemented!(pthread_attr_getstack);
    not_implemented!(pthread_attr_getstackaddr);
    not_implemented!(pthread_attr_getstacksize);
    not_implemented!(pthread_attr_init);
    not_implemented!(pthread_attr_setaffinity_np);
    not_implemented!(pthread_attr_setdetachstate);
    not_implemented!(pthread_attr_setguardsize);
    not_implemented!(pthread_attr_setinheritsched);
    not_implemented!(pthread_attr_setschedparam);
    not_implemented!(pthread_attr_setschedpolicy);
    not_implemented!(pthread_attr_setscope);
    not_implemented!(pthread_attr_setsigmask_np);
    not_implemented!(pthread_attr_setstack);
    not_implemented!(pthread_attr_setstackaddr);
    not_implemented!(pthread_attr_setstacksize);
    not_implemented!(pthread_barrierattr_destroy);
    not_implemented!(pthread_barrierattr_getpshared);
    not_implemented!(pthread_barrierattr_init);
    not_implemented!(pthread_barrierattr_setpshared);
    not_implemented!(pthread_barrier_destroy);
    not_implemented!(pthread_barrier_wait);
    not_implemented!(pthread_cancel);
    not_implemented!(pthread_cleanup_pop);
    not_implemented!(pthread_cleanup_pop_restore_np);
    not_implemented!(pthread_cleanup_push);
    not_implemented!(pthread_cleanup_push_defer_np);
    not_implemented!(pthread_condattr_destroy);
    not_implemented!(pthread_condattr_getclock);
    not_implemented!(pthread_condattr_getpshared);
    not_implemented!(pthread_condattr_init);
    not_implemented!(pthread_condattr_setclock);
    not_implemented!(pthread_condattr_setpshared);
    not_implemented!(pthread_cond_broadcast);
    not_implemented!(pthread_cond_destroy);
    not_implemented!(pthread_cond_signal);
    not_implemented!(pthread_cond_timedwait);
    not_implemented!(pthread_create);
    not_implemented!(pthread_detach);
    not_implemented!(pthread_equal);
    not_implemented!(pthread_exit);
    not_implemented!(pthread_getaffinity_np);
    not_implemented!(pthread_getattr_default_np);
    not_implemented!(pthread_getattr_np);
    not_implemented!(pthread_getconcurrency);
    not_implemented!(pthread_getcpuclockid);
    not_implemented!(pthread_getname_np);
    not_implemented!(pthread_getschedparam);
    not_implemented!(pthread_getspecific);
    not_implemented!(pthread_join);
    not_implemented!(pthread_key_create);
    not_implemented!(pthread_key_delete);
    not_implemented!(pthread_kill);
    not_implemented!(pthread_kill_other_threads_np);
    not_implemented!(pthread_mutexattr_destroy);
    not_implemented!(pthread_mutexattr_getprioceiling);
    not_implemented!(pthread_mutexattr_getprotocol);
    not_implemented!(pthread_mutexattr_getpshared);
    not_implemented!(pthread_mutexattr_getrobust);
    not_implemented!(pthread_mutexattr_getrobust_np);
    not_implemented!(pthread_mutexattr_gettype);
    not_implemented!(pthread_mutexattr_init);
    not_implemented!(pthread_mutexattr_setprioceiling);
    not_implemented!(pthread_mutexattr_setprotocol);
    not_implemented!(pthread_mutexattr_setpshared);
    not_implemented!(pthread_mutexattr_setrobust);
    not_implemented!(pthread_mutexattr_setrobust_np);
    not_implemented!(pthread_mutexattr_settype);
    not_implemented!(pthread_mutex_consistent);
    not_implemented!(pthread_mutex_consistent_np);
    not_implemented!(pthread_mutex_destroy);
    not_implemented!(pthread_mutex_getprioceiling);
    not_implemented!(pthread_mutex_init);
    not_implemented!(pthread_mutex_lock);
    not_implemented!(pthread_mutex_setprioceiling);
    not_implemented!(pthread_mutex_timedlock);
    not_implemented!(pthread_mutex_trylock);
    not_implemented!(pthread_once);
    not_implemented!(pthread_rwlockattr_destroy);
    not_implemented!(pthread_rwlockattr_getkind_np);
    not_implemented!(pthread_rwlockattr_getpshared);
    not_implemented!(pthread_rwlockattr_init);
    not_implemented!(pthread_rwlockattr_setkind_np);
    not_implemented!(pthread_rwlockattr_setpshared);
    not_implemented!(pthread_rwlock_destroy);
    not_implemented!(pthread_rwlock_rdlock);
    not_implemented!(pthread_rwlock_timedrdlock);
    not_implemented!(pthread_rwlock_timedwrlock);
    not_implemented!(pthread_rwlock_tryrdlock);
    not_implemented!(pthread_rwlock_trywrlock);
    not_implemented!(pthread_rwlock_unlock);
    not_implemented!(pthread_rwlock_wrlock);
    not_implemented!(pthread_self);
    not_implemented!(pthread_setaffinity_np);
    not_implemented!(pthread_setattr_default_np);
    not_implemented!(pthread_setcancelstate);
    not_implemented!(pthread_setcanceltype);
    not_implemented!(pthread_setconcurrency);
    not_implemented!(pthread_setname_np);
    not_implemented!(pthread_setschedparam);
    not_implemented!(pthread_setschedprio);
    not_implemented!(pthread_setspecific);
    not_implemented!(pthread_sigmask);
    not_implemented!(pthread_sigqueue);
    not_implemented!(pthread_spin_destroy);
    not_implemented!(pthread_spin_init);
    not_implemented!(pthread_spin_lock);
    not_implemented!(pthread_spin_trylock);
    not_implemented!(pthread_spin_unlock);
    not_implemented!(pthread_testcancel);
    not_implemented!(pthread_timedjoin_np);
    not_implemented!(pthread_tryjoin_np);
    not_implemented!(pthread_yield);
}

/// Functions which provide higher-level functionality are out of scope for
/// rustix.
///
/// These functions are provided by typical libc implementations, but are
/// higher-level than the simple syscall-like functions that rustix focuses on.
/// They could be implemented as a separate library built on top of rustix,
/// rather than being part of rustix itself. This module contains an incomplete
/// list of such functions.
pub mod higher_level {
    not_implemented!(getpwent);
    not_implemented!(getpwuid);
    not_implemented!(getpwnam);
    not_implemented!(getpwuid_r);
    not_implemented!(getpwnam_r);
    not_implemented!(gethostbyname);
    not_implemented!(execv);
    not_implemented!(execvp);
    not_implemented!(execvpe);
    not_implemented!(wordexp);
    not_implemented!(localtime);
    not_implemented!(localtime_r);
    not_implemented!(gmtime);
    not_implemented!(gmtime_r);
    not_implemented!(ctime);
    not_implemented!(ctime_r);
    not_implemented!(asctime);
    not_implemented!(asctime_r);
    not_implemented!(mktime);
    not_implemented!(getifaddrs);

    /// See [rustix-openpty](https://crates.io/crates/rustix-openpty).
    pub fn closefrom() {
        unimplemented!()
    }
    /// See [rustix-openpty](https://crates.io/crates/rustix-openpty).
    pub fn login_tty() {
        unimplemented!()
    }
    /// See [rustix-openpty](https://crates.io/crates/rustix-openpty).
    pub fn openpty() {
        unimplemented!()
    }

    /// See [`std::io::IsTerminal`].
    ///
    /// For Rust < 1.70, see [is-terminal]. For a rustix-based implementation,
    /// see [rustix-is-terminal].
    ///
    /// [`std::io::IsTerminal`]: std::io::IsTerminal
    /// [is-terminal]: https://crates.io/crates/is-terminal
    /// [rustix-is-terminal]: https://crates.io/crates/rustix-is-terminal
    pub fn isatty() {
        unimplemented!()
    }
}

/// Functions which don't seem possible to even call from Rust with current
/// language features, even with `unsafe`.
pub mod impossible {
    not_implemented!(vfork);
    not_implemented!(sigreturn);
    not_implemented!(setjmp);
    not_implemented!(longjmp);
    not_implemented!(sigsetjmp);
    not_implemented!(siglongjmp);
}

/// These functions are not yet implemented in rustix, but probably could be.
///
/// These are functions that users have asked about, and which probably are in
/// scope for rustix, but are not yet implemented. This module contains an
/// incomplete list of such functions.
pub mod yet {
    not_implemented!(tgkill);
    not_implemented!(raise);
    not_implemented!(sysctl);
    not_implemented!(mq_open);
    not_implemented!(mq_send);
    not_implemented!(mq_unlink);
    not_implemented!(recvmmsg);
    not_implemented!(cachestat);
    not_implemented!(fanotify_init);
    not_implemented!(fanotify_mark);
    not_implemented!(getifaddrs);
    not_implemented!(signalfd);
    not_implemented!(pidfd_send_signal);
    not_implemented!(mount_setattr);
    not_implemented!(extattr_delete_fd);
    not_implemented!(extattr_delete_link);
    not_implemented!(extattr_get_fd);
    not_implemented!(extattr_get_link);
    not_implemented!(extattr_list_fd);
    not_implemented!(extattr_list_link);
    not_implemented!(extattr_set_fd);
    not_implemented!(extattr_set_link);
    not_implemented!(get_mempolicy);
    not_implemented!(mbind);
    not_implemented!(set_mempolicy);
    not_implemented!(migrate_pages);
    not_implemented!(move_pages);
    not_implemented!(fchmodat2);
    not_implemented!(shmat);
    not_implemented!(shmdt);
    not_implemented!(shmget);
    not_implemented!(shmctl);
}

/// These functions are not quite yet finished in rustix.
///
/// Rustix's codebase includes experimental implementations of these functions,
/// however they are not yet publicly exposed because their API might need more
/// work and/or they don't yet have a libc backend implementation yet.
///
/// See [#1314] for more information, and please leave comments if there are
/// specific functions you're interested in.
///
/// [#1314]: https://github.com/bytecodealliance/rustix/issues/1314
pub mod quite_yet {
    not_implemented!(_exit);
    not_implemented!(_Exit);
    not_implemented!(exit_group);
    not_implemented!(sigpending);
    not_implemented!(sigsuspend);
    not_implemented!(execveat);
    not_implemented!(execve);

    /// For now, use `rustix::process::uname().nodename()` instead.
    ///
    /// See also the [module comment](self).
    pub fn gethostname() {
        unimplemented!()
    }
}