Kostya Serebryany | 4ad375f | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 1 | //===-- tsan_mman.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 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | #ifndef TSAN_MMAN_H |
| 14 | #define TSAN_MMAN_H |
| 15 | |
| 16 | #include "tsan_defs.h" |
| 17 | |
| 18 | namespace __tsan { |
| 19 | |
Dmitry Vyukov | 954fc8c | 2012-08-15 15:35:15 +0000 | [diff] [blame] | 20 | const uptr kDefaultAlignment = 16; |
| 21 | |
| 22 | void InitializeAllocator(); |
| 23 | void AlloctorThreadFinish(ThreadState *thr); |
Kostya Serebryany | 4ad375f | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 24 | |
| 25 | // For user allocations. |
Dmitry Vyukov | 954fc8c | 2012-08-15 15:35:15 +0000 | [diff] [blame] | 26 | void *user_alloc(ThreadState *thr, uptr pc, uptr sz, |
| 27 | uptr align = kDefaultAlignment); |
Kostya Serebryany | 4ad375f | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 28 | // Does not accept NULL. |
| 29 | void user_free(ThreadState *thr, uptr pc, void *p); |
| 30 | void *user_realloc(ThreadState *thr, uptr pc, void *p, uptr sz); |
| 31 | void *user_alloc_aligned(ThreadState *thr, uptr pc, uptr sz, uptr align); |
| 32 | // Given the pointer p into a valid allocated block, |
| 33 | // returns the descriptor of the block. |
| 34 | MBlock *user_mblock(ThreadState *thr, void *p); |
| 35 | |
| 36 | enum MBlockType { |
| 37 | MBlockScopedBuf, |
| 38 | MBlockString, |
| 39 | MBlockStackTrace, |
Dmitry Vyukov | 5bfac97 | 2012-07-16 16:44:47 +0000 | [diff] [blame] | 40 | MBlockShadowStack, |
Kostya Serebryany | 4ad375f | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 41 | MBlockSync, |
| 42 | MBlockClock, |
| 43 | MBlockThreadContex, |
Dmitry Vyukov | f6985e3 | 2012-05-22 14:34:43 +0000 | [diff] [blame] | 44 | MBlockDeadInfo, |
Kostya Serebryany | 4ad375f | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 45 | MBlockRacyStacks, |
| 46 | MBlockRacyAddresses, |
| 47 | MBlockAtExit, |
| 48 | MBlockFlag, |
| 49 | MBlockReport, |
| 50 | MBlockReportMop, |
| 51 | MBlockReportThread, |
| 52 | MBlockReportMutex, |
| 53 | MBlockReportLoc, |
| 54 | MBlockReportStack, |
| 55 | MBlockSuppression, |
| 56 | MBlockExpectRace, |
Dmitry Vyukov | 97c26bd | 2012-06-27 16:05:06 +0000 | [diff] [blame] | 57 | MBlockSignal, |
Kostya Serebryany | 4ad375f | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 58 | |
| 59 | // This must be the last. |
Alexey Samsonov | 046248c | 2012-09-13 11:54:41 +0000 | [diff] [blame^] | 60 | MBlockTypeCount |
Kostya Serebryany | 4ad375f | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | // For internal data structures. |
| 64 | void *internal_alloc(MBlockType typ, uptr sz); |
| 65 | void internal_free(void *p); |
| 66 | |
| 67 | template<typename T> |
| 68 | void DestroyAndFree(T *&p) { |
| 69 | p->~T(); |
| 70 | internal_free(p); |
| 71 | p = 0; |
| 72 | } |
| 73 | |
Kostya Serebryany | 4ad375f | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 74 | } // namespace __tsan |
| 75 | #endif // TSAN_MMAN_H |