tsan_dispatch_defs.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //===-- tsan_dispatch_defs.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. //===----------------------------------------------------------------------===//
  12. #ifndef TSAN_DISPATCH_DEFS_H
  13. #define TSAN_DISPATCH_DEFS_H
  14. #include "sanitizer_common/sanitizer_internal_defs.h"
  15. typedef struct dispatch_object_s {} *dispatch_object_t;
  16. #define DISPATCH_DECL(name) \
  17. typedef struct name##_s : public dispatch_object_s {} *name##_t
  18. DISPATCH_DECL(dispatch_queue);
  19. DISPATCH_DECL(dispatch_source);
  20. DISPATCH_DECL(dispatch_group);
  21. DISPATCH_DECL(dispatch_data);
  22. DISPATCH_DECL(dispatch_semaphore);
  23. DISPATCH_DECL(dispatch_io);
  24. typedef void (*dispatch_function_t)(void *arg);
  25. typedef void (^dispatch_block_t)(void);
  26. typedef void (^dispatch_io_handler_t)(bool done, dispatch_data_t data,
  27. int error);
  28. typedef long dispatch_once_t;
  29. typedef __sanitizer::u64 dispatch_time_t;
  30. typedef int dispatch_fd_t;
  31. typedef unsigned long dispatch_io_type_t;
  32. typedef unsigned long dispatch_io_close_flags_t;
  33. extern "C" {
  34. void *dispatch_get_context(dispatch_object_t object);
  35. void dispatch_retain(dispatch_object_t object);
  36. void dispatch_release(dispatch_object_t object);
  37. extern const dispatch_block_t _dispatch_data_destructor_free;
  38. extern const dispatch_block_t _dispatch_data_destructor_munmap;
  39. } // extern "C"
  40. #define DISPATCH_DATA_DESTRUCTOR_DEFAULT nullptr
  41. #define DISPATCH_DATA_DESTRUCTOR_FREE _dispatch_data_destructor_free
  42. #define DISPATCH_DATA_DESTRUCTOR_MUNMAP _dispatch_data_destructor_munmap
  43. #if __has_attribute(noescape)
  44. # define DISPATCH_NOESCAPE __attribute__((__noescape__))
  45. #else
  46. # define DISPATCH_NOESCAPE
  47. #endif
  48. #if SANITIZER_MAC
  49. # define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak_import))
  50. #else
  51. # define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak))
  52. #endif
  53. // Data types used in dispatch APIs
  54. typedef unsigned long size_t;
  55. typedef unsigned long uintptr_t;
  56. typedef __sanitizer::s64 off_t;
  57. typedef __sanitizer::u16 mode_t;
  58. typedef long long_t;
  59. #endif // TSAN_DISPATCH_DEFS_H