michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim:set ts=4 sw=4 sts=4 ci et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_PoisonIOInterposer_h michael@0: #define mozilla_PoisonIOInterposer_h michael@0: michael@0: #include "mozilla/Types.h" michael@0: #include michael@0: michael@0: MOZ_BEGIN_EXTERN_C michael@0: michael@0: /** Register file descriptor to be ignored by poisoning IO interposer */ michael@0: void MozillaRegisterDebugFD(int fd); michael@0: michael@0: /** Register file to be ignored by poisoning IO interposer */ michael@0: void MozillaRegisterDebugFILE(FILE *f); michael@0: michael@0: /** Unregister file descriptor from being ignored by poisoning IO interposer */ michael@0: void MozillaUnRegisterDebugFD(int fd); michael@0: michael@0: /** Unregister file from being ignored by poisoning IO interposer */ michael@0: void MozillaUnRegisterDebugFILE(FILE *f); michael@0: michael@0: MOZ_END_EXTERN_C michael@0: michael@0: #if defined(XP_WIN) || defined(XP_MACOSX) michael@0: michael@0: #ifdef __cplusplus michael@0: namespace mozilla { michael@0: michael@0: /** michael@0: * Check if a file is registered as a debug file. michael@0: */ michael@0: bool IsDebugFile(intptr_t aFileID); michael@0: michael@0: /** michael@0: * Initialize IO poisoning, this is only safe to do on the main-thread when no michael@0: * other threads are running. michael@0: * michael@0: * Please, note that this probably has performance implications as all michael@0: */ michael@0: void InitPoisonIOInterposer(); michael@0: michael@0: #ifdef XP_MACOSX michael@0: /** michael@0: * Check that writes are dirty before reporting I/O (Mac OS X only) michael@0: * This is necessary for late-write checks on Mac OS X, but reading the buffer michael@0: * from file to see if we're writing dirty bits is expensive, so we don't want michael@0: * to do this for everything else that uses michael@0: */ michael@0: void OnlyReportDirtyWrites(); michael@0: #endif /* XP_MACOSX */ michael@0: michael@0: /** michael@0: * Clear IO poisoning, this is only safe to do on the main-thread when no other michael@0: * threads are running. michael@0: */ michael@0: void ClearPoisonIOInterposer(); michael@0: michael@0: } // namespace mozilla michael@0: #endif /* __cplusplus */ michael@0: michael@0: #else /* XP_WIN || XP_MACOSX */ michael@0: michael@0: #ifdef __cplusplus michael@0: namespace mozilla { michael@0: inline bool IsDebugFile(intptr_t aFileID){ return true; } michael@0: inline void InitPoisonIOInterposer(){} michael@0: inline void ClearPoisonIOInterposer(){} michael@0: #ifdef XP_MACOSX michael@0: inline void OnlyReportDirtyWrites(){} michael@0: #endif /* XP_MACOSX */ michael@0: } // namespace mozilla michael@0: #endif /* __cplusplus */ michael@0: michael@0: #endif /* XP_WIN || XP_MACOSX */ michael@0: michael@0: #endif // mozilla_PoisonIOInterposer_h