[libc-commits] [libc] [libc][assert] define __STDC_VERSION_ASSERT_H__ (PR #87592)
via libc-commits
libc-commits at lists.llvm.org
Tue Apr 23 20:01:08 PDT 2024
https://github.com/aniplcc updated https://github.com/llvm/llvm-project/pull/87592
>From e305e6543c9b15ff0c11a46b3038556b3df6b733 Mon Sep 17 00:00:00 2001
From: aniplcc <aniplccode at gmail.com>
Date: Thu, 4 Apr 2024 06:52:11 +0530
Subject: [PATCH 1/6] [libc][assert] define __STDC_VERSION_ASSERT_H__
---
libc/include/assert.h.def | 8 +++++++-
libc/include/llvm-libc-macros/assert-macros.h | 14 ++++++++++++++
libc/test/include/assert_test.cpp | 15 +++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 libc/include/llvm-libc-macros/assert-macros.h
create mode 100644 libc/test/include/assert_test.cpp
diff --git a/libc/include/assert.h.def b/libc/include/assert.h.def
index e006133a76542a..65f476f6886d9a 100644
--- a/libc/include/assert.h.def
+++ b/libc/include/assert.h.def
@@ -1,14 +1,20 @@
//===-- C standard library header assert.h --------------------------------===//
-//
// 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_ASSERT_H
+#define LLVM_LIBC_ASSERT_H
+
#include "__llvm-libc-common.h"
// This file may be usefully included multiple times to change assert()'s
// definition based on NDEBUG.
%%public_api()
+
+#include "llvm-libc-macros/assert-macros.h"
+
+#endif // LLVM_LIBC_ASSERT_H
diff --git a/libc/include/llvm-libc-macros/assert-macros.h b/libc/include/llvm-libc-macros/assert-macros.h
new file mode 100644
index 00000000000000..44e14543d8562e
--- /dev/null
+++ b/libc/include/llvm-libc-macros/assert-macros.h
@@ -0,0 +1,14 @@
+//===-- Definition of macros to be used with assert functions -------------===//
+//
+// 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_MACROS_ASSERT_MACROS_H
+#define __LLVM_LIBC_MACROS_ASSERT_MACROS_H
+
+#define __STDC_VERSION_ASSERT_H__ 202311L
+
+#endif // __LLVM_LIBC_MACROS_ASSERT_MACROS_H
diff --git a/libc/test/include/assert_test.cpp b/libc/test/include/assert_test.cpp
new file mode 100644
index 00000000000000..78709bbcdd5941
--- /dev/null
+++ b/libc/test/include/assert_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for assert ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDSList-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "include/llvm-libc-macros/assert-macros.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcAssertTest, VersionMacro) {
+ // 7.2p3 an integer constant expression with a value equivalent to 202311L.
+ EXPECT_EQ(__STDC_VERSION_ASSERT_H__, 202311L);
+}
>From 365374c2a06d217ca6e49d66cf4cdc8f98c8f295 Mon Sep 17 00:00:00 2001
From: aniplcc <aniplccode at gmail.com>
Date: Thu, 4 Apr 2024 07:14:16 +0530
Subject: [PATCH 2/6] update cmake
---
libc/test/include/CMakeLists.txt | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libc/test/include/CMakeLists.txt b/libc/test/include/CMakeLists.txt
index 8d8dff53169f6a..03c31855e352ba 100644
--- a/libc/test/include/CMakeLists.txt
+++ b/libc/test/include/CMakeLists.txt
@@ -1,5 +1,15 @@
add_custom_target(libc_include_tests)
+add_libc_test(
+ assert_test
+ SUITE
+ libc_include_tests
+ SRCS
+ assert_test.cpp
+ DEPENDS
+ libc.include.llvm-libc-macros.assert_macros
+)
+
add_libc_test(
sys_queue_test
SUITE
>From d27b931268994cba5364639d65eebba6dbbd7323 Mon Sep 17 00:00:00 2001
From: aniplcc <aniplccode at gmail.com>
Date: Thu, 4 Apr 2024 07:41:02 +0530
Subject: [PATCH 3/6] update cmake
---
libc/include/llvm-libc-macros/CMakeLists.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt
index 635ccadfb49e7d..3b1b9e173d6816 100644
--- a/libc/include/llvm-libc-macros/CMakeLists.txt
+++ b/libc/include/llvm-libc-macros/CMakeLists.txt
@@ -31,6 +31,12 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()
+add_macro_header(
+ assert_macros
+ HDR
+ assert-macros.h
+)
+
add_macro_header(
generic_error_number_macros
HDR
>From 15142b1cbf6bcaa226114fd585e2fa359ede34d3 Mon Sep 17 00:00:00 2001
From: aniplcc <aniplccode at gmail.com>
Date: Thu, 4 Apr 2024 07:45:14 +0530
Subject: [PATCH 4/6] Update assert.h.def
---
libc/include/assert.h.def | 1 +
1 file changed, 1 insertion(+)
diff --git a/libc/include/assert.h.def b/libc/include/assert.h.def
index 65f476f6886d9a..03b53e7d75780f 100644
--- a/libc/include/assert.h.def
+++ b/libc/include/assert.h.def
@@ -1,4 +1,5 @@
//===-- C standard library header assert.h --------------------------------===//
+//
// 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
>From 15ce30e911d293dbe73a56efbc73d9aa1cdeb3d6 Mon Sep 17 00:00:00 2001
From: aniplcc <aniplccode at gmail.com>
Date: Thu, 4 Apr 2024 23:48:29 +0530
Subject: [PATCH 5/6] Update assert.h.def
---
libc/include/assert.h.def | 5 -----
1 file changed, 5 deletions(-)
diff --git a/libc/include/assert.h.def b/libc/include/assert.h.def
index 03b53e7d75780f..0fb4142076b495 100644
--- a/libc/include/assert.h.def
+++ b/libc/include/assert.h.def
@@ -6,9 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBC_ASSERT_H
-#define LLVM_LIBC_ASSERT_H
-
#include "__llvm-libc-common.h"
// This file may be usefully included multiple times to change assert()'s
@@ -17,5 +14,3 @@
%%public_api()
#include "llvm-libc-macros/assert-macros.h"
-
-#endif // LLVM_LIBC_ASSERT_H
>From d6b174abc6dfdd2fff6e38d64689298bee676b36 Mon Sep 17 00:00:00 2001
From: aniplcc <aniplccode at gmail.com>
Date: Wed, 24 Apr 2024 08:30:57 +0530
Subject: [PATCH 6/6] Update assert.h.def
---
libc/include/assert.h.def | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libc/include/assert.h.def b/libc/include/assert.h.def
index 0fb4142076b495..15077e53e2ca48 100644
--- a/libc/include/assert.h.def
+++ b/libc/include/assert.h.def
@@ -7,10 +7,9 @@
//===----------------------------------------------------------------------===//
#include "__llvm-libc-common.h"
+#include "llvm-libc-macros/assert-macros.h"
// This file may be usefully included multiple times to change assert()'s
// definition based on NDEBUG.
%%public_api()
-
-#include "llvm-libc-macros/assert-macros.h"
More information about the libc-commits
mailing list