Skip to content

Commit 208d1ea

Browse files
authored
Merge pull request #104 from devnexen/cpu_pin_macm1
CPU_PIN support for mac M1 proposal.
2 parents 6288817 + 5c9835d commit 208d1ea

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ LIBNAME = libisoalloc.so
165165
UNAME := $(shell uname)
166166
ifeq ($(UNAME), Darwin)
167167
OS_FLAGS = -framework Security
168-
CPU_PIN =
169168
LIBNAME = libisoalloc.dylib
170169
endif
171170

android/jni/Android.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
LOCAL_PATH := $(call my-dir)
22
include $(CLEAR_VARS)
33

4-
LOCAL_CFLAGS := -DTHREAD_SUPPORT=1 -pthread \
4+
LOCAL_CFLAGS := -DTHREAD_SUPPORT=1 -pthread \
55
-DPRE_POPULATE_PAGES=0 -DSMALL_MEM_STARTUP=0 -DSANITIZE_CHUNKS=0 \
66
-DFUZZ_MODE=0 -DPERM_FREE_REALLOC=0 -DDISABLE_CANARY=0 -Werror \
77
-pedantic -Wno-pointer-arith -Wno-gnu-zero-variadic-macro-arguments \
88
-Wno-format-pedantic -DMALLOC_HOOK=1 -fvisibility=hidden -std=c11 \
9-
-DALLOC_SANITY=0 -DUNINIT_READ_SANITY=0 -DCPU_PIN=0 -DEXPERIMENTAL=0 \
9+
-DALLOC_SANITY=0 -DUNINIT_READ_SANITY=0 -DCPU_PIN=0 -DEXPERIMENTAL=0 \
1010
-DUAF_PTR_PAGE=0 -DVERIFY_BIT_SLOT_CACHE=0 -DNAMED_MAPPINGS=1 -fPIC \
11-
-shared -DDEBUG=1 -DLEAK_DETECTOR=1 -DMEM_USAGE=1 -DUSE_MLOCK=1 \
11+
-shared -DDEBUG=1 -DLEAK_DETECTOR=1 -DMEM_USAGE=1 -DUSE_MLOCK=1 -DSCHED_GETCPU \
1212
-g -ggdb3 -fno-omit-frame-pointer
1313

1414
LOCAL_SRC_FILES := ../../src/iso_alloc.c ../../src/iso_alloc_printf.c ../../src/iso_alloc_random.c \

src/iso_alloc_util.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ INTERNAL_HIDDEN INLINE int _iso_getcpu(void) {
2222
: "=r"(a)
2323
: "r"(cpunodesegment));
2424
return (int) (a & 0xfff);
25+
#elif defined(__aarch64__)
26+
#if __APPLE__
27+
/* unlike other operating systems, the tpidr_el0 register on macOs
28+
* is unused data stored for the current thread is instead fetchable
29+
* from "tpidrro_el0".
30+
*/
31+
uintptr_t a;
32+
__asm__ volatile("mrs %x0, tpidrro_el0" : "=r"(a) :: "memory");
33+
return (int)((a & 0x8) - 1);
34+
#else
35+
/* TODO most likely different register/making on other platforms */
36+
return -1;
37+
#endif
2538
#else
2639
return -1;
2740
#endif

0 commit comments

Comments
 (0)