xref: /freebsd-src/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_dispatch_defs.h (revision 7a6dacaca14b62ca4b74406814becb87a3fefac0)
10b57cec5SDimitry Andric //===-- tsan_dispatch_defs.h ------------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file is a part of ThreadSanitizer (TSan), a race detector.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric #ifndef TSAN_DISPATCH_DEFS_H
130b57cec5SDimitry Andric #define TSAN_DISPATCH_DEFS_H
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric #include "sanitizer_common/sanitizer_internal_defs.h"
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric typedef struct dispatch_object_s {} *dispatch_object_t;
180b57cec5SDimitry Andric 
190b57cec5SDimitry Andric #define DISPATCH_DECL(name) \
200b57cec5SDimitry Andric   typedef struct name##_s : public dispatch_object_s {} *name##_t
210b57cec5SDimitry Andric 
220b57cec5SDimitry Andric DISPATCH_DECL(dispatch_queue);
230b57cec5SDimitry Andric DISPATCH_DECL(dispatch_source);
240b57cec5SDimitry Andric DISPATCH_DECL(dispatch_group);
250b57cec5SDimitry Andric DISPATCH_DECL(dispatch_data);
260b57cec5SDimitry Andric DISPATCH_DECL(dispatch_semaphore);
270b57cec5SDimitry Andric DISPATCH_DECL(dispatch_io);
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric typedef void (*dispatch_function_t)(void *arg);
300b57cec5SDimitry Andric typedef void (^dispatch_block_t)(void);
310b57cec5SDimitry Andric typedef void (^dispatch_io_handler_t)(bool done, dispatch_data_t data,
320b57cec5SDimitry Andric                                       int error);
330b57cec5SDimitry Andric 
3468d75effSDimitry Andric typedef long dispatch_once_t;
350b57cec5SDimitry Andric typedef __sanitizer::u64 dispatch_time_t;
3668d75effSDimitry Andric typedef int dispatch_fd_t;
3768d75effSDimitry Andric typedef unsigned long dispatch_io_type_t;
3868d75effSDimitry Andric typedef unsigned long dispatch_io_close_flags_t;
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric extern "C" {
410b57cec5SDimitry Andric void *dispatch_get_context(dispatch_object_t object);
420b57cec5SDimitry Andric void dispatch_retain(dispatch_object_t object);
430b57cec5SDimitry Andric void dispatch_release(dispatch_object_t object);
440b57cec5SDimitry Andric 
450b57cec5SDimitry Andric extern const dispatch_block_t _dispatch_data_destructor_free;
460b57cec5SDimitry Andric extern const dispatch_block_t _dispatch_data_destructor_munmap;
470b57cec5SDimitry Andric } // extern "C"
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric #define DISPATCH_DATA_DESTRUCTOR_DEFAULT nullptr
500b57cec5SDimitry Andric #define DISPATCH_DATA_DESTRUCTOR_FREE    _dispatch_data_destructor_free
510b57cec5SDimitry Andric #define DISPATCH_DATA_DESTRUCTOR_MUNMAP  _dispatch_data_destructor_munmap
520b57cec5SDimitry Andric 
530b57cec5SDimitry Andric #if __has_attribute(noescape)
540b57cec5SDimitry Andric # define DISPATCH_NOESCAPE __attribute__((__noescape__))
550b57cec5SDimitry Andric #else
560b57cec5SDimitry Andric # define DISPATCH_NOESCAPE
570b57cec5SDimitry Andric #endif
58*e8d8bef9SDimitry Andric 
590b57cec5SDimitry Andric // Data types used in dispatch APIs
6068d75effSDimitry Andric typedef unsigned long size_t;
6168d75effSDimitry Andric typedef unsigned long uintptr_t;
620b57cec5SDimitry Andric typedef __sanitizer::s64 off_t;
630b57cec5SDimitry Andric typedef __sanitizer::u16 mode_t;
6468d75effSDimitry Andric typedef long long_t;
650b57cec5SDimitry Andric 
660b57cec5SDimitry Andric #endif  // TSAN_DISPATCH_DEFS_H
67