Skip to content

Commit

Permalink
[clang] Extend clang's <limits.h> to define *LONG_LONG*_ macros for b…
Browse files Browse the repository at this point in the history
…ionic (#115406)

*LONG_LONG*_ macros are not GNU-only extensions any more. Bionic also
defines them.
  • Loading branch information
ZijunZhaoCCK authored Nov 14, 2024
1 parent 531acf9 commit 7d20ea9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^

Expand Down
11 changes: 7 additions & 4 deletions clang/lib/Headers/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Headers/limits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d20ea9

Please sign in to comment.