blob: 64dc84f6edd6b10955de262c6ea8ceb6e12f6aa1 [file] [log] [blame]
Dmitry Vyukovfb8ca812012-12-12 12:27:00 +00001//===-- 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 Vyukov84cc1ca2012-12-12 12:45:07 +000012// 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 Vyukovfb8ca812012-12-12 12:27:00 +000033//===----------------------------------------------------------------------===//
34#ifndef TSAN_FD_H
35#define TSAN_FD_H
36
37#include "tsan_rtl.h"
38
39namespace __tsan {
40
41void FdInit();
42void FdAcquire(ThreadState *thr, uptr pc, int fd);
43void FdRelease(ThreadState *thr, uptr pc, int fd);
Dmitry Vyukova5972582013-01-09 17:31:27 +000044void FdAccess(ThreadState *thr, uptr pc, int fd);
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080045void FdClose(ThreadState *thr, uptr pc, int fd, bool write = true);
Dmitry Vyukovfb8ca812012-12-12 12:27:00 +000046void FdFileCreate(ThreadState *thr, uptr pc, int fd);
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080047void FdDup(ThreadState *thr, uptr pc, int oldfd, int newfd, bool write);
Dmitry Vyukovfb8ca812012-12-12 12:27:00 +000048void FdPipeCreate(ThreadState *thr, uptr pc, int rfd, int wfd);
49void FdEventCreate(ThreadState *thr, uptr pc, int fd);
Dmitry Vyukov45d43242012-12-18 12:35:31 +000050void FdSignalCreate(ThreadState *thr, uptr pc, int fd);
51void FdInotifyCreate(ThreadState *thr, uptr pc, int fd);
Dmitry Vyukovfb8ca812012-12-12 12:27:00 +000052void FdPollCreate(ThreadState *thr, uptr pc, int fd);
53void FdSocketCreate(ThreadState *thr, uptr pc, int fd);
54void FdSocketAccept(ThreadState *thr, uptr pc, int fd, int newfd);
Dmitry Vyukoved513f62012-12-14 20:01:58 +000055void FdSocketConnecting(ThreadState *thr, uptr pc, int fd);
Dmitry Vyukovfb8ca812012-12-12 12:27:00 +000056void FdSocketConnect(ThreadState *thr, uptr pc, int fd);
Dmitry Vyukovc2234cd2012-12-18 06:57:34 +000057bool FdLocation(uptr addr, int *fd, int *tid, u32 *stack);
Dmitry Vyukov4554b7a2012-12-18 14:44:44 +000058void FdOnFork(ThreadState *thr, uptr pc);
Dmitry Vyukovfb8ca812012-12-12 12:27:00 +000059
Stephen Hines2d1fdb22014-05-28 23:58:16 -070060uptr File2addr(const char *path);
61uptr Dir2addr(const char *path);
Dmitry Vyukovfb8ca812012-12-12 12:27:00 +000062
63} // namespace __tsan
64
65#endif // TSAN_INTERFACE_H