/work/obj-fuzz/dist/include/mozilla/PoisonIOInterposer.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_PoisonIOInterposer_h |
8 | | #define mozilla_PoisonIOInterposer_h |
9 | | |
10 | | #include "mozilla/Types.h" |
11 | | #include <stdio.h> |
12 | | |
13 | | MOZ_BEGIN_EXTERN_C |
14 | | |
15 | | /** Register file handle to be ignored by poisoning IO interposer. This function |
16 | | * and the corresponding UnRegister function are necessary for exchange of handles |
17 | | * between binaries not using the same CRT on Windows (which happens when one of |
18 | | * them links the static CRT). In such cases, giving file descriptors or FILEs |
19 | | * doesn't work because _get_osfhandle fails with "invalid parameter". */ |
20 | | void MozillaRegisterDebugHandle(intptr_t aHandle); |
21 | | |
22 | | /** Register file descriptor to be ignored by poisoning IO interposer */ |
23 | | void MozillaRegisterDebugFD(int aFd); |
24 | | |
25 | | /** Register file to be ignored by poisoning IO interposer */ |
26 | | void MozillaRegisterDebugFILE(FILE* aFile); |
27 | | |
28 | | /** Unregister file handle from being ignored by poisoning IO interposer */ |
29 | | void MozillaUnRegisterDebugHandle(intptr_t aHandle); |
30 | | |
31 | | /** Unregister file descriptor from being ignored by poisoning IO interposer */ |
32 | | void MozillaUnRegisterDebugFD(int aFd); |
33 | | |
34 | | /** Unregister file from being ignored by poisoning IO interposer */ |
35 | | void MozillaUnRegisterDebugFILE(FILE* aFile); |
36 | | |
37 | | MOZ_END_EXTERN_C |
38 | | |
39 | | #if defined(XP_MACOSX) || (defined(XP_WIN) && !defined(__MINGW32__)) |
40 | | |
41 | | #ifdef __cplusplus |
42 | | namespace mozilla { |
43 | | |
44 | | /** |
45 | | * Check if a file is registered as a debug file. |
46 | | */ |
47 | | bool IsDebugFile(intptr_t aFileID); |
48 | | |
49 | | /** |
50 | | * Initialize IO poisoning, this is only safe to do on the main-thread when no |
51 | | * other threads are running. |
52 | | * |
53 | | * Please, note that this probably has performance implications as all |
54 | | */ |
55 | | void InitPoisonIOInterposer(); |
56 | | |
57 | | #ifdef XP_MACOSX |
58 | | /** |
59 | | * Check that writes are dirty before reporting I/O (Mac OS X only) |
60 | | * This is necessary for late-write checks on Mac OS X, but reading the buffer |
61 | | * from file to see if we're writing dirty bits is expensive, so we don't want |
62 | | * to do this for everything else that uses |
63 | | */ |
64 | | void OnlyReportDirtyWrites(); |
65 | | #endif /* XP_MACOSX */ |
66 | | |
67 | | /** |
68 | | * Clear IO poisoning, this is only safe to do on the main-thread when no other |
69 | | * threads are running. |
70 | | */ |
71 | | void ClearPoisonIOInterposer(); |
72 | | |
73 | | } // namespace mozilla |
74 | | #endif /* __cplusplus */ |
75 | | |
76 | | #else /* defined(XP_MACOSX) || (defined(XP_WIN) && !defined(__MINGW32__)) */ |
77 | | |
78 | | #ifdef __cplusplus |
79 | | namespace mozilla { |
80 | 0 | inline bool IsDebugFile(intptr_t aFileID) { return true; } |
81 | 3 | inline void InitPoisonIOInterposer() {} |
82 | 0 | inline void ClearPoisonIOInterposer() {} |
83 | | #ifdef XP_MACOSX |
84 | | inline void OnlyReportDirtyWrites() {} |
85 | | #endif /* XP_MACOSX */ |
86 | | } // namespace mozilla |
87 | | #endif /* __cplusplus */ |
88 | | |
89 | | #endif /* XP_WIN || XP_MACOSX */ |
90 | | |
91 | | #endif // mozilla_PoisonIOInterposer_h |