mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
e9d64cd221
clang's -Wmissing-prototypes option identifies global functions that can be made static (because they're only called from one compilation unit) or removed (if they're never called). The .cpp files defining these functions did not include the headers with the corresponding function prototypes used by other compilation units. Including a header file in its corresponding .cpp file can help catch mismatched declarations and definitions. xpcom/components/nsCategoryManager.cpp:637:6 [-Wmissing-prototypes] no previous prototype for function 'NS_CreateServicesFromCategory' xpcom/io/nsPipe3.cpp:1824:10 [-Wmissing-prototypes] no previous prototype for function 'nsPipeConstructor' xpcom/io/nsStringStream.cpp:475:10 [-Wmissing-prototypes] no previous prototype for function 'nsStringInputStreamConstructor' xpcom/threads/ThreadDelay.cpp:18:6 [-Wmissing-prototypes] no previous prototype for function 'DelayForChaosMode' Differential Revision: https://phabricator.services.mozilla.com/D23265 --HG-- extra : rebase_source : a2085a090394a5d3f5c319258b782a5d9f217751 extra : source : 18c3e569ff15987eb200c62eaa9f4943ff08cb25
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "ThreadDelay.h"
|
|
#include "mozilla/Assertions.h"
|
|
#include "mozilla/ChaosMode.h"
|
|
|
|
#if defined(XP_WIN)
|
|
# include <windows.h>
|
|
#else
|
|
# include <unistd.h>
|
|
#endif
|
|
|
|
namespace mozilla {
|
|
|
|
void DelayForChaosMode(ChaosFeature aFeature,
|
|
const uint32_t aMicrosecondLimit) {
|
|
if (!ChaosMode::isActive(aFeature)) {
|
|
return;
|
|
}
|
|
|
|
MOZ_ASSERT(aMicrosecondLimit <= 1000);
|
|
#if defined(XP_WIN)
|
|
// Windows doesn't support sleeping at less than millisecond resolution.
|
|
// We could spin here, or we could just sleep for one millisecond.
|
|
// Sleeping for a full millisecond causes heavy delays, so we don't do
|
|
// anything here for now until we have found a good way to sleep more
|
|
// precisely here.
|
|
#else
|
|
const uint32_t duration = ChaosMode::randomUint32LessThan(aMicrosecondLimit);
|
|
::usleep(duration);
|
|
#endif
|
|
}
|
|
|
|
} // namespace mozilla
|