Skip to content

Commit 7d20ea9

Browse files
authored
[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.
1 parent 531acf9 commit 7d20ea9

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ Resolutions to C++ Defect Reports
271271
C Language Changes
272272
------------------
273273

274+
- Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic.
275+
274276
C2y Feature Support
275277
^^^^^^^^^^^^^^^^^^^
276278

clang/lib/Headers/limits.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@
111111
#define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
112112
#endif
113113

114-
/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. It's too bad
115-
that we don't have something like #pragma poison that could be used to
116-
deprecate a macro - the code should just use LLONG_MAX and friends.
114+
/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
115+
bionic also defines them. It's too bad that we don't have something like
116+
#pragma poison that could be used to deprecate a macro - the code should just
117+
use LLONG_MAX and friends.
117118
*/
118-
#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
119+
#if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) \
120+
: !defined(__STRICT_ANSI__)) || \
121+
defined(__BIONIC__)
119122

120123
#undef LONG_LONG_MIN
121124
#undef LONG_LONG_MAX

clang/test/Headers/limits.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// RUN: %clang_cc1 -std=c17 -ffreestanding -fsyntax-only -verify -x c %s
55
// RUN: %clang_cc1 -std=c2x -ffreestanding -fsyntax-only -verify -x c %s
66

7+
// Specifically test arm64 linux platforms.
8+
// RUN: %clang_cc1 -triple arm64-linux -ffreestanding -fsyntax-only -verify -x c %s
9+
710
// Specifically test 16-bit int platforms.
811
// RUN: %clang_cc1 -triple=avr -ffreestanding -fsyntax-only -verify -x c %s
912
// RUN: %clang_cc1 -triple=avr -std=c++11 -ffreestanding -fsyntax-only -verify %s

0 commit comments

Comments
 (0)