Skip to content

Commit 134e718

Browse files
chriswailestgross35
authored andcommitted
Add mallopt and related constants for Android
The `HeapTaggingLevel` enum does not have a typedef alias and thus generated tests will not compile due to the missing `enum` keyword. As a result the constants are defined using `i32` to match the signature for `mallopt`. See: https://cs.android.com/android/platform/superproject/main/+/main:bionic/libc/include/malloc.h;l=215
1 parent 1ee0549 commit 134e718

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

libc-test/semver/android.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,22 @@ MS_STRICTATIME
13261326
MS_SYNC
13271327
MS_SYNCHRONOUS
13281328
MS_UNBINDABLE
1329+
M_BIONIC_SET_HEAP_TAGGING_LEVEL
1330+
M_BIONIC_ZERO_INIT
1331+
M_CACHE_COUNT_MAX
1332+
M_CACHE_SIZE_MAX
1333+
M_DECAY_TIME
1334+
M_HEAP_TAGGING_LEVEL_ASYNC
1335+
M_HEAP_TAGGING_LEVEL_NONE
1336+
M_HEAP_TAGGING_LEVEL_SYNC
1337+
M_HEAP_TAGGING_LEVEL_TBI
1338+
M_MEMTAG_TUNING
1339+
M_MEMTAG_TUNING_BUFFER_OVERFLOW
1340+
M_MEMTAG_TUNING_UAF
1341+
M_PURGE
1342+
M_PURGE_ALL
1343+
M_THREAD_DISABLE_MEM_INIT
1344+
M_TSDS_COUNT_MAX
13291345
NCCS
13301346
NCP_SUPER_MAGIC
13311347
NDA_CACHEINFO
@@ -3520,6 +3536,7 @@ makedev
35203536
mallinfo
35213537
malloc
35223538
malloc_usable_size
3539+
mallopt
35233540
mcontext_t
35243541
memalign
35253542
memchr

src/unix/linux_like/android/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,6 +3153,26 @@ pub const IFLA_INFO_XSTATS: c_ushort = 3;
31533153
pub const IFLA_INFO_SLAVE_KIND: c_ushort = 4;
31543154
pub const IFLA_INFO_SLAVE_DATA: c_ushort = 5;
31553155

3156+
// malloc.h
3157+
pub const M_DECAY_TIME: c_int = -100;
3158+
pub const M_PURGE: c_int = -101;
3159+
pub const M_MEMTAG_TUNING: c_int = -102;
3160+
pub const M_THREAD_DISABLE_MEM_INIT: c_int = -103;
3161+
pub const M_PURGE_ALL: c_int = -104;
3162+
pub const M_CACHE_COUNT_MAX: c_int = -200;
3163+
pub const M_CACHE_SIZE_MAX: c_int = -201;
3164+
pub const M_TSDS_COUNT_MAX: c_int = -202;
3165+
pub const M_BIONIC_ZERO_INIT: c_int = -203;
3166+
pub const M_BIONIC_SET_HEAP_TAGGING_LEVEL: c_int = -204;
3167+
3168+
pub const M_MEMTAG_TUNING_BUFFER_OVERFLOW: c_int = 0;
3169+
pub const M_MEMTAG_TUNING_UAF: c_int = 1;
3170+
3171+
pub const M_HEAP_TAGGING_LEVEL_NONE: i32 = 0;
3172+
pub const M_HEAP_TAGGING_LEVEL_TBI: i32 = 1;
3173+
pub const M_HEAP_TAGGING_LEVEL_ASYNC: i32 = 2;
3174+
pub const M_HEAP_TAGGING_LEVEL_SYNC: i32 = 3;
3175+
31563176
// linux/rtnetlink.h
31573177
pub const TCA_UNSPEC: c_ushort = 0;
31583178
pub const TCA_KIND: c_ushort = 1;
@@ -3650,6 +3670,9 @@ extern "C" {
36503670

36513671
pub fn malloc_usable_size(ptr: *const c_void) -> size_t;
36523672

3673+
// available from API level 26
3674+
pub fn mallopt(opt: c_int, arg: c_int) -> c_int;
3675+
36533676
pub fn utmpname(name: *const c_char) -> c_int;
36543677
pub fn setutent();
36553678
pub fn getutent() -> *mut utmp;

0 commit comments

Comments
 (0)