Lines Matching refs:thr

50 static FdSync *allocsync(ThreadState *thr, uptr pc) {  in allocsync()  argument
51 FdSync *s = (FdSync*)user_alloc(thr, pc, sizeof(FdSync), kDefaultAlignment, in allocsync()
63 static void unref(ThreadState *thr, uptr pc, FdSync *s) { in unref() argument
69 user_free(thr, pc, s, false); in unref()
74 static FdDesc *fddesc(ThreadState *thr, uptr pc, int fd) { in fddesc() argument
82 void *p = user_alloc(thr, pc, size, kDefaultAlignment, false); in fddesc()
84 MemoryResetRange(thr, (uptr)&fddesc, (uptr)p, size); in fddesc()
88 user_free(thr, pc, p, false); in fddesc()
94 static void init(ThreadState *thr, uptr pc, int fd, FdSync *s) { in init() argument
95 FdDesc *d = fddesc(thr, pc, fd); in init()
99 unref(thr, pc, d->sync); in init()
103 unref(thr, pc, s); in init()
107 unref(thr, pc, s); in init()
110 d->creation_tid = thr->tid; in init()
111 d->creation_stack = CurrentStackId(thr, pc); in init()
113 MemoryRangeImitateWrite(thr, pc, (uptr)d, 8); in init()
122 void FdOnFork(ThreadState *thr, uptr pc) { in FdOnFork() argument
132 MemoryResetRange(thr, pc, (uptr)d, 8); in FdOnFork()
154 void FdAcquire(ThreadState *thr, uptr pc, int fd) { in FdAcquire() argument
157 FdDesc *d = fddesc(thr, pc, fd); in FdAcquire()
159 DPrintf("#%d: FdAcquire(%d) -> %p\n", thr->tid, fd, s); in FdAcquire()
160 MemoryRead(thr, pc, (uptr)d, kSizeLog8); in FdAcquire()
162 Acquire(thr, pc, (uptr)s); in FdAcquire()
165 void FdRelease(ThreadState *thr, uptr pc, int fd) { in FdRelease() argument
168 FdDesc *d = fddesc(thr, pc, fd); in FdRelease()
170 DPrintf("#%d: FdRelease(%d) -> %p\n", thr->tid, fd, s); in FdRelease()
171 MemoryRead(thr, pc, (uptr)d, kSizeLog8); in FdRelease()
173 Release(thr, pc, (uptr)s); in FdRelease()
176 void FdAccess(ThreadState *thr, uptr pc, int fd) { in FdAccess() argument
177 DPrintf("#%d: FdAccess(%d)\n", thr->tid, fd); in FdAccess()
180 FdDesc *d = fddesc(thr, pc, fd); in FdAccess()
181 MemoryRead(thr, pc, (uptr)d, kSizeLog8); in FdAccess()
184 void FdClose(ThreadState *thr, uptr pc, int fd) { in FdClose() argument
185 DPrintf("#%d: FdClose(%d)\n", thr->tid, fd); in FdClose()
188 FdDesc *d = fddesc(thr, pc, fd); in FdClose()
190 MemoryWrite(thr, pc, (uptr)d, kSizeLog8); in FdClose()
193 MemoryResetRange(thr, pc, (uptr)d, 8); in FdClose()
194 unref(thr, pc, d->sync); in FdClose()
200 void FdFileCreate(ThreadState *thr, uptr pc, int fd) { in FdFileCreate() argument
201 DPrintf("#%d: FdFileCreate(%d)\n", thr->tid, fd); in FdFileCreate()
204 init(thr, pc, fd, &fdctx.filesync); in FdFileCreate()
207 void FdDup(ThreadState *thr, uptr pc, int oldfd, int newfd) { in FdDup() argument
208 DPrintf("#%d: FdDup(%d, %d)\n", thr->tid, oldfd, newfd); in FdDup()
212 FdDesc *od = fddesc(thr, pc, oldfd); in FdDup()
213 MemoryRead(thr, pc, (uptr)od, kSizeLog8); in FdDup()
214 FdClose(thr, pc, newfd); in FdDup()
215 init(thr, pc, newfd, ref(od->sync)); in FdDup()
218 void FdPipeCreate(ThreadState *thr, uptr pc, int rfd, int wfd) { in FdPipeCreate() argument
219 DPrintf("#%d: FdCreatePipe(%d, %d)\n", thr->tid, rfd, wfd); in FdPipeCreate()
220 FdSync *s = allocsync(thr, pc); in FdPipeCreate()
221 init(thr, pc, rfd, ref(s)); in FdPipeCreate()
222 init(thr, pc, wfd, ref(s)); in FdPipeCreate()
223 unref(thr, pc, s); in FdPipeCreate()
226 void FdEventCreate(ThreadState *thr, uptr pc, int fd) { in FdEventCreate() argument
227 DPrintf("#%d: FdEventCreate(%d)\n", thr->tid, fd); in FdEventCreate()
230 init(thr, pc, fd, allocsync(thr, pc)); in FdEventCreate()
233 void FdSignalCreate(ThreadState *thr, uptr pc, int fd) { in FdSignalCreate() argument
234 DPrintf("#%d: FdSignalCreate(%d)\n", thr->tid, fd); in FdSignalCreate()
237 init(thr, pc, fd, 0); in FdSignalCreate()
240 void FdInotifyCreate(ThreadState *thr, uptr pc, int fd) { in FdInotifyCreate() argument
241 DPrintf("#%d: FdInotifyCreate(%d)\n", thr->tid, fd); in FdInotifyCreate()
244 init(thr, pc, fd, 0); in FdInotifyCreate()
247 void FdPollCreate(ThreadState *thr, uptr pc, int fd) { in FdPollCreate() argument
248 DPrintf("#%d: FdPollCreate(%d)\n", thr->tid, fd); in FdPollCreate()
251 init(thr, pc, fd, allocsync(thr, pc)); in FdPollCreate()
254 void FdSocketCreate(ThreadState *thr, uptr pc, int fd) { in FdSocketCreate() argument
255 DPrintf("#%d: FdSocketCreate(%d)\n", thr->tid, fd); in FdSocketCreate()
259 init(thr, pc, fd, &fdctx.socksync); in FdSocketCreate()
262 void FdSocketAccept(ThreadState *thr, uptr pc, int fd, int newfd) { in FdSocketAccept() argument
263 DPrintf("#%d: FdSocketAccept(%d, %d)\n", thr->tid, fd, newfd); in FdSocketAccept()
267 Acquire(thr, pc, (uptr)&fdctx.connectsync); in FdSocketAccept()
268 init(thr, pc, newfd, &fdctx.socksync); in FdSocketAccept()
271 void FdSocketConnecting(ThreadState *thr, uptr pc, int fd) { in FdSocketConnecting() argument
272 DPrintf("#%d: FdSocketConnecting(%d)\n", thr->tid, fd); in FdSocketConnecting()
276 Release(thr, pc, (uptr)&fdctx.connectsync); in FdSocketConnecting()
279 void FdSocketConnect(ThreadState *thr, uptr pc, int fd) { in FdSocketConnect() argument
280 DPrintf("#%d: FdSocketConnect(%d)\n", thr->tid, fd); in FdSocketConnect()
283 init(thr, pc, fd, &fdctx.socksync); in FdSocketConnect()