Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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