Path: blob/main/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_fd.h
35269 views
//===-- tsan_fd.h -----------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//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 elsewhere15// int server_socket; // initialized elsewhere16//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 on27// the scope as necessary. Some scopes are very fine grained (e.g. pipe28// operations synchronize only with operations on the same pipe), while29// others are corse-grained (e.g. all operations on local files synchronize30// with each other).31//===----------------------------------------------------------------------===//32#ifndef TSAN_FD_H33#define TSAN_FD_H3435#include "tsan_rtl.h"3637namespace __tsan {3839void FdInit();40void FdAcquire(ThreadState *thr, uptr pc, int fd);41void FdRelease(ThreadState *thr, uptr pc, int fd);42void FdAccess(ThreadState *thr, uptr pc, int fd);43void FdClose(ThreadState *thr, uptr pc, int fd, bool write = true);44void FdFileCreate(ThreadState *thr, uptr pc, int fd);45void FdDup(ThreadState *thr, uptr pc, int oldfd, int newfd, bool write);46void FdPipeCreate(ThreadState *thr, uptr pc, int rfd, int wfd);47void FdEventCreate(ThreadState *thr, uptr pc, int fd);48void FdSignalCreate(ThreadState *thr, uptr pc, int fd);49void FdInotifyCreate(ThreadState *thr, uptr pc, int fd);50void FdPollCreate(ThreadState *thr, uptr pc, int fd);51void FdPollAdd(ThreadState *thr, uptr pc, int epfd, int fd);52void FdSocketCreate(ThreadState *thr, uptr pc, int fd);53void FdSocketAccept(ThreadState *thr, uptr pc, int fd, int newfd);54void FdSocketConnecting(ThreadState *thr, uptr pc, int fd);55void FdSocketConnect(ThreadState *thr, uptr pc, int fd);56bool FdLocation(uptr addr, int *fd, Tid *tid, StackID *stack, bool *closed);57void FdOnFork(ThreadState *thr, uptr pc);5859uptr File2addr(const char *path);60uptr Dir2addr(const char *path);6162} // namespace __tsan6364#endif // TSAN_INTERFACE_H656667