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