mirror of
https://github.com/google/benchmark.git
synced 2024-11-29 00:34:42 +00:00
Enable zero as NULL warnings and fix all occurences
This commit is contained in:
parent
19464f7dab
commit
64ba272911
|
@ -38,8 +38,7 @@ add_cxx_compiler_flag(-Wextra)
|
||||||
add_cxx_compiler_flag(-Wshadow)
|
add_cxx_compiler_flag(-Wshadow)
|
||||||
add_cxx_compiler_flag(-Werror)
|
add_cxx_compiler_flag(-Werror)
|
||||||
add_cxx_compiler_flag(-pedantic-errors)
|
add_cxx_compiler_flag(-pedantic-errors)
|
||||||
# TODO(ericwf): enable this for g++
|
add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
|
||||||
#add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
|
|
||||||
# Release flags
|
# Release flags
|
||||||
add_cxx_compiler_flag(-fno-strict-aliasing RELEASE)
|
add_cxx_compiler_flag(-fno-strict-aliasing RELEASE)
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,8 @@ void Initialize(int* argc, const char** argv);
|
||||||
|
|
||||||
// Otherwise, run all benchmarks specified by the --benchmark_filter flag,
|
// Otherwise, run all benchmarks specified by the --benchmark_filter flag,
|
||||||
// and exit after running the benchmarks.
|
// and exit after running the benchmarks.
|
||||||
void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter = NULL);
|
void RunSpecifiedBenchmarks();
|
||||||
|
void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter);
|
||||||
|
|
||||||
// If this routine is called, peak memory allocation past this point in the
|
// If this routine is called, peak memory allocation past this point in the
|
||||||
// benchmark is reported at the end of the benchmark report line. (It is
|
// benchmark is reported at the end of the benchmark report line. (It is
|
||||||
|
@ -164,6 +165,19 @@ void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter = NULL);
|
||||||
namespace internal {
|
namespace internal {
|
||||||
class Benchmark;
|
class Benchmark;
|
||||||
class BenchmarkFamilies;
|
class BenchmarkFamilies;
|
||||||
|
|
||||||
|
template <class T> struct Voider {
|
||||||
|
typedef void type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class = void>
|
||||||
|
struct EnableIfString {};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct EnableIfString<T, typename Voider<typename T::basic_string>::type> {
|
||||||
|
typedef int type;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// State is passed to a running Benchmark and contains state for the
|
// State is passed to a running Benchmark and contains state for the
|
||||||
|
@ -279,7 +293,7 @@ public:
|
||||||
// as an injected class name in the case of std::string.
|
// as an injected class name in the case of std::string.
|
||||||
template <class StringType>
|
template <class StringType>
|
||||||
void SetLabel(StringType const & str,
|
void SetLabel(StringType const & str,
|
||||||
typename StringType::basic_string* = 0) {
|
typename internal::EnableIfString<StringType>::type = 1) {
|
||||||
this->SetLabel(str.c_str());
|
this->SetLabel(str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -898,6 +898,9 @@ void RunMatchingBenchmarks(const std::string& spec,
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
|
void RunSpecifiedBenchmarks() {
|
||||||
|
RunSpecifiedBenchmarks(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter) {
|
void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter) {
|
||||||
std::string spec = FLAGS_benchmark_filter;
|
std::string spec = FLAGS_benchmark_filter;
|
||||||
|
|
|
@ -303,7 +303,7 @@ static bool MyCPUUsageCPUTimeNsLocked(double* cputime) {
|
||||||
cputime_fd = -1;
|
cputime_fd = -1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
unsigned long long result = strtoull(buff, NULL, 0);
|
unsigned long long result = strtoull(buff, nullptr, 0);
|
||||||
if (result == (std::numeric_limits<unsigned long long>::max)()) {
|
if (result == (std::numeric_limits<unsigned long long>::max)()) {
|
||||||
close(cputime_fd);
|
close(cputime_fd);
|
||||||
cputime_fd = -1;
|
cputime_fd = -1;
|
||||||
|
|
|
@ -89,7 +89,7 @@ private:
|
||||||
|
|
||||||
WallTime Slow() const {
|
WallTime Slow() const {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, nullptr);
|
||||||
return tv.tv_sec + tv.tv_usec * 1e-6;
|
return tv.tv_sec + tv.tv_usec * 1e-6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue