Bug 1734063 [wpt PR 31107] - [GridNG] Fix rounding of distributed free space to flexi...
[gecko.git] / xpcom / build / PoisonIOInterposer.h
blob20adeb835b0685038c8a541c2525aba8b3fab229
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 MOZ_BEGIN_EXTERN_C
15 /** Register file handle to be ignored by poisoning IO interposer. This function
16 * and the corresponding UnRegister function are necessary for exchange of
17 * handles between binaries not using the same CRT on Windows (which happens
18 * when one of them links the static CRT). In such cases, giving file
19 * descriptors or FILEs
20 * doesn't work because _get_osfhandle fails with "invalid parameter". */
21 void MozillaRegisterDebugHandle(intptr_t aHandle);
23 /** Register file descriptor to be ignored by poisoning IO interposer */
24 void MozillaRegisterDebugFD(int aFd);
26 /** Register file to be ignored by poisoning IO interposer */
27 void MozillaRegisterDebugFILE(FILE* aFile);
29 /** Unregister file handle from being ignored by poisoning IO interposer */
30 void MozillaUnRegisterDebugHandle(intptr_t aHandle);
32 /** Unregister file descriptor from being ignored by poisoning IO interposer */
33 void MozillaUnRegisterDebugFD(int aFd);
35 /** Unregister file from being ignored by poisoning IO interposer */
36 void MozillaUnRegisterDebugFILE(FILE* aFile);
38 MOZ_END_EXTERN_C
40 #if defined(XP_MACOSX) || defined(XP_WIN)
42 # ifdef __cplusplus
43 namespace mozilla {
45 /**
46 * Check if a file is registered as a debug file.
48 bool IsDebugFile(intptr_t aFileID);
50 /**
51 * Initialize IO poisoning, this is only safe to do on the main-thread when no
52 * other threads are running.
54 * Please, note that this probably has performance implications as all
56 void InitPoisonIOInterposer();
58 # ifdef XP_MACOSX
59 /**
60 * Check that writes are dirty before reporting I/O (Mac OS X only)
61 * This is necessary for late-write checks on Mac OS X, but reading the buffer
62 * from file to see if we're writing dirty bits is expensive, so we don't want
63 * to do this for everything else that uses
65 void OnlyReportDirtyWrites();
66 # endif /* XP_MACOSX */
68 /**
69 * Clear IO poisoning, this is only safe to do on the main-thread when no other
70 * threads are running.
71 * Never called! See bug 1647107.
73 void ClearPoisonIOInterposer();
75 } // namespace mozilla
76 # endif /* __cplusplus */
78 #else /* defined(XP_MACOSX) || defined(XP_WIN) */
80 # ifdef __cplusplus
81 namespace mozilla {
82 inline bool IsDebugFile(intptr_t aFileID) { return true; }
83 inline void InitPoisonIOInterposer() {}
84 inline void ClearPoisonIOInterposer() {}
85 # ifdef XP_MACOSX
86 inline void OnlyReportDirtyWrites() {}
87 # endif /* XP_MACOSX */
88 } // namespace mozilla
89 # endif /* __cplusplus */
91 #endif /* XP_WIN || XP_MACOSX */
93 #endif // mozilla_PoisonIOInterposer_h