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

via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 14 10:39:11 PST 2024


Author: ZijunZhaoCCK
Date: 2024-11-14T10:39:08-08:00
New Revision: 7d20ea9d32954e8e5becab8495fa509a3f67b710

URL: https://github.com/llvm/llvm-project/commit/7d20ea9d32954e8e5becab8495fa509a3f67b710
DIFF: https://github.com/llvm/llvm-project/commit/7d20ea9d32954e8e5becab8495fa509a3f67b710.diff

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

*LONG_LONG*_ macros are not GNU-only extensions any more. Bionic also
defines them.

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/lib/Headers/limits.h
    clang/test/Headers/limits.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index eecfd585c1c03d..681728d36952c1 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
 ^^^^^^^^^^^^^^^^^^^
 

diff  --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 56dffe568486cc..d08227fe4d3d48 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,11 +111,14 @@
 #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. 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.
  */
-#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

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


        


More information about the cfe-commits mailing list