[clang] [clang] Extend clang's <limits.h> to define *LONG_LONG*_ macros for bionic (PR #115406)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 13 12:21:42 PST 2024


https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/115406

>From eda669f73765a957cc47d3d684a6443ed2f75edf Mon Sep 17 00:00:00 2001
From: Zijun <zijunzhao at google.com>
Date: Fri, 8 Nov 2024 01:04:21 +0000
Subject: [PATCH 1/6] Extend clang's <limits.h> to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 56dffe568486cc..9879fe81faa651 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,11 +111,12 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension.  It's too bad
-   that we don't have something like #pragma poison that could be used to
-   deprecate a macro - the code should just use LLONG_MAX and friends.
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
+   defines them. It's too bad that we don't have something like #pragma poison
+   that could be used to deprecate a macro - the code should just use LLONG_MAX
+   and friends.
  */
-#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
+#if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 
 #undef   LONG_LONG_MIN
 #undef   LONG_LONG_MAX

>From b727c41e93ee0fa5f3cc2addf4f1b67ffedc8879 Mon Sep 17 00:00:00 2001
From: Zijun <zijunzhao at google.com>
Date: Fri, 8 Nov 2024 01:04:21 +0000
Subject: [PATCH 2/6] Extend clang's <limits.h> to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 9879fe81faa651..82e07f5a494951 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,10 +111,17 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
+<<<<<<< HEAD
 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
    defines them. It's too bad that we don't have something like #pragma poison
    that could be used to deprecate a macro - the code should just use LLONG_MAX
    and friends.
+=======
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
+   bionic also defines them. It's too bad that we don't have something like
+   #pragma poison that could be used to deprecate a macro - the code should just
+   use LLONG_MAX and friends.
+>>>>>>> 16ef50bd1f66 (Extend clang's <limits.h> to define *LONG_LONG*_ macros for bionic)
  */
 #if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 

>From 2cb4ee5d644f42b54f93e8e07fe61b93dc6de2f1 Mon Sep 17 00:00:00 2001
From: Zijun <zijunzhao at google.com>
Date: Fri, 8 Nov 2024 01:04:21 +0000
Subject: [PATCH 3/6] Extend clang's <limits.h> to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 82e07f5a494951..bc3dfb1d6d0d1c 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,17 +111,10 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-<<<<<<< HEAD
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
-   defines them. It's too bad that we don't have something like #pragma poison
-   that could be used to deprecate a macro - the code should just use LLONG_MAX
-   and friends.
-=======
 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
    bionic also defines them. It's too bad that we don't have something like
    #pragma poison that could be used to deprecate a macro - the code should just
    use LLONG_MAX and friends.
->>>>>>> 16ef50bd1f66 (Extend clang's <limits.h> to define *LONG_LONG*_ macros for bionic)
  */
 #if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 

>From a69cebad4e9f0b24bb4fa704157888c4604a71b2 Mon Sep 17 00:00:00 2001
From: Zijun <zijunzhao at google.com>
Date: Fri, 8 Nov 2024 01:04:21 +0000
Subject: [PATCH 4/6] Extend clang's <limits.h> to define *LONG_LONG*_ macros
 for Android's bionic

---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/test/Headers/limits.cpp | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3fc275b528d215..3d75dbe36c05b3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -319,6 +319,7 @@ C23 Feature Support
 
 - Clang now supports `N3029 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3029.htm>`_ Improved Normal Enumerations.
 - Clang now officially supports `N3030 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3030.htm>`_ Enhancements to Enumerations. Clang already supported it as an extension, so there were no changes to compiler behavior.
+- Extend clang's <limits.h> to define *LONG_LONG*_ macros for Android's bionic.
 
 Non-comprehensive list of changes in this release
 -------------------------------------------------
diff --git a/clang/test/Headers/limits.cpp b/clang/test/Headers/limits.cpp
index da7a64901831d5..132e5bc24a0c92 100644
--- a/clang/test/Headers/limits.cpp
+++ b/clang/test/Headers/limits.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -std=c17 -ffreestanding -fsyntax-only -verify -x c %s
 // RUN: %clang_cc1 -std=c2x -ffreestanding -fsyntax-only -verify -x c %s
 
+// Specifically test arm64 linux platforms.
+// RUN: %clang_cc1 -triple arm64-linux -ffreestanding -fsyntax-only -verify -x c %s
+
 // Specifically test 16-bit int platforms.
 // RUN: %clang_cc1 -triple=avr -ffreestanding -fsyntax-only -verify -x c %s
 // RUN: %clang_cc1 -triple=avr -std=c++11 -ffreestanding -fsyntax-only -verify %s

>From 96f3218cd8658111ef7bd69b948aa2d426d18f31 Mon Sep 17 00:00:00 2001
From: Zijun <zijunzhao at google.com>
Date: Fri, 8 Nov 2024 01:04:21 +0000
Subject: [PATCH 5/6] Extend clang's <limits.h> to define *LONG_LONG*_ macros
 for Android's bionic

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3d75dbe36c05b3..c56eeb72812c57 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -271,6 +271,8 @@ Resolutions to C++ Defect Reports
 C Language Changes
 ------------------
 
+- Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic.
+
 C2y Feature Support
 ^^^^^^^^^^^^^^^^^^^
 

>From 1720b12dbae4fd795957b2233b463bd0492d22f2 Mon Sep 17 00:00:00 2001
From: Zijun <zijunzhao at google.com>
Date: Fri, 8 Nov 2024 01:04:21 +0000
Subject: [PATCH 6/6] Extend clang's <limits.h> to define *LONG_LONG*_ macros
 for Android's bionic

---
 clang/docs/ReleaseNotes.rst | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c56eeb72812c57..73f1fce068fd1d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -321,7 +321,6 @@ C23 Feature Support
 
 - Clang now supports `N3029 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3029.htm>`_ Improved Normal Enumerations.
 - Clang now officially supports `N3030 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3030.htm>`_ Enhancements to Enumerations. Clang already supported it as an extension, so there were no changes to compiler behavior.
-- Extend clang's <limits.h> to define *LONG_LONG*_ macros for Android's bionic.
 
 Non-comprehensive list of changes in this release
 -------------------------------------------------



More information about the cfe-commits mailing list