Skip to content

Commit d6c7090

Browse files
committed
Clean up for PR
1 parent 0c7fed9 commit d6c7090

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@
3333
# define SANITIZER_INTERFACE_ATTRIBUTE __declspec(dllimport)
3434
#else
3535
# define SANITIZER_INTERFACE_ATTRIBUTE __declspec(dllexport)
36-
#endif // SANITIZER_IMPORT_INTERFACE
36+
#endif
3737
# define SANITIZER_WEAK_ATTRIBUTE
38-
#define SANITIZER_WEAK_IMPORT
38+
# define SANITIZER_WEAK_IMPORT
3939
#elif SANITIZER_GO
4040
# define SANITIZER_INTERFACE_ATTRIBUTE
4141
# define SANITIZER_WEAK_ATTRIBUTE
42-
# define SANITIZER_WEAK_IMPORT
43-
#else // NOT SANITIZER_WINDOWS
42+
# define SANITIZER_WEAK_IMPORT
43+
#else
4444
# define SANITIZER_INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
4545
# define SANITIZER_WEAK_ATTRIBUTE __attribute__((weak))
46-
#if SANITIZER_APPLE
47-
# define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak_import))
48-
#else // NOT SANITIZER_APPLE
49-
# define SANITIZER_WEAK_IMPORT extern "C" SANITIZER_WEAK_ATTRIBUTE
50-
#endif // SANITIZER_APPLE
51-
#endif // SANITIZER_WINDOWS
46+
# if SANITIZER_APPLE
47+
# define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak_import))
48+
# else
49+
# define SANITIZER_WEAK_IMPORT extern "C" SANITIZER_WEAK_ATTRIBUTE
50+
# endif // SANITIZER_APPLE
51+
#endif // SANITIZER_WINDOWS
5252

5353
//--------------------------- WEAK FUNCTIONS ---------------------------------//
5454
// When working with weak functions, to simplify the code and make it more

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)