Dmitry Vyukov | fb8ca81 | 2012-12-12 12:27:00 +0000 | [diff] [blame] | 1 | //===-- tsan_fd.h -----------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file is a part of ThreadSanitizer (TSan), a race detector. |
| 11 | // |
Dmitry Vyukov | 84cc1ca | 2012-12-12 12:45:07 +0000 | [diff] [blame] | 12 | // This file handles synchronization via IO. |
| 13 | // People use IO for synchronization along the lines of: |
| 14 | // |
| 15 | // int X; |
| 16 | // int client_socket; // initialized elsewhere |
| 17 | // int server_socket; // initialized elsewhere |
| 18 | // |
| 19 | // Thread 1: |
| 20 | // X = 42; |
| 21 | // send(client_socket, ...); |
| 22 | // |
| 23 | // Thread 2: |
| 24 | // if (recv(server_socket, ...) > 0) |
| 25 | // assert(X == 42); |
| 26 | // |
| 27 | // This file determines the scope of the file descriptor (pipe, socket, |
| 28 | // all local files, etc) and executes acquire and release operations on |
| 29 | // the scope as necessary. Some scopes are very fine grained (e.g. pipe |
| 30 | // operations synchronize only with operations on the same pipe), while |
| 31 | // others are corse-grained (e.g. all operations on local files synchronize |
| 32 | // with each other). |
Dmitry Vyukov | fb8ca81 | 2012-12-12 12:27:00 +0000 | [diff] [blame] | 33 | //===----------------------------------------------------------------------===// |
| 34 | #ifndef TSAN_FD_H |
| 35 | #define TSAN_FD_H |
| 36 | |
| 37 | #include "tsan_rtl.h" |
| 38 | |
| 39 | namespace __tsan { |
| 40 | |
| 41 | void FdInit(); |
| 42 | void FdAcquire(ThreadState *thr, uptr pc, int fd); |
| 43 | void FdRelease(ThreadState *thr, uptr pc, int fd); |
Dmitry Vyukov | a597258 | 2013-01-09 17:31:27 +0000 | [diff] [blame] | 44 | void FdAccess(ThreadState *thr, uptr pc, int fd); |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 45 | void FdClose(ThreadState *thr, uptr pc, int fd, bool write = true); |
Dmitry Vyukov | fb8ca81 | 2012-12-12 12:27:00 +0000 | [diff] [blame] | 46 | void FdFileCreate(ThreadState *thr, uptr pc, int fd); |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 47 | void FdDup(ThreadState *thr, uptr pc, int oldfd, int newfd, bool write); |
Dmitry Vyukov | fb8ca81 | 2012-12-12 12:27:00 +0000 | [diff] [blame] | 48 | void FdPipeCreate(ThreadState *thr, uptr pc, int rfd, int wfd); |
| 49 | void FdEventCreate(ThreadState *thr, uptr pc, int fd); |
Dmitry Vyukov | 45d4324 | 2012-12-18 12:35:31 +0000 | [diff] [blame] | 50 | void FdSignalCreate(ThreadState *thr, uptr pc, int fd); |
| 51 | void FdInotifyCreate(ThreadState *thr, uptr pc, int fd); |
Dmitry Vyukov | fb8ca81 | 2012-12-12 12:27:00 +0000 | [diff] [blame] | 52 | void FdPollCreate(ThreadState *thr, uptr pc, int fd); |
| 53 | void FdSocketCreate(ThreadState *thr, uptr pc, int fd); |
| 54 | void FdSocketAccept(ThreadState *thr, uptr pc, int fd, int newfd); |
Dmitry Vyukov | ed513f6 | 2012-12-14 20:01:58 +0000 | [diff] [blame] | 55 | void FdSocketConnecting(ThreadState *thr, uptr pc, int fd); |
Dmitry Vyukov | fb8ca81 | 2012-12-12 12:27:00 +0000 | [diff] [blame] | 56 | void FdSocketConnect(ThreadState *thr, uptr pc, int fd); |
Dmitry Vyukov | c2234cd | 2012-12-18 06:57:34 +0000 | [diff] [blame] | 57 | bool FdLocation(uptr addr, int *fd, int *tid, u32 *stack); |
Dmitry Vyukov | 4554b7a | 2012-12-18 14:44:44 +0000 | [diff] [blame] | 58 | void FdOnFork(ThreadState *thr, uptr pc); |
Dmitry Vyukov | fb8ca81 | 2012-12-12 12:27:00 +0000 | [diff] [blame] | 59 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 60 | uptr File2addr(const char *path); |
| 61 | uptr Dir2addr(const char *path); |
Dmitry Vyukov | fb8ca81 | 2012-12-12 12:27:00 +0000 | [diff] [blame] | 62 | |
| 63 | } // namespace __tsan |
| 64 | |
| 65 | #endif // TSAN_INTERFACE_H |