3030
3131#[ cfg( feature = "thread" ) ]
3232use crate :: thread;
33- #[ cfg( feature = "alloc " ) ]
33+ #[ cfg( feature = "program-at-exit " ) ]
3434use alloc:: boxed:: Box ;
35- #[ cfg( all( feature = "alloc " , not( feature = "thread" ) ) ) ]
35+ #[ cfg( all( feature = "program-at-exit " , not( feature = "thread" ) ) ) ]
3636use core:: cell:: UnsafeCell ;
3737use linux_raw_sys:: ctypes:: c_int;
38- #[ cfg( all( feature = "alloc " , feature = "thread" ) ) ]
38+ #[ cfg( all( feature = "program-at-exit " , feature = "thread" ) ) ]
3939use rustix_futex_sync:: Mutex ;
4040
4141#[ cfg( not( any( feature = "origin-start" , feature = "external-start" ) ) ) ]
@@ -227,28 +227,28 @@ unsafe fn init_runtime(mem: *mut usize, envp: *mut *mut u8) {
227227/// `SmallVec` to ensure we can register that many without allocating.
228228///
229229/// [POSIX guarantees]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/atexit.html
230- #[ cfg( all( feature = "alloc " , feature = "thread" ) ) ]
230+ #[ cfg( all( feature = "program-at-exit " , feature = "thread" ) ) ]
231231static DTORS : Mutex < smallvec:: SmallVec < [ Box < dyn FnOnce ( ) + Send > ; 32 ] > > =
232232 Mutex :: new ( smallvec:: SmallVec :: new_const ( ) ) ;
233233
234234/// A type for `DTORS` in the single-threaded case that we can mark as `Sync`.
235- #[ cfg( all( feature = "alloc " , not( feature = "thread" ) ) ) ]
235+ #[ cfg( all( feature = "program-at-exit " , not( feature = "thread" ) ) ) ]
236236struct Dtors ( UnsafeCell < smallvec:: SmallVec < [ Box < dyn FnOnce ( ) + Send > ; 32 ] > > ) ;
237237
238238/// SAFETY: With `feature = "take-charge"`, we can assume that Origin is
239239/// responsible for creating all threads in the program, and with
240240/// `not(feature = "thread")` mode, Origin can't create any new threads, so we
241241/// don't need to synchronize.
242- #[ cfg( all( feature = "alloc " , not( feature = "thread" ) ) ) ]
242+ #[ cfg( all( feature = "program-at-exit " , not( feature = "thread" ) ) ) ]
243243unsafe impl Sync for Dtors { }
244244
245245/// The single-threaded version of `DTORS`.
246- #[ cfg( all( feature = "alloc " , not( feature = "thread" ) ) ) ]
246+ #[ cfg( all( feature = "program-at-exit " , not( feature = "thread" ) ) ) ]
247247static DTORS : Dtors = Dtors ( UnsafeCell :: new ( smallvec:: SmallVec :: new_const ( ) ) ) ;
248248
249249/// Register a function to be called when [`exit`] is called.
250- #[ cfg( feature = "alloc " ) ]
251- #[ cfg_attr( docsrs, doc( cfg( feature = "alloc " ) ) ) ]
250+ #[ cfg( feature = "program-at-exit " ) ]
251+ #[ cfg_attr( docsrs, doc( cfg( feature = "program-at-exit " ) ) ) ]
252252pub fn at_exit ( func : Box < dyn FnOnce ( ) + Send > ) {
253253 #[ cfg( feature = "thread" ) ]
254254 let mut dtors = DTORS . lock ( ) ;
@@ -263,13 +263,13 @@ pub fn at_exit(func: Box<dyn FnOnce() + Send>) {
263263/// `.fini_array` section, and exit the program.
264264pub fn exit ( status : c_int ) -> ! {
265265 // Call functions registered with `at_thread_exit`.
266- #[ cfg( all ( feature = "alloc" , feature = " thread" ) ) ]
266+ #[ cfg( feature = "thread-at-exit" ) ]
267267 crate :: thread:: call_dtors ( crate :: thread:: current ( ) ) ;
268268
269269 // Call all the registered functions, in reverse order. Leave `DTORS`
270270 // unlocked while making the call so that functions can add more functions
271271 // to the end of the list.
272- #[ cfg( feature = "alloc " ) ]
272+ #[ cfg( feature = "program-at-exit " ) ]
273273 loop {
274274 #[ cfg( feature = "thread" ) ]
275275 let mut dtors = DTORS . lock ( ) ;
0 commit comments