Skip to content

Commit 82cd900

Browse files
committed
make macOS interposes compile for older macOS versions (by @Noxybot, PR #1028)
1 parent c1249a4 commit 82cd900

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/alloc-override.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,20 @@ typedef void* mi_nothrow_t;
7171
#define MI_INTERPOSE_FUN(oldfun,newfun) { (const void*)&newfun, (const void*)&oldfun }
7272
#define MI_INTERPOSE_MI(fun) MI_INTERPOSE_FUN(fun,mi_##fun)
7373

74-
__attribute__((used)) static struct mi_interpose_s _mi_interposes[] __attribute__((section("__DATA, __interpose"))) =
74+
#define MI_INTERPOSE_DECLS(name) __attribute__((used)) static struct mi_interpose_s name[] __attribute__((section("__DATA, __interpose")))
75+
76+
MI_INTERPOSE_DECLS(_mi_interposes) =
7577
{
7678
MI_INTERPOSE_MI(malloc),
7779
MI_INTERPOSE_MI(calloc),
7880
MI_INTERPOSE_MI(realloc),
7981
MI_INTERPOSE_MI(strdup),
80-
#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
81-
MI_INTERPOSE_MI(strndup),
82-
#endif
8382
MI_INTERPOSE_MI(realpath),
8483
MI_INTERPOSE_MI(posix_memalign),
8584
MI_INTERPOSE_MI(reallocf),
8685
MI_INTERPOSE_MI(valloc),
8786
MI_INTERPOSE_FUN(malloc_size,mi_malloc_size_checked),
8887
MI_INTERPOSE_MI(malloc_good_size),
89-
#if defined(MAC_OS_X_VERSION_10_15) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15
90-
MI_INTERPOSE_MI(aligned_alloc),
91-
#endif
9288
#ifdef MI_OSX_ZONE
9389
// we interpose malloc_default_zone in alloc-override-osx.c so we can use mi_free safely
9490
MI_INTERPOSE_MI(free),
@@ -99,6 +95,12 @@ typedef void* mi_nothrow_t;
9995
MI_INTERPOSE_FUN(vfree,mi_cfree),
10096
#endif
10197
};
98+
MI_INTERPOSE_DECLS(_mi_interposes_10_7) __OSX_AVAILABLE(10.7) = {
99+
MI_INTERPOSE_MI(strndup),
100+
};
101+
MI_INTERPOSE_DECLS(_mi_interposes_10_15) __OSX_AVAILABLE(10.15) = {
102+
MI_INTERPOSE_MI(aligned_alloc),
103+
};
102104

103105
#ifdef __cplusplus
104106
extern "C" {

0 commit comments

Comments
 (0)