Skip to content

Commit 72dbcd2

Browse files
committed
Clean up for PR
1 parent 35b549e commit 72dbcd2

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,14 @@ TSAN_INTERCEPTOR(void*, memalign, uptr align, uptr sz) {
816816
#define TSAN_MAYBE_INTERCEPT_MEMALIGN
817817
#endif
818818

819-
#if !SANITIZER_APPLE || defined(__MAC_10_16)
819+
// aligned_alloc was introduced in macOS 10.15
820+
// Linking will fail when using an older SDK
821+
#if !SANITIZER_APPLE || defined(__MAC_10_15)
822+
// macOS 10.15 is greater than our minimal deployment target. To ensure we
823+
// generate a weak reference so the TSan dylib continues to work on older
824+
// systems, we need to forward declare the intercepted function as "weak
825+
// imports".
820826
SANITIZER_WEAK_IMPORT void *aligned_alloc(SIZE_T __alignment, SIZE_T __size);
821-
822827
TSAN_INTERCEPTOR(void*, aligned_alloc, uptr align, uptr sz) {
823828
if (in_symbolizer())
824829
return InternalAlloc(sz, nullptr, align);

compiler-rt/test/tsan/free_race_aligned_alloc.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
// RUN: %clang_tsan -O1 %s -o %t -undefined dynamic_lookup
2-
// RUN: %deflake %run %t | FileCheck %s
2+
// RUN: %deflake %run %t | FileCheck %s
33

44
#include "test.h"
55

66
#include <stdlib.h>
77

88
#if defined(__cplusplus) && (__cplusplus >= 201703L)
9-
#define HAVE_ALIGNED_ALLOC 1
9+
# define HAVE_ALIGNED_ALLOC 1
1010
#endif
1111

12-
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
12+
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
1313
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500
14-
#define HAVE_ALIGNED_ALLOC 0
14+
# define HAVE_ALIGNED_ALLOC 0
1515
#else
1616
#endif
1717

18-
1918
int *mem;
2019
pthread_mutex_t mtx;
2120

@@ -39,9 +38,9 @@ int main() {
3938

4039
barrier_init(&barrier, 2);
4140
#if HAVE_ALIGNED_ALLOC
42-
mem = (int*)aligned_alloc(8, 8);
41+
mem = (int *)aligned_alloc(8, 8);
4342
#else
44-
mem = (int*)malloc(8);
43+
mem = (int *)malloc(8);
4544
#endif
4645
pthread_mutex_init(&mtx, 0);
4746
pthread_t t;

0 commit comments

Comments
 (0)