llvm-project
35 строк · 1010.0 Байт
1//===-- Implementation of atexit ------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "src/stdlib/atexit.h"10#include "hdr/types/atexithandler_t.h"11#include "src/__support/common.h"12#include "src/stdlib/exit_handler.h"13
14namespace LIBC_NAMESPACE {15
16extern "C" {17
18int __cxa_atexit(AtExitCallback *callback, void *payload, void *) {19return add_atexit_unit(atexit_callbacks, {callback, payload});20}
21
22void __cxa_finalize(void *dso) {23if (!dso)24call_exit_callbacks(atexit_callbacks);25}
26
27} // extern "C"28
29LLVM_LIBC_FUNCTION(int, atexit, (__atexithandler_t callback)) {30return add_atexit_unit(31atexit_callbacks,32{&stdc_at_exit_func, reinterpret_cast<void *>(callback)});33}
34
35} // namespace LIBC_NAMESPACE36