Bug 1932613 - temporarily disable browser_ml_end_to_end.js for permanent failures...
[gecko.git] / xpcom / build / PoisonIOInterposer.h
blob3217027b9af98875db963a16586c44aeec698b9c
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_PoisonIOInterposer_h
8 #define mozilla_PoisonIOInterposer_h
10 #include "mozilla/Types.h"
11 #include <stdio.h>
13 #ifdef _WIN32
14 typedef void* platform_handle_t;
15 #else
16 typedef int platform_handle_t;
17 #endif
19 MOZ_BEGIN_EXTERN_C
21 /** Register file handle to be ignored by poisoning IO interposer. This function
22 * and the corresponding UnRegister function are necessary for exchange of
23 * handles between binaries not using the same CRT on Windows (which happens
24 * when one of them links the static CRT). In such cases, giving file
25 * descriptors or FILEs
26 * doesn't work because _get_osfhandle fails with "invalid parameter". */
27 void MozillaRegisterDebugHandle(platform_handle_t aHandle);
29 /** Register file descriptor to be ignored by poisoning IO interposer */
30 void MozillaRegisterDebugFD(int aFd);
32 /** Register file to be ignored by poisoning IO interposer */
33 void MozillaRegisterDebugFILE(FILE* aFile);
35 /** Unregister file handle from being ignored by poisoning IO interposer */
36 void MozillaUnRegisterDebugHandle(platform_handle_t aHandle);
38 /** Unregister file descriptor from being ignored by poisoning IO interposer */
39 void MozillaUnRegisterDebugFD(int aFd);
41 /** Unregister file from being ignored by poisoning IO interposer */
42 void MozillaUnRegisterDebugFILE(FILE* aFile);
44 MOZ_END_EXTERN_C
46 #if defined(XP_MACOSX) || defined(XP_WIN)
48 # ifdef __cplusplus
49 namespace mozilla {
51 /**
52 * Check if a file is registered as a debug file.
54 bool IsDebugFile(platform_handle_t aFileID);
56 /**
57 * Initialize IO poisoning, this is only safe to do on the main-thread when no
58 * other threads are running.
60 * Please, note that this probably has performance implications as all
62 void InitPoisonIOInterposer();
64 # ifdef XP_MACOSX
65 /**
66 * Check that writes are dirty before reporting I/O (Mac OS X only)
67 * This is necessary for late-write checks on Mac OS X, but reading the buffer
68 * from file to see if we're writing dirty bits is expensive, so we don't want
69 * to do this for everything else that uses
71 void OnlyReportDirtyWrites();
72 # endif /* XP_MACOSX */
74 /**
75 * Clear IO poisoning, this is only safe to do on the main-thread when no other
76 * threads are running.
77 * Never called! See bug 1647107.
79 void ClearPoisonIOInterposer();
81 } // namespace mozilla
82 # endif /* __cplusplus */
84 #else /* defined(XP_MACOSX) || defined(XP_WIN) */
86 # ifdef __cplusplus
87 namespace mozilla {
88 inline bool IsDebugFile(platform_handle_t aFileID) { return true; }
89 inline void InitPoisonIOInterposer() {}
90 inline void ClearPoisonIOInterposer() {}
91 # ifdef XP_MACOSX
92 inline void OnlyReportDirtyWrites() {}
93 # endif /* XP_MACOSX */
94 } // namespace mozilla
95 # endif /* __cplusplus */
97 #endif /* XP_WIN || XP_MACOSX */
99 #endif // mozilla_PoisonIOInterposer_h