About Bionic
Bionic is Android’s C library, math library, and dynamic linker. It provides a subset of standard C library functionality with Android-specific optimizations and modifications.Bionic is not fully POSIX-compliant. Always check API availability for your target Android version before using standard C library functions.
POSIX compliance
Bionic provides partial POSIX compliance with some differences from standard glibc implementations.Supported POSIX features
Full support
pthread APIs are fully supported with Android-specific extensions for thread naming and priority.
Full support
Standard file operations (open, read, write, close) are fully supported.
Full support
malloc, free, and related APIs with Android-specific allocators.
Full support
Socket APIs for network communication, including Unix domain sockets.
Limited or missing POSIX features
System V IPC
System V IPC
System V shared memory, semaphores, and message queues are not supported.Alternative: Use POSIX shared memory (
shm_open, mmap) or Android IPC mechanisms.Locale support
Locale support
Very limited locale support. Most locale functions are stubs.Impact: Functions like
setlocale(), nl_langinfo() have minimal functionality.Real-time extensions
Real-time extensions
Limited support for POSIX real-time extensions.Available: Basic timer APIs
Limited: Real-time signals, advanced scheduling
Limited: Real-time signals, advanced scheduling
Wide character support
Wide character support
Basic wide character support, but not all functions are implemented.Impact: Some
wchar.h functions may be missing or have limited functionality.Standard C library functions
String functions
All standard string functions are available across all Android API levels:Code example: Safe string operations
Math functions
Standard math library functions from<math.h>:
API availability by Android version
Android 5.0 (API 21) - Minimum supported
API 21 includes:- Complete pthread support
- Standard C11 features (except threads.h)
- Basic math functions
- File I/O and networking
Android 8.0 (API 26) - Major improvements
New in API 26:function
Create a stream that writes to a dynamically allocated buffer.
function
Secure random number generation (cryptographically secure).
function
Path pattern matching (globbing).
Android 9.0 (API 28) - String safety
New in API 28:function
Safe string copy with guaranteed null termination.
function
Safe string concatenation with size limits.
Android 12.0 (API 31) - Modern C features
New in API 31:function
C11 time function for high-resolution timestamps.
function
Allocate aligned memory (C11 standard).
Function availability table
Standard C functions by API level
Math functions by API level
Threading APIs
Bionic provides full pthread support with Android-specific extensions.Code example: Thread creation
Code example: Mutexes and synchronization
Memory allocation
Bionic provides standard memory allocation with Android-specific optimizations.Available allocators
Standard
Standard memory allocation. Uses jemalloc on most Android versions.
Standard
Allocate and zero-initialize memory.
Standard
Resize previously allocated memory.
Aligned
Allocate aligned memory. Available from API 21+.
Code example: Memory allocation patterns
Important differences from glibc
Key differences
- No System V IPC: Use POSIX alternatives or Android-specific IPC
- Limited locale support: Don’t rely on locale-specific formatting
- Different allocator: Memory allocation behavior may differ from glibc
- No
dlmopen: Only standarddlopenis supported - Different signal handling: Some signal behaviors differ from standard Linux
Code example: Portable code patterns
Official documentation
Android bionic status
Comprehensive status of Bionic APIs and POSIX compliance
Next steps
Platform APIs
Platform API availability and private vs public APIs
Android-specific APIs
NativeActivity, Asset Manager, and other Android APIs
Dynamic linker
Understanding Android’s dynamic linker
32-bit ABI issues
Known issues with 32-bit Android ABIs