[libc-commits] [libc] [libc] add an _Exit declaration to the _Exit proxy func header (PR #114904)

Job Henandez Lara via libc-commits libc-commits at lists.llvm.org
Wed Nov 6 16:27:29 PST 2024


https://github.com/Jobhdez updated https://github.com/llvm/llvm-project/pull/114904

>From 0f7bada2806630bf01fa09fda319283283c7c8a1 Mon Sep 17 00:00:00 2001
From: Job Hernandez <jobhdezlara93 at gmail.com>
Date: Mon, 4 Nov 2024 17:05:12 -0800
Subject: [PATCH 1/2] add _Exit declaration

---
 libc/hdr/func/_Exit.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libc/hdr/func/_Exit.h b/libc/hdr/func/_Exit.h
index e024a651a50bcf..b8160e9af3e4e3 100644
--- a/libc/hdr/func/_Exit.h
+++ b/libc/hdr/func/_Exit.h
@@ -10,8 +10,7 @@
 #define LLVM_LIBC_HDR_FUNC_EXIT_H
 
 #ifdef LIBC_FULL_BUILD
-// We will use the `_Exit` declaration from our generated stdlib.h
-#include <stdlib.h>
+extern "C" [[noreturn]] void _Exit(int) noexcept;
 
 #else // Overlay mode
 

>From 30e2cba1b5099cbe7ea63381e71dc4d4882a4cdf Mon Sep 17 00:00:00 2001
From: Job Hernandez <jobhdezlara93 at gmail.com>
Date: Wed, 6 Nov 2024 16:27:00 -0800
Subject: [PATCH 2/2] address review

---
 libc/hdr/func/CMakeLists.txt                | 10 ----------
 libc/hdr/func/_Exit.h                       | 21 ---------------------
 libc/test/src/stdlib/CMakeLists.txt         |  3 +--
 libc/test/src/stdlib/at_quick_exit_test.cpp |  3 +--
 libc/test/src/stdlib/atexit_test.cpp        |  3 +--
 5 files changed, 3 insertions(+), 37 deletions(-)
 delete mode 100644 libc/hdr/func/_Exit.h

diff --git a/libc/hdr/func/CMakeLists.txt b/libc/hdr/func/CMakeLists.txt
index 714b7ec9b48809..608bab5ae1e95d 100644
--- a/libc/hdr/func/CMakeLists.txt
+++ b/libc/hdr/func/CMakeLists.txt
@@ -40,13 +40,3 @@ add_proxy_header_library(
   FULL_BUILD_DEPENDS
     libc.include.stdlib
 )
-
-add_proxy_header_library(
-  _Exit
-  HDRS
-    _Exit.h
-  DEPENDS
-    libc.hdr.stdlib_overlay
-  FULL_BUILD_DEPENDS
-    libc.include.stdlib
-)
diff --git a/libc/hdr/func/_Exit.h b/libc/hdr/func/_Exit.h
deleted file mode 100644
index b8160e9af3e4e3..00000000000000
--- a/libc/hdr/func/_Exit.h
+++ /dev/null
@@ -1,21 +0,0 @@
-//===-- Definition of the _Exit proxy -------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_HDR_FUNC_EXIT_H
-#define LLVM_LIBC_HDR_FUNC_EXIT_H
-
-#ifdef LIBC_FULL_BUILD
-extern "C" [[noreturn]] void _Exit(int) noexcept;
-
-#else // Overlay mode
-
-#include "hdr/stdlib_overlay.h"
-
-#endif
-
-#endif // LLVM_LIBC_HDR_EXIT_H
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 4ea894cf48724d..ff6034e43e9f6a 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -382,7 +382,6 @@ if(LLVM_LIBC_FULL_BUILD)
     SRCS
       atexit_test.cpp
     DEPENDS
-      libc.hdr.func._Exit 
       libc.src.stdlib._Exit
       libc.src.stdlib.exit
       libc.src.stdlib.atexit
@@ -398,7 +397,7 @@ if(LLVM_LIBC_FULL_BUILD)
     SRCS
       at_quick_exit_test.cpp
     DEPENDS
-      libc.hdr.func._Exit 
+      libc.src.stdlib._Exit
       libc.src.stdlib.quick_exit
       libc.src.stdlib.at_quick_exit
       libc.src.__support.CPP.array
diff --git a/libc/test/src/stdlib/at_quick_exit_test.cpp b/libc/test/src/stdlib/at_quick_exit_test.cpp
index 8049fe58d29bd3..1ed5a83a61b8d0 100644
--- a/libc/test/src/stdlib/at_quick_exit_test.cpp
+++ b/libc/test/src/stdlib/at_quick_exit_test.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "hdr/func/_Exit.h"
 #include "src/__support/CPP/array.h"
 #include "src/__support/CPP/utility.h"
 #include "src/stdlib/at_quick_exit.h"
@@ -34,7 +33,7 @@ TEST(LlvmLibcAtQuickExit, Basic) {
 
 TEST(LlvmLibcAtQuickExit, AtQuickExitCallsSysExit) {
   auto test = [] {
-    LIBC_NAMESPACE::at_quick_exit(+[] { _Exit(1); });
+    LIBC_NAMESPACE::at_quick_exit(+[] { LIBC_NAMESPACE::_Exit(1); });
     LIBC_NAMESPACE::quick_exit(0);
   };
   EXPECT_EXITS(test, 1);
diff --git a/libc/test/src/stdlib/atexit_test.cpp b/libc/test/src/stdlib/atexit_test.cpp
index 9e19423f730860..24f8b0451f3636 100644
--- a/libc/test/src/stdlib/atexit_test.cpp
+++ b/libc/test/src/stdlib/atexit_test.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "hdr/func/_Exit.h"
 #include "src/__support/CPP/array.h"
 #include "src/__support/CPP/utility.h"
 #include "src/stdlib/atexit.h"
@@ -34,7 +33,7 @@ TEST(LlvmLibcAtExit, Basic) {
 
 TEST(LlvmLibcAtExit, AtExitCallsSysExit) {
   auto test = [] {
-    LIBC_NAMESPACE::atexit(+[] { _Exit(1); });
+    LIBC_NAMESPACE::atexit(+[] { LIBC_NAMESPACE::_Exit(1); });
     LIBC_NAMESPACE::exit(0);
   };
   EXPECT_EXITS(test, 1);



More information about the libc-commits mailing list