1//===-- tsan_posix_util.h ---------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of ThreadSanitizer (TSan), a race detector.
10//
11// Test POSIX utils.
12//===----------------------------------------------------------------------===//
13#ifndef TSAN_POSIX_UTIL_H
14#define TSAN_POSIX_UTIL_H
15
16#include <pthread.h>
17
18#ifdef __APPLE__
19#define __interceptor_memcpy wrap_memcpy
20#define __interceptor_memset wrap_memset
21#define __interceptor_pthread_create wrap_pthread_create
22#define __interceptor_pthread_join wrap_pthread_join
23#define __interceptor_pthread_detach wrap_pthread_detach
24#define __interceptor_pthread_mutex_init wrap_pthread_mutex_init
25#define __interceptor_pthread_mutex_lock wrap_pthread_mutex_lock
26#define __interceptor_pthread_mutex_unlock wrap_pthread_mutex_unlock
27#define __interceptor_pthread_mutex_destroy wrap_pthread_mutex_destroy
28#define __interceptor_pthread_mutex_trylock wrap_pthread_mutex_trylock
29#define __interceptor_pthread_rwlock_init wrap_pthread_rwlock_init
30#define __interceptor_pthread_rwlock_destroy wrap_pthread_rwlock_destroy
31#define __interceptor_pthread_rwlock_trywrlock wrap_pthread_rwlock_trywrlock
32#define __interceptor_pthread_rwlock_wrlock wrap_pthread_rwlock_wrlock
33#define __interceptor_pthread_rwlock_unlock wrap_pthread_rwlock_unlock
34#define __interceptor_pthread_rwlock_rdlock wrap_pthread_rwlock_rdlock
35#define __interceptor_pthread_rwlock_tryrdlock wrap_pthread_rwlock_tryrdlock
36#define __interceptor_pthread_cond_init wrap_pthread_cond_init
37#define __interceptor_pthread_cond_signal wrap_pthread_cond_signal
38#define __interceptor_pthread_cond_broadcast wrap_pthread_cond_broadcast
39#define __interceptor_pthread_cond_wait wrap_pthread_cond_wait
40#define __interceptor_pthread_cond_destroy wrap_pthread_cond_destroy
41#endif
42
43extern "C" void *__interceptor_memcpy(void *, const void *, uptr);
44extern "C" void *__interceptor_memset(void *, int, uptr);
45extern "C" int __interceptor_pthread_create(pthread_t *thread,
46 const pthread_attr_t *attr,
47 void *(*start_routine)(void *),
48 void *arg);
49extern "C" int __interceptor_pthread_join(pthread_t thread, void **value_ptr);
50extern "C" int __interceptor_pthread_detach(pthread_t thread);
51
52extern "C" int __interceptor_pthread_mutex_init(
53 pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
54extern "C" int __interceptor_pthread_mutex_lock(pthread_mutex_t *mutex);
55extern "C" int __interceptor_pthread_mutex_unlock(pthread_mutex_t *mutex);
56extern "C" int __interceptor_pthread_mutex_destroy(pthread_mutex_t *mutex);
57extern "C" int __interceptor_pthread_mutex_trylock(pthread_mutex_t *mutex);
58
59extern "C" int __interceptor_pthread_rwlock_init(
60 pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr);
61extern "C" int __interceptor_pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
62extern "C" int __interceptor_pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
63extern "C" int __interceptor_pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
64extern "C" int __interceptor_pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
65extern "C" int __interceptor_pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
66extern "C" int __interceptor_pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
67
68extern "C" int __interceptor_pthread_cond_init(pthread_cond_t *cond,
69 const pthread_condattr_t *attr);
70extern "C" int __interceptor_pthread_cond_signal(pthread_cond_t *cond);
71extern "C" int __interceptor_pthread_cond_broadcast(pthread_cond_t *cond);
72extern "C" int __interceptor_pthread_cond_wait(pthread_cond_t *cond,
73 pthread_mutex_t *mutex);
74extern "C" int __interceptor_pthread_cond_destroy(pthread_cond_t *cond);
75
76#endif // #ifndef TSAN_POSIX_UTIL_H
77

source code of compiler-rt/lib/tsan/tests/rtl/tsan_posix_util.h