xpcom/build/PoisonIOInterposer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/build/PoisonIOInterposer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim:set ts=4 sw=4 sts=4 ci et: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_PoisonIOInterposer_h
    1.11 +#define mozilla_PoisonIOInterposer_h
    1.12 +
    1.13 +#include "mozilla/Types.h"
    1.14 +#include <stdio.h>
    1.15 +
    1.16 +MOZ_BEGIN_EXTERN_C
    1.17 +
    1.18 +/** Register file descriptor to be ignored by poisoning IO interposer */
    1.19 +void MozillaRegisterDebugFD(int fd);
    1.20 +
    1.21 +/** Register file to be ignored by poisoning IO interposer */
    1.22 +void MozillaRegisterDebugFILE(FILE *f);
    1.23 +
    1.24 +/** Unregister file descriptor from being ignored by poisoning IO interposer */
    1.25 +void MozillaUnRegisterDebugFD(int fd);
    1.26 +
    1.27 +/** Unregister file from being ignored by poisoning IO interposer */
    1.28 +void MozillaUnRegisterDebugFILE(FILE *f);
    1.29 +
    1.30 +MOZ_END_EXTERN_C
    1.31 +
    1.32 +#if defined(XP_WIN) || defined(XP_MACOSX)
    1.33 +
    1.34 +#ifdef __cplusplus
    1.35 +namespace mozilla {
    1.36 +
    1.37 +/**
    1.38 + * Check if a file is registered as a debug file.
    1.39 + */
    1.40 +bool IsDebugFile(intptr_t aFileID);
    1.41 +
    1.42 +/**
    1.43 + * Initialize IO poisoning, this is only safe to do on the main-thread when no
    1.44 + * other threads are running.
    1.45 + *
    1.46 + * Please, note that this probably has performance implications as all
    1.47 + */
    1.48 +void InitPoisonIOInterposer();
    1.49 +
    1.50 +#ifdef XP_MACOSX
    1.51 +/**
    1.52 + * Check that writes are dirty before reporting I/O (Mac OS X only)
    1.53 + * This is necessary for late-write checks on Mac OS X, but reading the buffer
    1.54 + * from file to see if we're writing dirty bits is expensive, so we don't want
    1.55 + * to do this for everything else that uses
    1.56 + */
    1.57 +void OnlyReportDirtyWrites();
    1.58 +#endif /* XP_MACOSX */
    1.59 +
    1.60 +/**
    1.61 + * Clear IO poisoning, this is only safe to do on the main-thread when no other
    1.62 + * threads are running.
    1.63 + */
    1.64 +void ClearPoisonIOInterposer();
    1.65 +
    1.66 +} // namespace mozilla
    1.67 +#endif /* __cplusplus */
    1.68 +
    1.69 +#else /* XP_WIN || XP_MACOSX */
    1.70 +
    1.71 +#ifdef __cplusplus
    1.72 +namespace mozilla {
    1.73 +inline bool IsDebugFile(intptr_t aFileID){ return true; }
    1.74 +inline void InitPoisonIOInterposer(){}
    1.75 +inline void ClearPoisonIOInterposer(){}
    1.76 +#ifdef XP_MACOSX
    1.77 +inline void OnlyReportDirtyWrites(){}
    1.78 +#endif /* XP_MACOSX */
    1.79 +} // namespace mozilla
    1.80 +#endif /* __cplusplus */
    1.81 +
    1.82 +#endif /* XP_WIN || XP_MACOSX */
    1.83 +
    1.84 +#endif // mozilla_PoisonIOInterposer_h

mercurial