Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* vim:set ts=4 sw=4 sts=4 ci et: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_PoisonIOInterposer_h |
michael@0 | 8 | #define mozilla_PoisonIOInterposer_h |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Types.h" |
michael@0 | 11 | #include <stdio.h> |
michael@0 | 12 | |
michael@0 | 13 | MOZ_BEGIN_EXTERN_C |
michael@0 | 14 | |
michael@0 | 15 | /** Register file descriptor to be ignored by poisoning IO interposer */ |
michael@0 | 16 | void MozillaRegisterDebugFD(int fd); |
michael@0 | 17 | |
michael@0 | 18 | /** Register file to be ignored by poisoning IO interposer */ |
michael@0 | 19 | void MozillaRegisterDebugFILE(FILE *f); |
michael@0 | 20 | |
michael@0 | 21 | /** Unregister file descriptor from being ignored by poisoning IO interposer */ |
michael@0 | 22 | void MozillaUnRegisterDebugFD(int fd); |
michael@0 | 23 | |
michael@0 | 24 | /** Unregister file from being ignored by poisoning IO interposer */ |
michael@0 | 25 | void MozillaUnRegisterDebugFILE(FILE *f); |
michael@0 | 26 | |
michael@0 | 27 | MOZ_END_EXTERN_C |
michael@0 | 28 | |
michael@0 | 29 | #if defined(XP_WIN) || defined(XP_MACOSX) |
michael@0 | 30 | |
michael@0 | 31 | #ifdef __cplusplus |
michael@0 | 32 | namespace mozilla { |
michael@0 | 33 | |
michael@0 | 34 | /** |
michael@0 | 35 | * Check if a file is registered as a debug file. |
michael@0 | 36 | */ |
michael@0 | 37 | bool IsDebugFile(intptr_t aFileID); |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * Initialize IO poisoning, this is only safe to do on the main-thread when no |
michael@0 | 41 | * other threads are running. |
michael@0 | 42 | * |
michael@0 | 43 | * Please, note that this probably has performance implications as all |
michael@0 | 44 | */ |
michael@0 | 45 | void InitPoisonIOInterposer(); |
michael@0 | 46 | |
michael@0 | 47 | #ifdef XP_MACOSX |
michael@0 | 48 | /** |
michael@0 | 49 | * Check that writes are dirty before reporting I/O (Mac OS X only) |
michael@0 | 50 | * This is necessary for late-write checks on Mac OS X, but reading the buffer |
michael@0 | 51 | * from file to see if we're writing dirty bits is expensive, so we don't want |
michael@0 | 52 | * to do this for everything else that uses |
michael@0 | 53 | */ |
michael@0 | 54 | void OnlyReportDirtyWrites(); |
michael@0 | 55 | #endif /* XP_MACOSX */ |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * Clear IO poisoning, this is only safe to do on the main-thread when no other |
michael@0 | 59 | * threads are running. |
michael@0 | 60 | */ |
michael@0 | 61 | void ClearPoisonIOInterposer(); |
michael@0 | 62 | |
michael@0 | 63 | } // namespace mozilla |
michael@0 | 64 | #endif /* __cplusplus */ |
michael@0 | 65 | |
michael@0 | 66 | #else /* XP_WIN || XP_MACOSX */ |
michael@0 | 67 | |
michael@0 | 68 | #ifdef __cplusplus |
michael@0 | 69 | namespace mozilla { |
michael@0 | 70 | inline bool IsDebugFile(intptr_t aFileID){ return true; } |
michael@0 | 71 | inline void InitPoisonIOInterposer(){} |
michael@0 | 72 | inline void ClearPoisonIOInterposer(){} |
michael@0 | 73 | #ifdef XP_MACOSX |
michael@0 | 74 | inline void OnlyReportDirtyWrites(){} |
michael@0 | 75 | #endif /* XP_MACOSX */ |
michael@0 | 76 | } // namespace mozilla |
michael@0 | 77 | #endif /* __cplusplus */ |
michael@0 | 78 | |
michael@0 | 79 | #endif /* XP_WIN || XP_MACOSX */ |
michael@0 | 80 | |
michael@0 | 81 | #endif // mozilla_PoisonIOInterposer_h |