[libc-commits] [libc] [libc] add `LLVM_LIBC_CAST` macro. (PR #127319)
via libc-commits
libc-commits at lists.llvm.org
Sat Feb 15 04:59:21 PST 2025
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/127319
related: #127238
This patch adds a macro called `LLVM_LIBC_CAST`, similar to `__BIONIC_CAST`, for type conversion in `endian.h`.
>From 866374c4fb133bcb3d22b3ce2dfcbc9fb7559dac Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Sat, 15 Feb 2025 20:56:03 +0800
Subject: [PATCH] add LLVM_LIBC_CAST macro
---
libc/include/__llvm-libc-common.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libc/include/__llvm-libc-common.h b/libc/include/__llvm-libc-common.h
index a0fa506c01ab8..83682e0a440d8 100644
--- a/libc/include/__llvm-libc-common.h
+++ b/libc/include/__llvm-libc-common.h
@@ -47,6 +47,9 @@
#define __NOEXCEPT throw()
#endif
+#undef LLVM_LIBC_CAST
+#define LLVM_LIBC_CAST(cast, type, value) (cast<type>(value))
+
#else // not __cplusplus
#undef __BEGIN_C_DECLS
@@ -85,6 +88,9 @@
#undef _Returns_twice
#define _Returns_twice __attribute__((returns_twice))
+#undef LLVM_LIBC_CAST
+#define LLVM_LIBC_CAST(cast, type, value) ((type)(value))
+
#endif // __cplusplus
#endif // LLVM_LIBC_COMMON_H
More information about the libc-commits
mailing list