tsan_fd.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //===-- tsan_fd.h -----------------------------------------------*- C++ -*-===//
  2. //
  3. // This file is distributed under the University of Illinois Open Source
  4. // License. See LICENSE.TXT for details.
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // This file is a part of ThreadSanitizer (TSan), a race detector.
  9. //
  10. // This file handles synchronization via IO.
  11. // People use IO for synchronization along the lines of:
  12. //
  13. // int X;
  14. // int client_socket; // initialized elsewhere
  15. // int server_socket; // initialized elsewhere
  16. //
  17. // Thread 1:
  18. // X = 42;
  19. // send(client_socket, ...);
  20. //
  21. // Thread 2:
  22. // if (recv(server_socket, ...) > 0)
  23. // assert(X == 42);
  24. //
  25. // This file determines the scope of the file descriptor (pipe, socket,
  26. // all local files, etc) and executes acquire and release operations on
  27. // the scope as necessary. Some scopes are very fine grained (e.g. pipe
  28. // operations synchronize only with operations on the same pipe), while
  29. // others are corse-grained (e.g. all operations on local files synchronize
  30. // with each other).
  31. //===----------------------------------------------------------------------===//
  32. #ifndef TSAN_FD_H
  33. #define TSAN_FD_H
  34. #include "tsan_rtl.h"
  35. namespace __tsan {
  36. void FdInit();
  37. void FdAcquire(ThreadState *thr, uptr pc, int fd);
  38. void FdRelease(ThreadState *thr, uptr pc, int fd);
  39. void FdAccess(ThreadState *thr, uptr pc, int fd);
  40. void FdClose(ThreadState *thr, uptr pc, int fd);
  41. void FdFileCreate(ThreadState *thr, uptr pc, int fd);
  42. void FdDup(ThreadState *thr, uptr pc, int oldfd, int newfd);
  43. void FdPipeCreate(ThreadState *thr, uptr pc, int rfd, int wfd);
  44. void FdEventCreate(ThreadState *thr, uptr pc, int fd);
  45. void FdSignalCreate(ThreadState *thr, uptr pc, int fd);
  46. void FdInotifyCreate(ThreadState *thr, uptr pc, int fd);
  47. void FdPollCreate(ThreadState *thr, uptr pc, int fd);
  48. void FdSocketCreate(ThreadState *thr, uptr pc, int fd);
  49. void FdSocketAccept(ThreadState *thr, uptr pc, int fd, int newfd);
  50. void FdSocketConnecting(ThreadState *thr, uptr pc, int fd);
  51. void FdSocketConnect(ThreadState *thr, uptr pc, int fd);
  52. bool FdLocation(uptr addr, int *fd, int *tid, u32 *stack);
  53. void FdOnFork(ThreadState *thr, uptr pc);
  54. uptr File2addr(const char *path);
  55. uptr Dir2addr(const char *path);
  56. } // namespace __tsan
  57. #endif // TSAN_INTERFACE_H