Issue 94060
Summary [libc] add `at_quick_exit`
Labels libc
Assignees michaelrj-google
Reporter michaelrj-google
    Followup to #93581

The `at_quick_exit` function is defined in the C standard on page 381 of this PDF: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf

It's used to register callbacks to be run when `quick_exit` is called, so changes to `quick_exit` will be necessary. Additionally it's similar in design to [`atexit`](https://github.com/llvm/llvm-project/blob/main/libc/src/stdlib/atexit.cpp) so refactoring to reuse that code is recommended.

### Build System

In [entrypoints.txt](https://github.com/llvm/llvm-project/blob/main/libc/config/linux/x86_64/entrypoints.txt)
- [ ] Add the new function to the list of entrypoints for stdlib.h (you need to do this before it will build)

In [stdlib/CMakeLists.txt](https://github.com/llvm/llvm-project/blob/main/libc/src/stdlib/CMakeLists.txt)
- [ ] Add new entrypoint objects to the list

In [stdc.td](https://github.com/llvm/llvm-project/blob/main/libc/spec/stdc.td)
- [ ] Add the functions to the list of functions for stdlib.h.

### Code

- [ ] Refactor [`atexit`](https://github.com/llvm/llvm-project/blob/main/libc/src/stdlib/atexit.cpp)
The existing implementation of `atexit` defines a system for storing and calling functions similar to what should be used for `at_quick_exit`, so it should be moved to a shared file. From there, both `atexit` and `at_quick_exit` should maintain separate lists of functions to call.

- [ ] Create `stdlib/at_quick_exit.h`
- [ ] Create `stdlib/at_quick_exit.cpp`

### Testing

- [ ] Create `test/src/stdlib/at_quick_exit_test.cpp`

- [ ] Add your test to [test/src/stdlib/CMakeLists.txt](https://github.com/llvm/llvm-project/blob/main/libc/test/src/stdlib/CMakeLists.txt)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to