Skip to content

Use NDK availability guard for mallopt instead of weak declaration - #2384

Open
charlesmunger wants to merge 1 commit into
google:mainfrom
charlesmunger:ndkversioncheck
Open

charlesmunger wants to merge 1 commit into
google:mainfrom
charlesmunger:ndkversioncheck

Conversation

@charlesmunger

Copy link
Copy Markdown
Contributor

Removes extraneous weak declaration in favor of conditioning the version check on whether the android headers declare symbols as weak.

@dmah42

dmah42 commented Nov 13, 2026

Copy link
Copy Markdown
Member

do you mind checking that clang format issue?

In Android NDK headers (<malloc.h>), mallopt() is declared with
__INTRODUCED_IN(26) and guarded by __BIONIC_AVAILABILITY_GUARD(26).
When __ANDROID_MIN_SDK_VERSION__ < 26, mallopt() is declared as a weak
symbol if __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__ is defined, and
hidden otherwise.

Instead of manually declaring mallopt() with __attribute__((weak)) and
checking the deprecated __ANDROID_API__ macro, guard the
__builtin_available() blocks with
__ANDROID_MIN_SDK_VERSION__ >= 26 || defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__).
@charlesmunger

Copy link
Copy Markdown
Contributor Author

formatting fixed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants