|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* vim:set ts=4 sw=4 sts=4 ci et: */ |
|
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 descriptor to be ignored by poisoning IO interposer */ |
|
16 void MozillaRegisterDebugFD(int fd); |
|
17 |
|
18 /** Register file to be ignored by poisoning IO interposer */ |
|
19 void MozillaRegisterDebugFILE(FILE *f); |
|
20 |
|
21 /** Unregister file descriptor from being ignored by poisoning IO interposer */ |
|
22 void MozillaUnRegisterDebugFD(int fd); |
|
23 |
|
24 /** Unregister file from being ignored by poisoning IO interposer */ |
|
25 void MozillaUnRegisterDebugFILE(FILE *f); |
|
26 |
|
27 MOZ_END_EXTERN_C |
|
28 |
|
29 #if defined(XP_WIN) || defined(XP_MACOSX) |
|
30 |
|
31 #ifdef __cplusplus |
|
32 namespace mozilla { |
|
33 |
|
34 /** |
|
35 * Check if a file is registered as a debug file. |
|
36 */ |
|
37 bool IsDebugFile(intptr_t aFileID); |
|
38 |
|
39 /** |
|
40 * Initialize IO poisoning, this is only safe to do on the main-thread when no |
|
41 * other threads are running. |
|
42 * |
|
43 * Please, note that this probably has performance implications as all |
|
44 */ |
|
45 void InitPoisonIOInterposer(); |
|
46 |
|
47 #ifdef XP_MACOSX |
|
48 /** |
|
49 * Check that writes are dirty before reporting I/O (Mac OS X only) |
|
50 * This is necessary for late-write checks on Mac OS X, but reading the buffer |
|
51 * from file to see if we're writing dirty bits is expensive, so we don't want |
|
52 * to do this for everything else that uses |
|
53 */ |
|
54 void OnlyReportDirtyWrites(); |
|
55 #endif /* XP_MACOSX */ |
|
56 |
|
57 /** |
|
58 * Clear IO poisoning, this is only safe to do on the main-thread when no other |
|
59 * threads are running. |
|
60 */ |
|
61 void ClearPoisonIOInterposer(); |
|
62 |
|
63 } // namespace mozilla |
|
64 #endif /* __cplusplus */ |
|
65 |
|
66 #else /* XP_WIN || XP_MACOSX */ |
|
67 |
|
68 #ifdef __cplusplus |
|
69 namespace mozilla { |
|
70 inline bool IsDebugFile(intptr_t aFileID){ return true; } |
|
71 inline void InitPoisonIOInterposer(){} |
|
72 inline void ClearPoisonIOInterposer(){} |
|
73 #ifdef XP_MACOSX |
|
74 inline void OnlyReportDirtyWrites(){} |
|
75 #endif /* XP_MACOSX */ |
|
76 } // namespace mozilla |
|
77 #endif /* __cplusplus */ |
|
78 |
|
79 #endif /* XP_WIN || XP_MACOSX */ |
|
80 |
|
81 #endif // mozilla_PoisonIOInterposer_h |