/* android.h - A secure memory allocator * Copyright 2023 - chris.rohlf@gmail.com */ #pragma once #include #include /* This magic number is usually defined by Android Bionic: * https://android.googlesource.com/platform/bionic/+/263325d/libc/include/sys/prctl.h#42 */ #ifndef PR_SET_VMA #define PR_SET_VMA 0x53564d41 #endif #ifndef PR_SET_VMA_ANON_NAME #define PR_SET_VMA_ANON_NAME 0 #endif #if (__clang_major__ >= 12 && defined(__aarch64__) && !defined(__ILP32__)) && ARM_MTE == 1 /* TODO: these belong in an aarch specific header */ #ifndef PROT_MTE #define PROT_MTE 0x20 #endif #ifndef PR_SET_TAGGED_ADDR_CTRL #define PR_SET_TAGGED_ADDR_CTRL 54 #endif #ifndef PR_GET_TAGGED_ADDR_CTRL #define PR_GET_TAGGED_ADDR_CTRL 56 #endif #ifndef PR_TAGGED_ADDR_ENABLE #define PR_TAGGED_ADDR_ENABLE (1UL << 0) #endif #ifndef PR_MTE_TCF_SHIFT #define PR_MTE_TCF_SHIFT 1 #endif #ifndef PR_MTE_TAG_SHIFT #define PR_MTE_TAG_SHIFT 3 #endif #ifndef PR_MTE_TCF_NONE #define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT) #endif #ifndef PR_MTE_TCF_SYNC #define PR_MTE_TCF_SYNC (1UL << PR_MTE_TCF_SHIFT) #endif #ifndef PR_MTE_TCF_MASK #define PR_MTE_TCF_MASK (3UL << PR_MTE_TCF_SHIFT) #endif #endif