[LIBC][NFC] Rename errno and assert files to match other files with functions
authorMichael Jones <michaelrj@google.com>
Mon, 2 Nov 2020 23:16:00 +0000 (23:16 +0000)
committerMichael Jones <michaelrj@google.com>
Tue, 3 Nov 2020 21:29:32 +0000 (21:29 +0000)
Rename the files containing the `__errno_location` function
to `__errno_location.h/cpp` to match the other files and move
the `llvmlibc_errno` macro to its own file.

Split assert.h into `__assert_fail.h` (contains the function prototype)
and assert.h (contains the assert macro).

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D90653

libc/src/assert/CMakeLists.txt
libc/src/assert/__assert_fail.cpp
libc/src/assert/__assert_fail.h [new file with mode: 0644]
libc/src/assert/assert.h
libc/src/errno/CMakeLists.txt
libc/src/errno/__errno_location.cpp [moved from libc/src/errno/errno_location.cpp with 94% similarity]
libc/src/errno/__errno_location.h [new file with mode: 0644]
libc/src/errno/llvmlibc_errno.h

index 69c54b5..36123cc 100644 (file)
@@ -3,6 +3,7 @@ add_entrypoint_object(
   SRCS
     __assert_fail.cpp
   HDRS
   SRCS
     __assert_fail.cpp
   HDRS
+    __assert_fail.h
     assert.h
   DEPENDS
     # These two dependencies are temporary and should be replaced by fprintf
     assert.h
   DEPENDS
     # These two dependencies are temporary and should be replaced by fprintf
index 8b75a3b..114a368 100644 (file)
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/assert/assert.h"
+#include "src/assert/__assert_fail.h"
 #include "src/stdlib/abort.h"
 
 // These includes are temporary.
 #include "src/stdlib/abort.h"
 
 // These includes are temporary.
diff --git a/libc/src/assert/__assert_fail.h b/libc/src/assert/__assert_fail.h
new file mode 100644 (file)
index 0000000..3ad2400
--- /dev/null
@@ -0,0 +1,21 @@
+//===-- Internal header for __assert_fail -----------------------*- C++ -*-===//
+//
+// 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_SRC_ASSERT_ASSERT_FAIL_H
+#define LLVM_LIBC_SRC_ASSERT_ASSERT_FAIL_H
+
+#include <stddef.h>
+
+namespace __llvm_libc {
+
+[[noreturn]] void __assert_fail(const char *assertion, const char *file,
+                                unsigned line, const char *function);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_ASSERT_ASSERT_FAIL_H
index 4c9a15d..46cfe3b 100644 (file)
@@ -6,19 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC_ASSERT_ASSERT_H
-#define LLVM_LIBC_SRC_ASSERT_ASSERT_H
+#include "src/assert/__assert_fail.h"
 
 
-#include <stddef.h>
-
-namespace __llvm_libc {
-
-[[noreturn]] void __assert_fail(const char *assertion, const char *file, unsigned line,
-                  const char *function);
-
-} // namespace __llvm_libc
-
-#endif // LLVM_LIBC_SRC_ASSERT_ASSERT_H
+// There is no header guard here since assert is intended to be able to be
+// able to be included multiple times with NDEBUG defined differently, causing
+// different behavior.
 
 #undef assert
 
 
 #undef assert
 
index 9f24490..e13aa1d 100644 (file)
@@ -1,7 +1,8 @@
 add_entrypoint_object(
   __errno_location
   SRCS
 add_entrypoint_object(
   __errno_location
   SRCS
-    errno_location.cpp
+    __errno_location.cpp
   HDRS
   HDRS
+    __errno_location.h
     llvmlibc_errno.h
 )
     llvmlibc_errno.h
 )
similarity index 94%
rename from libc/src/errno/errno_location.cpp
rename to libc/src/errno/__errno_location.cpp
index 1d3e2b7..3e7c769 100644 (file)
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/errno/llvmlibc_errno.h"
+#include "src/errno/__errno_location.h"
 
 #include "src/__support/common.h"
 
 
 #include "src/__support/common.h"
 
diff --git a/libc/src/errno/__errno_location.h b/libc/src/errno/__errno_location.h
new file mode 100644 (file)
index 0000000..20be3fc
--- /dev/null
@@ -0,0 +1,18 @@
+//===-- Implementation header for __errno_location --------------*- C++ -*-===//
+//
+// 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_SRC_ERRNO_ERRNO_LOCATION_H
+#define LLVM_LIBC_SRC_ERRNO_ERRNO_LOCATION_H
+
+namespace __llvm_libc {
+
+int *__errno_location();
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_ERRNO_ERRNO_LOCATION_H
index 8702056..d1032a4 100644 (file)
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/errno/__errno_location.h"
+
 #ifndef LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H
 #define LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H
 
 #ifndef LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H
 #define LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H
 
 // public header.
 #define llvmlibc_errno (*__llvm_libc::__errno_location())
 
 // public header.
 #define llvmlibc_errno (*__llvm_libc::__errno_location())
 
-namespace __llvm_libc {
-
-int *__errno_location();
-
-} // namespace __llvm_libc
-
 #endif // LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H
 #endif // LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H