rustix/
not_implemented.rs

1//! Documentation about unimplemented functions.
2//!
3//! This module contains documentation for several functions that rustix does
4//! not implement, either because they are out of scope, or because they are
5//! could probably be implemented but are not yet.
6
7macro_rules! not_implemented {
8    ($func:ident) => {
9        /// See the [module comment](self).
10        pub fn $func() {
11            unimplemented!()
12        }
13    };
14}
15
16/// Memory-allocation functions are out of scope for rustix.
17///
18/// It is possible to implement `malloc`, `free`, and similar functions in
19/// Rust, however rustix itself is focused on syscall-like functions. This
20/// module contains an incomplete list of such functions.
21///
22/// There are several allocator implementations for Rust; one of them is
23/// [dlmalloc]. For a rustix-based implementation, see [rustix-dlmalloc].
24/// Another allocator implementation is [talc].
25///
26/// [dlmalloc]: https://crates.io/crates/dlmalloc
27/// [talc]: https://crates.io/crates/talc
28/// [rustix-dlmalloc]: https://crates.io/crates/rustix-dlmalloc
29pub mod memory_allocation {
30    not_implemented!(malloc);
31    not_implemented!(realloc);
32    not_implemented!(calloc);
33    not_implemented!(free);
34    not_implemented!(posix_memalign);
35    not_implemented!(aligned_alloc);
36    not_implemented!(malloc_usable_size);
37}
38
39/// Functions which need access to libc internals are out of scope for rustix.
40///
41/// Most Rust programs have a libc present, and when a libc is present, it
42/// expects to be the only thing in the process that can do certain operations.
43/// For example, there can be only one `atexit` list in a process, only one
44/// `pthread_atfork` list in a process, only one implementation of pthreads in
45/// a process, and so on, and libc expects to own the one of each of those
46/// things. And libc implementations may expect to be involved in signal
47/// handling. So, these functions are believed to be out of scope for rustix.
48/// This module contains an incomplete list of such functions.
49///
50/// It would be possible to make a rust library which provides safe or
51/// ergonomic wrappers around these libc functions, however that is out of
52/// scope for rustix itself.
53///
54/// If you would like to write a Rust program which does not use a libc, and
55/// which does provide APIs for some of these functions, [Eyra] and [origin]
56/// are two libraries which may be useful, and which provide public interfaces
57/// for some of this functionality.
58///
59/// If you are otherwise writing Rust code which you know will not share a
60/// process with a libc, perhaps because you are writing a libc or similar
61/// yourself, rustix's codebase does include experimental implementations of
62/// the primitives needed to implement most of these functions.
63///
64/// [Eyra]: https://github.com/sunfishcode/eyra?tab=readme-ov-file#eyra
65/// [origin]: https://github.com/sunfishcode/origin?tab=readme-ov-file#origin
66pub mod libc_internals {
67    not_implemented!(exit);
68    not_implemented!(fork);
69    not_implemented!(brk);
70    not_implemented!(sigaction);
71    not_implemented!(sigaltstack);
72    not_implemented!(sigprocmask);
73    not_implemented!(sigwait);
74    not_implemented!(sigwaitinfo);
75    not_implemented!(sigtimedwait);
76    not_implemented!(set_thread_area);
77    not_implemented!(set_tid_address);
78    not_implemented!(tkill);
79    not_implemented!(sched_setscheduler);
80    not_implemented!(rseq);
81    not_implemented!(setuid);
82    not_implemented!(setgid);
83    not_implemented!(seteuid);
84    not_implemented!(setegid);
85    not_implemented!(setreuid);
86    not_implemented!(setregid);
87    not_implemented!(setresuid);
88    not_implemented!(setresgid);
89    not_implemented!(setgroups);
90
91    not_implemented!(pthread_atfork);
92    not_implemented!(pthread_attr_destroy);
93    not_implemented!(pthread_attr_getaffinity_np);
94    not_implemented!(pthread_attr_getdetachstate);
95    not_implemented!(pthread_attr_getguardsize);
96    not_implemented!(pthread_attr_getinheritsched);
97    not_implemented!(pthread_attr_getschedparam);
98    not_implemented!(pthread_attr_getschedpolicy);
99    not_implemented!(pthread_attr_getscope);
100    not_implemented!(pthread_attr_getsigmask_np);
101    not_implemented!(pthread_attr_getstack);
102    not_implemented!(pthread_attr_getstackaddr);
103    not_implemented!(pthread_attr_getstacksize);
104    not_implemented!(pthread_attr_init);
105    not_implemented!(pthread_attr_setaffinity_np);
106    not_implemented!(pthread_attr_setdetachstate);
107    not_implemented!(pthread_attr_setguardsize);
108    not_implemented!(pthread_attr_setinheritsched);
109    not_implemented!(pthread_attr_setschedparam);
110    not_implemented!(pthread_attr_setschedpolicy);
111    not_implemented!(pthread_attr_setscope);
112    not_implemented!(pthread_attr_setsigmask_np);
113    not_implemented!(pthread_attr_setstack);
114    not_implemented!(pthread_attr_setstackaddr);
115    not_implemented!(pthread_attr_setstacksize);
116    not_implemented!(pthread_barrierattr_destroy);
117    not_implemented!(pthread_barrierattr_getpshared);
118    not_implemented!(pthread_barrierattr_init);
119    not_implemented!(pthread_barrierattr_setpshared);
120    not_implemented!(pthread_barrier_destroy);
121    not_implemented!(pthread_barrier_wait);
122    not_implemented!(pthread_cancel);
123    not_implemented!(pthread_cleanup_pop);
124    not_implemented!(pthread_cleanup_pop_restore_np);
125    not_implemented!(pthread_cleanup_push);
126    not_implemented!(pthread_cleanup_push_defer_np);
127    not_implemented!(pthread_condattr_destroy);
128    not_implemented!(pthread_condattr_getclock);
129    not_implemented!(pthread_condattr_getpshared);
130    not_implemented!(pthread_condattr_init);
131    not_implemented!(pthread_condattr_setclock);
132    not_implemented!(pthread_condattr_setpshared);
133    not_implemented!(pthread_cond_broadcast);
134    not_implemented!(pthread_cond_destroy);
135    not_implemented!(pthread_cond_signal);
136    not_implemented!(pthread_cond_timedwait);
137    not_implemented!(pthread_create);
138    not_implemented!(pthread_detach);
139    not_implemented!(pthread_equal);
140    not_implemented!(pthread_exit);
141    not_implemented!(pthread_getaffinity_np);
142    not_implemented!(pthread_getattr_default_np);
143    not_implemented!(pthread_getattr_np);
144    not_implemented!(pthread_getconcurrency);
145    not_implemented!(pthread_getcpuclockid);
146    not_implemented!(pthread_getname_np);
147    not_implemented!(pthread_getschedparam);
148    not_implemented!(pthread_getspecific);
149    not_implemented!(pthread_join);
150    not_implemented!(pthread_key_create);
151    not_implemented!(pthread_key_delete);
152    not_implemented!(pthread_kill);
153    not_implemented!(pthread_kill_other_threads_np);
154    not_implemented!(pthread_mutexattr_destroy);
155    not_implemented!(pthread_mutexattr_getprioceiling);
156    not_implemented!(pthread_mutexattr_getprotocol);
157    not_implemented!(pthread_mutexattr_getpshared);
158    not_implemented!(pthread_mutexattr_getrobust);
159    not_implemented!(pthread_mutexattr_getrobust_np);
160    not_implemented!(pthread_mutexattr_gettype);
161    not_implemented!(pthread_mutexattr_init);
162    not_implemented!(pthread_mutexattr_setprioceiling);
163    not_implemented!(pthread_mutexattr_setprotocol);
164    not_implemented!(pthread_mutexattr_setpshared);
165    not_implemented!(pthread_mutexattr_setrobust);
166    not_implemented!(pthread_mutexattr_setrobust_np);
167    not_implemented!(pthread_mutexattr_settype);
168    not_implemented!(pthread_mutex_consistent);
169    not_implemented!(pthread_mutex_consistent_np);
170    not_implemented!(pthread_mutex_destroy);
171    not_implemented!(pthread_mutex_getprioceiling);
172    not_implemented!(pthread_mutex_init);
173    not_implemented!(pthread_mutex_lock);
174    not_implemented!(pthread_mutex_setprioceiling);
175    not_implemented!(pthread_mutex_timedlock);
176    not_implemented!(pthread_mutex_trylock);
177    not_implemented!(pthread_once);
178    not_implemented!(pthread_rwlockattr_destroy);
179    not_implemented!(pthread_rwlockattr_getkind_np);
180    not_implemented!(pthread_rwlockattr_getpshared);
181    not_implemented!(pthread_rwlockattr_init);
182    not_implemented!(pthread_rwlockattr_setkind_np);
183    not_implemented!(pthread_rwlockattr_setpshared);
184    not_implemented!(pthread_rwlock_destroy);
185    not_implemented!(pthread_rwlock_rdlock);
186    not_implemented!(pthread_rwlock_timedrdlock);
187    not_implemented!(pthread_rwlock_timedwrlock);
188    not_implemented!(pthread_rwlock_tryrdlock);
189    not_implemented!(pthread_rwlock_trywrlock);
190    not_implemented!(pthread_rwlock_unlock);
191    not_implemented!(pthread_rwlock_wrlock);
192    not_implemented!(pthread_self);
193    not_implemented!(pthread_setaffinity_np);
194    not_implemented!(pthread_setattr_default_np);
195    not_implemented!(pthread_setcancelstate);
196    not_implemented!(pthread_setcanceltype);
197    not_implemented!(pthread_setconcurrency);
198    not_implemented!(pthread_setname_np);
199    not_implemented!(pthread_setschedparam);
200    not_implemented!(pthread_setschedprio);
201    not_implemented!(pthread_setspecific);
202    not_implemented!(pthread_sigmask);
203    not_implemented!(pthread_sigqueue);
204    not_implemented!(pthread_spin_destroy);
205    not_implemented!(pthread_spin_init);
206    not_implemented!(pthread_spin_lock);
207    not_implemented!(pthread_spin_trylock);
208    not_implemented!(pthread_spin_unlock);
209    not_implemented!(pthread_testcancel);
210    not_implemented!(pthread_timedjoin_np);
211    not_implemented!(pthread_tryjoin_np);
212    not_implemented!(pthread_yield);
213}
214
215/// Functions which provide higher-level functionality are out of scope for
216/// rustix.
217///
218/// These functions are provided by typical libc implementations, but are
219/// higher-level than the simple syscall-like functions that rustix focuses on.
220/// They could be implemented as a separate library built on top of rustix,
221/// rather than being part of rustix itself. This module contains an incomplete
222/// list of such functions.
223pub mod higher_level {
224    not_implemented!(getpwent);
225    not_implemented!(getpwuid);
226    not_implemented!(getpwnam);
227    not_implemented!(getpwuid_r);
228    not_implemented!(getpwnam_r);
229    not_implemented!(gethostbyname);
230    not_implemented!(execv);
231    not_implemented!(execvp);
232    not_implemented!(execvpe);
233    not_implemented!(wordexp);
234
235    /// See [rustix-openpty](https://crates.io/crates/rustix-openpty).
236    pub fn closefrom() {
237        unimplemented!()
238    }
239    /// See [rustix-openpty](https://crates.io/crates/rustix-openpty).
240    pub fn login_tty() {
241        unimplemented!()
242    }
243    /// See [rustix-openpty](https://crates.io/crates/rustix-openpty).
244    pub fn openpty() {
245        unimplemented!()
246    }
247
248    /// See [`std::io::IsTerminal`].
249    ///
250    /// For Rust < 1.70, see [is-terminal]. For a rustix-based implementation,
251    /// see [rustix-is-terminal].
252    ///
253    /// [`std::io::IsTerminal`]: std::io::IsTerminal
254    /// [is-terminal]: https://crates.io/crates/is-terminal
255    /// [rustix-is-terminal]: https://crates.io/crates/rustix-is-terminal
256    pub fn isatty() {
257        unimplemented!()
258    }
259}
260
261/// These functions are not yet implemented in rustix, but probably could be.
262///
263/// These are functions that users have asked about, and which probably are in
264/// scope for rustix, but are not yet implemented. This module contains an
265/// incomplete list of such functions.
266pub mod yet {
267    not_implemented!(tgkill);
268    not_implemented!(raise);
269    not_implemented!(sysctl);
270    not_implemented!(mq_open);
271    not_implemented!(mq_send);
272    not_implemented!(mq_unlink);
273    not_implemented!(recvmmsg);
274    not_implemented!(cachestat);
275    not_implemented!(fanotify_init);
276    not_implemented!(fanotify_mark);
277    not_implemented!(getifaddrs);
278    not_implemented!(signalfd);
279    not_implemented!(pidfd_send_signal);
280    not_implemented!(mount_setattr);
281    not_implemented!(extattr_delete_fd);
282    not_implemented!(extattr_delete_link);
283    not_implemented!(extattr_get_fd);
284    not_implemented!(extattr_get_link);
285    not_implemented!(extattr_list_fd);
286    not_implemented!(extattr_list_link);
287    not_implemented!(extattr_set_fd);
288    not_implemented!(extattr_set_link);
289    not_implemented!(get_mempolicy);
290    not_implemented!(mbind);
291    not_implemented!(set_mempolicy);
292    not_implemented!(migrate_pages);
293    not_implemented!(move_pages);
294    not_implemented!(fchmodat2);
295    not_implemented!(shmat);
296    not_implemented!(shmdt);
297    not_implemented!(shmget);
298    not_implemented!(shmctl);
299}
300
301/// These functions are not quite yet finished in rustix.
302///
303/// Rustix's codebase includes experimental implementations of these functions,
304/// however they are not yet publicly exposed because their API might need more
305/// work and/or they don't yet have a libc backend implementation yet.
306///
307/// See [#1314] for more information, and please leave comments if there are
308/// specific functions you're interested in.
309///
310/// [#1314]: https://github.com/bytecodealliance/rustix/issues/1314
311pub mod quite_yet {
312    not_implemented!(_exit);
313    not_implemented!(_Exit);
314    not_implemented!(exit_group);
315    not_implemented!(sigpending);
316    not_implemented!(sigsuspend);
317    not_implemented!(execveat);
318    not_implemented!(execve);
319
320    /// For now, use `rustix::process::uname().nodename()` instead.
321    ///
322    /// See also the [module comment](self).
323    pub fn gethostname() {
324        unimplemented!()
325    }
326}