Merge "Adjust test to let it pass on libhoudini."
diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index 20742bd..6f2651e 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -16,10 +16,6 @@
LOCAL_PATH := $(call my-dir)
-# -----------------------------------------------------------------------------
-# Benchmarks library, usable by projects outside this directory.
-# -----------------------------------------------------------------------------
-
benchmark_cflags := \
-O2 \
-fno-builtin \
@@ -30,38 +26,6 @@
benchmark_cppflags := \
-benchmarklib_src_files := \
- Benchmark.cpp \
- utils.cpp \
- main.cpp \
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbenchmark
-LOCAL_CFLAGS := $(benchmark_cflags)
-LOCAL_CPPFLAGS := $(benchmark_cppflags)
-LOCAL_SRC_FILES := $(benchmarklib_src_files)
-LOCAL_C_INCLUDES := $(benchmark_c_includes)
-LOCAL_STATIC_LIBRARIES := libbase
-include $(BUILD_STATIC_LIBRARY)
-
-# Only supported on linux systems.
-ifeq ($(HOST_OS),linux)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbenchmark
-LOCAL_CFLAGS := $(benchmark_cflags)
-LOCAL_CPPFLAGS := $(benchmark_cppflags)
-LOCAL_SRC_FILES := $(benchmarklib_src_files)
-LOCAL_C_INCLUDES := $(benchmark_c_includes)
-LOCAL_MULTILIB := both
-LOCAL_STATIC_LIBRARIES := libbase
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-endif
-
-# -----------------------------------------------------------------------------
-# Benchmarks.
-# -----------------------------------------------------------------------------
benchmark_src_files := \
math_benchmark.cpp \
property_benchmark.cpp \
@@ -83,8 +47,7 @@
LOCAL_CFLAGS := $(benchmark_cflags)
LOCAL_CPPFLAGS := $(benchmark_cppflags)
LOCAL_SRC_FILES := $(benchmark_src_files)
-LOCAL_STATIC_LIBRARIES := libbenchmark libbase
-include $(BUILD_EXECUTABLE)
+include $(BUILD_NATIVE_BENCHMARK)
# We don't build a static benchmark executable because it's not usually
# useful. If you're trying to run the current benchmarks on an older
@@ -105,7 +68,8 @@
LOCAL_CPPFLAGS := $(benchmark_cppflags)
LOCAL_LDFLAGS := -lrt
LOCAL_SRC_FILES := $(benchmark_src_files)
-LOCAL_STATIC_LIBRARIES := libbenchmark libbase
+LOCAL_STATIC_LIBRARIES := libgoogle-benchmark
+# TODO: BUILD_HOST_NATIVE_BENCHMARK
include $(BUILD_HOST_EXECUTABLE)
endif
diff --git a/benchmarks/Benchmark.cpp b/benchmarks/Benchmark.cpp
deleted file mode 100644
index a7ab682..0000000
--- a/benchmarks/Benchmark.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <inttypes.h>
-#include <regex.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <time.h>
-
-#include <string>
-#include <vector>
-
-#include <android-base/stringprintf.h>
-
-#include <benchmark/Benchmark.h>
-
-#include "utils.h"
-
-namespace testing {
-
-static uint64_t NanoTime() {
- struct timespec t;
- t.tv_sec = t.tv_nsec = 0;
- clock_gettime(CLOCK_MONOTONIC, &t);
- return static_cast<uint64_t>(t.tv_sec) * 1000000000LL + t.tv_nsec;
-}
-
-bool Benchmark::header_printed_;
-
-std::vector<Benchmark*>& Benchmark::List() {
- static std::vector<Benchmark*> list;
- return list;
-}
-
-int Benchmark::MaxNameColumnWidth() {
- size_t max = 20;
- for (auto& benchmark : List()) {
- max = std::max(max, benchmark->NameColumnWidth());
- }
- return static_cast<int>(max);
-}
-
-size_t Benchmark::RunAll(std::vector<regex_t*>& regs) {
- size_t benchmarks_run = 0;
- header_printed_ = false;
- for (auto& benchmark : List()) {
- benchmarks_run += benchmark->RunAllArgs(regs);
- }
- return benchmarks_run;
-}
-
-void Benchmark::PrintHeader() {
- if (!header_printed_) {
- printf("%-*s %10s %10s\n", MaxNameColumnWidth(), "", "iterations", "ns/op");
- header_printed_ = true;
- }
-}
-
-template <typename T>
-bool BenchmarkT<T>::ShouldRun(std::vector<regex_t*>& regs, T arg) {
- if (regs.empty()) {
- return true;
- }
-
- for (const auto& re : regs) {
- if (regexec(re, GetNameStr(arg).c_str(), 0, NULL, 0) != REG_NOMATCH) {
- return true;
- }
- }
- return false;
-}
-
-void Benchmark::StopBenchmarkTiming() {
- if (start_time_ns_ != 0) {
- total_time_ns_ += NanoTime() - start_time_ns_;
- }
- start_time_ns_ = 0;
-}
-
-void Benchmark::StartBenchmarkTiming() {
- if (start_time_ns_ == 0) {
- start_time_ns_ = NanoTime();
- }
-}
-
-std::string BenchmarkWithoutArg::GetNameStr(void*) {
- return Name();
-}
-
-template <>
-std::string BenchmarkWithArg<int>::GetNameStr(int arg) {
- return Name() + "/" + PrettyInt(arg, 2);
-}
-
-template <>
-std::string BenchmarkWithArg<double>::GetNameStr(double arg) {
- return Name() + "/" + android::base::StringPrintf("%0.6f", arg);
-}
-
-template<typename T>
-void BenchmarkT<T>::RunWithArg(T arg) {
- int new_iterations = 1;
- int iterations;
- while (new_iterations < 1e8) {
- bytes_processed_ = 0;
- total_time_ns_ = 0;
- start_time_ns_ = 0;
-
- iterations = new_iterations;
- RunIterations(iterations, arg);
- if (total_time_ns_ >= 1e9) {
- break;
- }
-
- if (total_time_ns_/iterations == 0) {
- new_iterations = 1e9;
- } else {
- new_iterations = 1e9/ (total_time_ns_/iterations);
- }
- new_iterations = std::max(iterations + 1,
- std::min(new_iterations + new_iterations/2, 100*iterations));
-
- new_iterations = Round(new_iterations);
- }
-
- printf("%-*s %10s %10" PRId64, MaxNameColumnWidth(), GetNameStr(arg).c_str(),
- PrettyInt(iterations, 10).c_str(), total_time_ns_/iterations);
-
- if (total_time_ns_ > 0 && bytes_processed_ > 0) {
- double gib_processed = static_cast<double>(bytes_processed_)/1e9;
- double seconds = static_cast<double>(total_time_ns_)/1e9;
- printf(" %8.3f GiB/s", gib_processed/seconds);
- }
- printf("\n");
- fflush(stdout);
-}
-
-template class BenchmarkT<int>;
-template class BenchmarkT<double>;
-template class BenchmarkT<void*>;
-
-template class BenchmarkWithArg<int>;
-template class BenchmarkWithArg<double>;
-
-} // namespace testing
diff --git a/benchmarks/benchmark/Benchmark.h b/benchmarks/benchmark/Benchmark.h
deleted file mode 100644
index ae5c1a2..0000000
--- a/benchmarks/benchmark/Benchmark.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef BENCHMARKS_BENCHMARK_H_
-#define BENCHMARKS_BENCHMARK_H_
-
-#include <regex.h>
-#include <stdint.h>
-
-#include <string>
-#include <vector>
-
-namespace testing {
-
-class Benchmark {
-public:
- Benchmark() {
- List().push_back(this);
- }
- virtual ~Benchmark() {}
-
- virtual std::string Name() = 0;
-
- virtual size_t RunAllArgs(std::vector<regex_t*>&) = 0;
-
- void SetBenchmarkBytesProcessed(uint64_t bytes) { bytes_processed_ += bytes; }
- void StopBenchmarkTiming();
- void StartBenchmarkTiming();
-
- // Run all of the benchmarks that have registered.
- static size_t RunAll(std::vector<regex_t*>&);
-
- static std::vector<Benchmark*>& List();
-
- static int MaxNameColumnWidth();
-
-protected:
- virtual size_t NameColumnWidth() = 0;
-
- uint64_t bytes_processed_;
- uint64_t total_time_ns_;
- uint64_t start_time_ns_;
-
- static bool header_printed_;
-
- static void PrintHeader();
-};
-
-template <typename T>
-class BenchmarkT : public Benchmark {
-public:
- BenchmarkT() {}
- virtual ~BenchmarkT() {}
-
-protected:
- bool ShouldRun(std::vector<regex_t*>&, T arg);
- void RunWithArg(T arg);
- virtual void RunIterations(int, T) = 0;
- virtual std::string GetNameStr(T) = 0;
-};
-
-class BenchmarkWithoutArg : public BenchmarkT<void*> {
-public:
- BenchmarkWithoutArg() {}
- virtual ~BenchmarkWithoutArg() {}
-
-protected:
- virtual size_t RunAllArgs(std::vector<regex_t*>& regs) override {
- size_t benchmarks_run = 0;
- if (BenchmarkT<void*>::ShouldRun(regs, nullptr)) {
- PrintHeader();
- RunWithArg(nullptr);
- benchmarks_run++;
- }
- return benchmarks_run;
- }
-
- virtual void RunIterations(int iters, void*) override {
- Run(iters);
- }
-
- virtual void Run(int) = 0;
-
- virtual size_t NameColumnWidth() override {
- return Name().size();
- }
-
- virtual std::string GetNameStr(void *) override;
-};
-
-template<typename T>
-class BenchmarkWithArg : public BenchmarkT<T> {
-public:
- BenchmarkWithArg() {}
- virtual ~BenchmarkWithArg() {}
-
- BenchmarkWithArg* Arg(T arg) {
- args_.push_back(arg);
- return this;
- }
-
-protected:
- virtual size_t NameColumnWidth() override {
- size_t max = 0;
- for (const auto& arg : args_) {
- max = std::max(max, GetNameStr(arg).size());
- }
- return max;
- }
-
- std::string GetNameStr(T arg) override;
-
- virtual size_t RunAllArgs(std::vector<regex_t*>& regs) override {
- size_t benchmarks_run = 0;
- for (T& arg : args_) {
- if (BenchmarkT<T>::ShouldRun(regs, arg)) {
- Benchmark::PrintHeader();
- BenchmarkT<T>::RunWithArg(arg);
- benchmarks_run++;
- }
- }
- return benchmarks_run;
- }
-
- virtual void RunIterations(int iters, T arg) override {
- Run(iters, arg);
- }
-
- virtual void Run(int iters, T arg) = 0;
-
-private:
- std::vector<T> args_;
-};
-
-} // namespace testing
-
-#define BENCHMARK_START(f, super_class) \
- class f : public super_class { \
- public: \
- f() {} \
- virtual ~f() {} \
- virtual std::string Name() override { return #f; } \
-
-#define BENCHMARK_NO_ARG(f) \
- BENCHMARK_START(f, ::testing::BenchmarkWithoutArg) \
- virtual void Run(int) override; \
- }; \
- static ::testing::Benchmark* __benchmark_##f = new f()
-
-#define BENCHMARK_WITH_ARG(f, arg_type) \
- BENCHMARK_START(f, ::testing::BenchmarkWithArg<arg_type>) \
- virtual void Run(int, arg_type) override; \
- }; \
- static ::testing::BenchmarkWithArg<arg_type>* __benchmark_##f = (new f())
-
-#endif // BENCHMARKS_BENCHMARK_H_
diff --git a/benchmarks/main.cpp b/benchmarks/main.cpp
deleted file mode 100644
index 5bce479..0000000
--- a/benchmarks/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <regex.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <vector>
-
-#include <benchmark/Benchmark.h>
-
-int main(int argc, char* argv[]) {
- if (::testing::Benchmark::List().empty()) {
- fprintf(stderr, "No benchmarks registered!\n");
- exit(EXIT_FAILURE);
- }
-
- std::vector<regex_t*> regs;
- for (int i = 1; i < argc; i++) {
- regex_t* re = new regex_t;
- int errcode = regcomp(re, argv[i], 0);
- if (errcode != 0) {
- size_t errbuf_size = regerror(errcode, re, NULL, 0);
- if (errbuf_size > 0) {
- char* errbuf = new char[errbuf_size];
- regerror(errcode, re, errbuf, errbuf_size);
- fprintf(stderr, "Couldn't compile \"%s\" as a regular expression: %s\n",
- argv[i], errbuf);
- } else {
- fprintf(stderr, "Unknown compile error for \"%s\" as a regular expression!\n", argv[i]);
- }
- exit(EXIT_FAILURE);
- }
- regs.push_back(re);
- }
-
- if (::testing::Benchmark::RunAll(regs) == 0) {
- fprintf(stderr, "No matching benchmarks!\n");
- fprintf(stderr, "Available benchmarks:\n");
- for (const auto& benchmark : ::testing::Benchmark::List()) {
- fprintf(stderr, " %s\n", benchmark->Name().c_str());
- }
- exit(EXIT_FAILURE);
- }
-
- return 0;
-}
diff --git a/benchmarks/math_benchmark.cpp b/benchmarks/math_benchmark.cpp
index ed5b56c..36ac301 100644
--- a/benchmarks/math_benchmark.cpp
+++ b/benchmarks/math_benchmark.cpp
@@ -17,270 +17,213 @@
#include <fenv.h>
#include <math.h>
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
-#define AT_COMMON_VALS \
- Arg(1234.0)->Arg(nan(""))->Arg(HUGE_VAL)->Arg(0.0)
+static const double values[] = { 1234.0, nan(""), HUGE_VAL, 0.0 };
+static const char* names[] = { "1234.0", "nan", "HUGE_VAL", "0.0" };
+
+#define BENCHMARK_COMMON_VALS(name) BENCHMARK(name)->Arg(0)->Arg(1)->Arg(2)->Arg(3)
+
+static void SetLabel(benchmark::State& state) {
+ state.SetLabel(names[state.range_x()]);
+}
// Avoid optimization.
volatile double d;
volatile double v;
-BENCHMARK_NO_ARG(BM_math_sqrt);
-void BM_math_sqrt::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_math_sqrt(benchmark::State& state) {
d = 0.0;
v = 2.0;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
d += sqrt(v);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_math_sqrt);
-BENCHMARK_NO_ARG(BM_math_log10);
-void BM_math_log10::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_math_log10(benchmark::State& state) {
d = 0.0;
v = 1234.0;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
d += log10(v);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_math_log10);
-BENCHMARK_NO_ARG(BM_math_logb);
-void BM_math_logb::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_math_logb(benchmark::State& state) {
d = 0.0;
v = 1234.0;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
d += logb(v);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_math_logb);
-BENCHMARK_WITH_ARG(BM_math_isfinite_macro, double)->AT_COMMON_VALS;
-void BM_math_isfinite_macro::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_isfinite_macro(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += isfinite(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_isfinite_macro);
#if defined(__BIONIC__)
#define test_isfinite __isfinite
#else
#define test_isfinite __finite
#endif
-BENCHMARK_WITH_ARG(BM_math_isfinite, double)->AT_COMMON_VALS;
-void BM_math_isfinite::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_isfinite(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += test_isfinite(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_isfinite);
-BENCHMARK_WITH_ARG(BM_math_isinf_macro, double)->AT_COMMON_VALS;
-void BM_math_isinf_macro::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_isinf_macro(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += isinf(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_isinf_macro);
-BENCHMARK_WITH_ARG(BM_math_isinf, double)->AT_COMMON_VALS;
-void BM_math_isinf::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_isinf(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += (isinf)(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_isinf);
-BENCHMARK_WITH_ARG(BM_math_isnan_macro, double)->AT_COMMON_VALS;
-void BM_math_isnan_macro::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_isnan_macro(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += isnan(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_isnan_macro);
-BENCHMARK_WITH_ARG(BM_math_isnan, double)->AT_COMMON_VALS;
-void BM_math_isnan::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_isnan(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += (isnan)(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_isnan);
-BENCHMARK_WITH_ARG(BM_math_isnormal_macro, double)->AT_COMMON_VALS;
-void BM_math_isnormal_macro::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_isnormal_macro(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += isnormal(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_isnormal_macro);
#if defined(__BIONIC__)
-BENCHMARK_WITH_ARG(BM_math_isnormal, double)->AT_COMMON_VALS;
-void BM_math_isnormal::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_isnormal(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += (__isnormal)(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_isnormal);
#endif
-BENCHMARK_NO_ARG(BM_math_sin_fast);
-void BM_math_sin_fast::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_math_sin_fast(benchmark::State& state) {
d = 1.0;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
d += sin(d);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_math_sin_fast);
-BENCHMARK_NO_ARG(BM_math_sin_feupdateenv);
-void BM_math_sin_feupdateenv::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_math_sin_feupdateenv(benchmark::State& state) {
d = 1.0;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
fenv_t __libc_save_rm;
feholdexcept(&__libc_save_rm);
fesetround(FE_TONEAREST);
d += sin(d);
feupdateenv(&__libc_save_rm);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_math_sin_feupdateenv);
-BENCHMARK_NO_ARG(BM_math_sin_fesetenv);
-void BM_math_sin_fesetenv::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_math_sin_fesetenv(benchmark::State& state) {
d = 1.0;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
fenv_t __libc_save_rm;
feholdexcept(&__libc_save_rm);
fesetround(FE_TONEAREST);
d += sin(d);
fesetenv(&__libc_save_rm);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_math_sin_fesetenv);
-BENCHMARK_WITH_ARG(BM_math_fpclassify, double)->AT_COMMON_VALS;
-void BM_math_fpclassify::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_fpclassify(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += fpclassify(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_fpclassify);
-BENCHMARK_WITH_ARG(BM_math_signbit_macro, double)->AT_COMMON_VALS;
-void BM_math_signbit_macro::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_signbit_macro(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += signbit(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_signbit_macro);
-BENCHMARK_WITH_ARG(BM_math_signbit, double)->AT_COMMON_VALS;
-void BM_math_signbit::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_signbit(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += (__signbit)(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_signbit);
-BENCHMARK_WITH_ARG(BM_math_fabs_macro, double)->AT_COMMON_VALS;
-void BM_math_fabs_macro::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_fabs_macro(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += fabs(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_fabs_macro);
-BENCHMARK_WITH_ARG(BM_math_fabs, double)->AT_COMMON_VALS;
-void BM_math_fabs::Run(int iters, double value) {
- StartBenchmarkTiming();
-
+static void BM_math_fabs(benchmark::State& state) {
d = 0.0;
- v = value;
- for (int i = 0; i < iters; ++i) {
+ v = values[state.range_x()];
+ while (state.KeepRunning()) {
d += (fabs)(v);
}
-
- StopBenchmarkTiming();
+ SetLabel(state);
}
+BENCHMARK_COMMON_VALS(BM_math_fabs);
diff --git a/benchmarks/property_benchmark.cpp b/benchmarks/property_benchmark.cpp
index 944cd68..2f72d60 100644
--- a/benchmarks/property_benchmark.cpp
+++ b/benchmarks/property_benchmark.cpp
@@ -26,7 +26,7 @@
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
extern void* __system_property_area__;
@@ -126,7 +126,8 @@
delete[] values;
delete[] value_lens;
}
-public:
+
+ public:
const int nprops;
char** names;
int* name_lens;
@@ -134,100 +135,79 @@
int* value_lens;
bool valid;
-private:
+ private:
std::string pa_dirname;
std::string pa_filename;
void* old_pa;
};
-BENCHMARK_WITH_ARG(BM_property_get, int)->TEST_NUM_PROPS;
-void BM_property_get::Run(int iters, int nprops) {
- StopBenchmarkTiming();
+static void BM_property_get(benchmark::State& state) {
+ const size_t nprops = state.range_x();
LocalPropertyTestState pa(nprops);
- char value[PROP_VALUE_MAX];
+ if (!pa.valid) return;
- if (!pa.valid)
- return;
-
- srandom(iters * nprops);
-
- StartBenchmarkTiming();
-
- for (int i = 0; i < iters; i++) {
+ while (state.KeepRunning()) {
+ char value[PROP_VALUE_MAX];
__system_property_get(pa.names[random() % nprops], value);
}
- StopBenchmarkTiming();
}
+BENCHMARK(BM_property_get)->TEST_NUM_PROPS;
-BENCHMARK_WITH_ARG(BM_property_find, int)->TEST_NUM_PROPS;
-void BM_property_find::Run(int iters, int nprops) {
- StopBenchmarkTiming();
+static void BM_property_find(benchmark::State& state) {
+ const size_t nprops = state.range_x();
LocalPropertyTestState pa(nprops);
+ if (!pa.valid) return;
- if (!pa.valid)
- return;
-
- srandom(iters * nprops);
-
- StartBenchmarkTiming();
-
- for (int i = 0; i < iters; i++) {
+ while (state.KeepRunning()) {
__system_property_find(pa.names[random() % nprops]);
}
- StopBenchmarkTiming();
}
+BENCHMARK(BM_property_find)->TEST_NUM_PROPS;
-BENCHMARK_WITH_ARG(BM_property_read, int)->TEST_NUM_PROPS;
-void BM_property_read::Run(int iters, int nprops) {
- StopBenchmarkTiming();
+static void BM_property_read(benchmark::State& state) {
+ const size_t nprops = state.range_x();
LocalPropertyTestState pa(nprops);
+ if (!pa.valid) return;
- if (!pa.valid)
- return;
-
- srandom(iters * nprops);
- const prop_info** pinfo = new const prop_info*[iters];
+ const prop_info** pinfo = new const prop_info*[nprops];
char propvalue[PROP_VALUE_MAX];
- for (int i = 0; i < iters; i++) {
+ for (size_t i = 0; i < nprops; ++i) {
pinfo[i] = __system_property_find(pa.names[random() % nprops]);
}
- StartBenchmarkTiming();
- for (int i = 0; i < iters; i++) {
+ size_t i = 0;
+ while (state.KeepRunning()) {
__system_property_read(pinfo[i], 0, propvalue);
+ i = (i + 1) % nprops;
}
- StopBenchmarkTiming();
delete[] pinfo;
}
+BENCHMARK(BM_property_read)->TEST_NUM_PROPS;
-BENCHMARK_WITH_ARG(BM_property_serial, int)->TEST_NUM_PROPS;
-void BM_property_serial::Run(int iters, int nprops) {
- StopBenchmarkTiming();
+static void BM_property_serial(benchmark::State& state) {
+ const size_t nprops = state.range_x();
LocalPropertyTestState pa(nprops);
+ if (!pa.valid) return;
- if (!pa.valid)
- return;
-
- srandom(iters * nprops);
- const prop_info** pinfo = new const prop_info*[iters];
-
- for (int i = 0; i < iters; i++) {
+ const prop_info** pinfo = new const prop_info*[nprops];
+ for (size_t i = 0; i < nprops; ++i) {
pinfo[i] = __system_property_find(pa.names[random() % nprops]);
}
- StartBenchmarkTiming();
- for (int i = 0; i < iters; i++) {
+ size_t i = 0;
+ while (state.KeepRunning()) {
__system_property_serial(pinfo[i]);
+ i = (i + 1) % nprops;
}
- StopBenchmarkTiming();
delete[] pinfo;
}
+BENCHMARK(BM_property_serial)->TEST_NUM_PROPS;
#endif // __BIONIC__
diff --git a/benchmarks/pthread_benchmark.cpp b/benchmarks/pthread_benchmark.cpp
index ad31e7e..bf4d6cb 100644
--- a/benchmarks/pthread_benchmark.cpp
+++ b/benchmarks/pthread_benchmark.cpp
@@ -16,218 +16,178 @@
#include <pthread.h>
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
// Stop GCC optimizing out our pure function.
/* Must not be static! */ pthread_t (*pthread_self_fp)() = pthread_self;
-BENCHMARK_NO_ARG(BM_pthread_self);
-void BM_pthread_self::Run(int iters) {
- StartBenchmarkTiming();
-
- for (int i = 0; i < iters; ++i) {
+static void BM_pthread_self(benchmark::State& state) {
+ while (state.KeepRunning()) {
pthread_self_fp();
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_pthread_self);
-BENCHMARK_NO_ARG(BM_pthread_getspecific);
-void BM_pthread_getspecific::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_pthread_getspecific(benchmark::State& state) {
pthread_key_t key;
pthread_key_create(&key, NULL);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
pthread_getspecific(key);
}
- StopBenchmarkTiming();
pthread_key_delete(key);
}
+BENCHMARK(BM_pthread_getspecific);
-BENCHMARK_NO_ARG(BM_pthread_setspecific);
-void BM_pthread_setspecific::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_pthread_setspecific(benchmark::State& state) {
pthread_key_t key;
pthread_key_create(&key, NULL);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
pthread_setspecific(key, NULL);
}
- StopBenchmarkTiming();
pthread_key_delete(key);
}
+BENCHMARK(BM_pthread_setspecific);
static void DummyPthreadOnceInitFunction() {
}
-BENCHMARK_NO_ARG(BM_pthread_once);
-void BM_pthread_once::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_pthread_once(benchmark::State& state) {
pthread_once_t once = PTHREAD_ONCE_INIT;
pthread_once(&once, DummyPthreadOnceInitFunction);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
pthread_once(&once, DummyPthreadOnceInitFunction);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_pthread_once);
-BENCHMARK_NO_ARG(BM_pthread_mutex_lock);
-void BM_pthread_mutex_lock::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_pthread_mutex_lock(benchmark::State& state) {
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_pthread_mutex_lock);
-BENCHMARK_NO_ARG(BM_pthread_mutex_lock_ERRORCHECK);
-void BM_pthread_mutex_lock_ERRORCHECK::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_pthread_mutex_lock_ERRORCHECK(benchmark::State& state) {
pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_pthread_mutex_lock_ERRORCHECK);
-BENCHMARK_NO_ARG(BM_pthread_mutex_lock_RECURSIVE);
-void BM_pthread_mutex_lock_RECURSIVE::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_pthread_mutex_lock_RECURSIVE(benchmark::State& state) {
pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_pthread_mutex_lock_RECURSIVE);
-BENCHMARK_NO_ARG(BM_pthread_rwlock_read);
-void BM_pthread_rwlock_read::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_pthread_rwlock_read(benchmark::State& state) {
pthread_rwlock_t lock;
pthread_rwlock_init(&lock, NULL);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
pthread_rwlock_rdlock(&lock);
pthread_rwlock_unlock(&lock);
}
- StopBenchmarkTiming();
pthread_rwlock_destroy(&lock);
}
+BENCHMARK(BM_pthread_rwlock_read);
-BENCHMARK_NO_ARG(BM_pthread_rwlock_write);
-void BM_pthread_rwlock_write::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_pthread_rwlock_write(benchmark::State& state) {
pthread_rwlock_t lock;
pthread_rwlock_init(&lock, NULL);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
pthread_rwlock_wrlock(&lock);
pthread_rwlock_unlock(&lock);
}
- StopBenchmarkTiming();
pthread_rwlock_destroy(&lock);
}
+BENCHMARK(BM_pthread_rwlock_write);
static void* IdleThread(void*) {
return NULL;
}
-BENCHMARK_NO_ARG(BM_pthread_create);
-void BM_pthread_create::Run(int iters) {
- StopBenchmarkTiming();
- pthread_t thread;
-
- for (int i = 0; i < iters; ++i) {
- StartBenchmarkTiming();
+static void BM_pthread_create(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ pthread_t thread;
pthread_create(&thread, NULL, IdleThread, NULL);
- StopBenchmarkTiming();
+ state.PauseTiming();
pthread_join(thread, NULL);
+ state.ResumeTiming();
}
}
+BENCHMARK(BM_pthread_create);
static void* RunThread(void* arg) {
- ::testing::Benchmark* benchmark = reinterpret_cast<::testing::Benchmark*>(arg);
- benchmark->StopBenchmarkTiming();
+ benchmark::State& state = *reinterpret_cast<benchmark::State*>(arg);
+ state.PauseTiming();
return NULL;
}
-BENCHMARK_NO_ARG(BM_pthread_create_and_run);
-void BM_pthread_create_and_run::Run(int iters) {
- StopBenchmarkTiming();
- pthread_t thread;
-
- for (int i = 0; i < iters; ++i) {
- StartBenchmarkTiming();
- pthread_create(&thread, NULL, RunThread, this);
+static void BM_pthread_create_and_run(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ pthread_t thread;
+ pthread_create(&thread, NULL, RunThread, &state);
pthread_join(thread, NULL);
+ state.ResumeTiming();
}
}
+BENCHMARK(BM_pthread_create_and_run);
static void* ExitThread(void* arg) {
- ::testing::Benchmark* benchmark = reinterpret_cast<::testing::Benchmark*>(arg);
- benchmark->StartBenchmarkTiming();
+ benchmark::State& state = *reinterpret_cast<benchmark::State*>(arg);
+ state.ResumeTiming();
pthread_exit(NULL);
}
-BENCHMARK_NO_ARG(BM_pthread_exit_and_join);
-void BM_pthread_exit_and_join::Run(int iters) {
- StopBenchmarkTiming();
- pthread_t thread;
-
- for (int i = 0; i < iters; ++i) {
- pthread_create(&thread, NULL, ExitThread, this);
+static void BM_pthread_exit_and_join(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ state.PauseTiming();
+ pthread_t thread;
+ pthread_create(&thread, NULL, ExitThread, &state);
pthread_join(thread, NULL);
- StopBenchmarkTiming();
}
}
+BENCHMARK(BM_pthread_exit_and_join);
-BENCHMARK_NO_ARG(BM_pthread_key_create);
-void BM_pthread_key_create::Run(int iters) {
- StopBenchmarkTiming();
- pthread_key_t key;
-
- for (int i = 0; i < iters; ++i) {
- StartBenchmarkTiming();
+static void BM_pthread_key_create(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ pthread_key_t key;
pthread_key_create(&key, NULL);
- StopBenchmarkTiming();
+
+ state.PauseTiming();
+ pthread_key_delete(key);
+ state.ResumeTiming();
+ }
+}
+BENCHMARK(BM_pthread_key_create);
+
+static void BM_pthread_key_delete(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ state.PauseTiming();
+ pthread_key_t key;
+ pthread_key_create(&key, NULL);
+ state.ResumeTiming();
+
pthread_key_delete(key);
}
}
-
-BENCHMARK_NO_ARG(BM_pthread_key_delete);
-void BM_pthread_key_delete::Run(int iters) {
- StopBenchmarkTiming();
- pthread_key_t key;
-
- for (int i = 0; i < iters; ++i) {
- pthread_key_create(&key, NULL);
- StartBenchmarkTiming();
- pthread_key_delete(key);
- StopBenchmarkTiming();
- }
-}
+BENCHMARK(BM_pthread_key_delete);
diff --git a/benchmarks/semaphore_benchmark.cpp b/benchmarks/semaphore_benchmark.cpp
index 8dd5684..d260803 100644
--- a/benchmarks/semaphore_benchmark.cpp
+++ b/benchmarks/semaphore_benchmark.cpp
@@ -18,101 +18,112 @@
#include <semaphore.h>
#include <stdatomic.h>
#include <stdio.h>
+#include <stdlib.h>
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
-BENCHMARK_NO_ARG(BM_semaphore_sem_getvalue);
-void BM_semaphore_sem_getvalue::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_semaphore_sem_getvalue(benchmark::State& state) {
sem_t semaphore;
sem_init(&semaphore, 1, 1);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
int dummy;
sem_getvalue(&semaphore, &dummy);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_semaphore_sem_getvalue);
-BENCHMARK_NO_ARG(BM_semaphore_sem_wait_sem_post);
-void BM_semaphore_sem_wait_sem_post::Run(int iters) {
- StopBenchmarkTiming();
+static void BM_semaphore_sem_wait_sem_post(benchmark::State& state) {
sem_t semaphore;
sem_init(&semaphore, 1, 1);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
sem_wait(&semaphore);
sem_post(&semaphore);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_semaphore_sem_wait_sem_post);
-/*
- * This test reports the overhead of the underlying futex wake syscall on
- * the producer. It does not report the overhead from issuing the wake to the
- * point where the posted consumer thread wakes up. It suffers from
- * clock_gettime syscall overhead. Lock the CPU speed for consistent results
- * as we may not reach >50% cpu utilization.
- *
- * We will run a background thread that catches the sem_post wakeup and
- * loops immediately returning back to sleep in sem_wait for the next one. This
- * thread is run with policy SCHED_OTHER (normal policy), a middle policy.
- *
- * The primary thread will run at SCHED_IDLE (lowest priority policy) when
- * monitoring the background thread to detect when it hits sem_wait sleep. It
- * will do so with no clock running. Once we are ready, we will switch to
- * SCHED_FIFO (highest priority policy) to time the act of running sem_post
- * with the benchmark clock running. This ensures nothing else in the system
- * can preempt our timed activity, including the background thread. We are
- * also protected with the scheduling policy of letting a process hit a
- * resource limit rather than get hit with a context switch.
- *
- * The background thread will start executing either on another CPU, or
- * after we back down from SCHED_FIFO, but certainly not in the context of
- * the timing of the sem_post.
- */
+// This test reports the overhead of the underlying futex wake syscall on
+// the producer. It does not report the overhead from issuing the wake to the
+// point where the posted consumer thread wakes up. It suffers from
+// clock_gettime syscall overhead. Lock the CPU speed for consistent results
+// as we may not reach >50% cpu utilization.
+//
+// We will run a background thread that catches the sem_post wakeup and
+// loops immediately returning back to sleep in sem_wait for the next one. This
+// thread is run with policy SCHED_OTHER (normal policy), a middle policy.
+//
+// The primary thread will run at SCHED_IDLE (lowest priority policy) when
+// monitoring the background thread to detect when it hits sem_wait sleep. It
+// will do so with no clock running. Once we are ready, we will switch to
+// SCHED_FIFO (highest priority policy) to time the act of running sem_post
+// with the benchmark clock running. This ensures nothing else in the system
+// can preempt our timed activity, including the background thread. We are
+// also protected with the scheduling policy of letting a process hit a
+// resource limit rather than get hit with a context switch.
+//
+// The background thread will start executing either on another CPU, or
+// after we back down from SCHED_FIFO, but certainly not in the context of
+// the timing of the sem_post.
+
static atomic_int BM_semaphore_sem_post_running;
-static void *BM_semaphore_sem_post_start_thread(void *obj) {
- sem_t *semaphore = reinterpret_cast<sem_t *>(obj);
-
- while ((BM_semaphore_sem_post_running > 0) && !sem_wait(semaphore)) {
- ;
- }
- BM_semaphore_sem_post_running = -1;
- return NULL;
+static void* BM_semaphore_sem_post_start_thread(void* arg) {
+ sem_t* semaphore = reinterpret_cast<sem_t*>(arg);
+ while ((BM_semaphore_sem_post_running > 0) && !sem_wait(semaphore)) {
+ }
+ BM_semaphore_sem_post_running = -1;
+ return NULL;
}
-BENCHMARK_NO_ARG(BM_semaphore_sem_post);
-void BM_semaphore_sem_post::Run(int iters) {
- StopBenchmarkTiming();
+class SemaphoreFixture : public benchmark::Fixture {
+ public:
+ void SetUp(const benchmark::State&) {
+ sem_init(&semaphore, 0, 0);
+
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+
+ memset(¶m, 0, sizeof(param));
+ pthread_attr_setschedparam(&attr, ¶m);
+ pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ pthread_t pthread;
+ pthread_create(&pthread, &attr, BM_semaphore_sem_post_start_thread, &semaphore);
+ pthread_attr_destroy(&attr);
+
+ sched_setscheduler(0, SCHED_IDLE, ¶m);
+
+ BM_semaphore_sem_post_running = 1;
+ }
+
+ ~SemaphoreFixture() {
+ sched_setscheduler(0, SCHED_OTHER, ¶m);
+
+ if (BM_semaphore_sem_post_running > 0) {
+ BM_semaphore_sem_post_running = 0;
+ }
+ do {
+ sem_post(&semaphore);
+ sched_yield();
+ } while (BM_semaphore_sem_post_running != -1);
+ }
sem_t semaphore;
- sem_init(&semaphore, 0, 0);
+ sched_param param;
+};
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- BM_semaphore_sem_post_running = 1;
- struct sched_param param = { 0, };
- pthread_attr_setschedparam(&attr, ¶m);
- pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_t pthread;
- pthread_create(&pthread, &attr, BM_semaphore_sem_post_start_thread, &semaphore);
- pthread_attr_destroy(&attr);
+BENCHMARK_F(SemaphoreFixture, semaphore_sem_post)(benchmark::State& state) {
+ while (state.KeepRunning()) {
+ state.PauseTiming();
- sched_setscheduler((pid_t)0, SCHED_IDLE, ¶m);
- for (int i = 0; i < iters; ++i) {
int trys = 3, dummy = 0;
do {
if (BM_semaphore_sem_post_running < 0) {
- sched_setscheduler((pid_t)0, SCHED_OTHER, ¶m);
+ sched_setscheduler(0, SCHED_OTHER, ¶m);
fprintf(stderr, "BM_semaphore_sem_post: start_thread died unexpectedly\n");
- return;
+ abort();
}
sched_yield();
sem_getvalue(&semaphore, &dummy);
@@ -123,21 +134,14 @@
--trys;
}
} while (trys);
- param.sched_priority = 1;
- sched_setscheduler((pid_t)0, SCHED_FIFO, ¶m);
- StartBenchmarkTiming();
- sem_post(&semaphore);
- StopBenchmarkTiming(); // Remember to subtract clock syscall overhead
- param.sched_priority = 0;
- sched_setscheduler((pid_t)0, SCHED_IDLE, ¶m);
- }
- sched_setscheduler((pid_t)0, SCHED_OTHER, ¶m);
- if (BM_semaphore_sem_post_running > 0) {
- BM_semaphore_sem_post_running = 0;
- }
- do {
+ param.sched_priority = 1;
+ sched_setscheduler(0, SCHED_FIFO, ¶m);
+
+ state.ResumeTiming();
sem_post(&semaphore);
- sched_yield();
- } while (!BM_semaphore_sem_post_running);
+
+ param.sched_priority = 0;
+ sched_setscheduler(0, SCHED_IDLE, ¶m);
+ }
}
diff --git a/benchmarks/stdio_benchmark.cpp b/benchmarks/stdio_benchmark.cpp
index 69e01a9..cc07128 100644
--- a/benchmarks/stdio_benchmark.cpp
+++ b/benchmarks/stdio_benchmark.cpp
@@ -18,7 +18,7 @@
#include <stdio_ext.h>
#include <stdlib.h>
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
#define KB 1024
#define MB 1024*KB
@@ -28,50 +28,49 @@
Arg(1*KB)->Arg(4*KB)->Arg(8*KB)->Arg(16*KB)->Arg(64*KB)
template <typename Fn>
-void ReadWriteTest(::testing::Benchmark* benchmark, int iters, int chunk_size, Fn f, bool buffered) {
- benchmark->StopBenchmarkTiming();
+void ReadWriteTest(benchmark::State& state, Fn f, bool buffered) {
+ size_t chunk_size = state.range_x();
+
FILE* fp = fopen("/dev/zero", "rw");
__fsetlocking(fp, FSETLOCKING_BYCALLER);
char* buf = new char[chunk_size];
- benchmark->StartBenchmarkTiming();
if (!buffered) {
setvbuf(fp, 0, _IONBF, 0);
}
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
f(buf, chunk_size, 1, fp);
}
- benchmark->StopBenchmarkTiming();
- benchmark->SetBenchmarkBytesProcessed(int64_t(iters) * int64_t(chunk_size));
+ state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(chunk_size));
delete[] buf;
fclose(fp);
}
-BENCHMARK_WITH_ARG(BM_stdio_fread, int)->AT_COMMON_SIZES;
-void BM_stdio_fread::Run(int iters, int chunk_size) {
- ReadWriteTest(this, iters, chunk_size, fread, true);
+void BM_stdio_fread(benchmark::State& state) {
+ ReadWriteTest(state, fread, true);
}
+BENCHMARK(BM_stdio_fread)->AT_COMMON_SIZES;
-BENCHMARK_WITH_ARG(BM_stdio_fwrite, int)->AT_COMMON_SIZES;
-void BM_stdio_fwrite::Run(int iters, int chunk_size) {
- ReadWriteTest(this, iters, chunk_size, fwrite, true);
+void BM_stdio_fwrite(benchmark::State& state) {
+ ReadWriteTest(state, fwrite, true);
}
+BENCHMARK(BM_stdio_fwrite)->AT_COMMON_SIZES;
-BENCHMARK_WITH_ARG(BM_stdio_fread_unbuffered, int)->AT_COMMON_SIZES;
-void BM_stdio_fread_unbuffered::Run(int iters, int chunk_size) {
- ReadWriteTest(this, iters, chunk_size, fread, false);
+void BM_stdio_fread_unbuffered(benchmark::State& state) {
+ ReadWriteTest(state, fread, false);
}
+BENCHMARK(BM_stdio_fread_unbuffered)->AT_COMMON_SIZES;
-BENCHMARK_WITH_ARG(BM_stdio_fwrite_unbuffered, int)->AT_COMMON_SIZES;
-void BM_stdio_fwrite_unbuffered::Run(int iters, int chunk_size) {
- ReadWriteTest(this, iters, chunk_size, fwrite, false);
+void BM_stdio_fwrite_unbuffered(benchmark::State& state) {
+ ReadWriteTest(state, fwrite, false);
}
+BENCHMARK(BM_stdio_fwrite_unbuffered)->AT_COMMON_SIZES;
-static void FopenFgetsFclose(int iters, bool no_locking) {
+static void FopenFgetsFclose(benchmark::State& state, bool no_locking) {
char buf[1024];
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
FILE* fp = fopen("/proc/version", "re");
if (no_locking) __fsetlocking(fp, FSETLOCKING_BYCALLER);
if (fgets(buf, sizeof(buf), fp) == nullptr) abort();
@@ -79,16 +78,12 @@
}
}
-BENCHMARK_NO_ARG(BM_stdio_fopen_fgets_fclose_locking);
-void BM_stdio_fopen_fgets_fclose_locking::Run(int iters) {
- StartBenchmarkTiming();
- FopenFgetsFclose(iters, false);
- StopBenchmarkTiming();
+static void BM_stdio_fopen_fgets_fclose_locking(benchmark::State& state) {
+ FopenFgetsFclose(state, false);
}
+BENCHMARK(BM_stdio_fopen_fgets_fclose_locking);
-BENCHMARK_NO_ARG(BM_stdio_fopen_fgets_fclose_no_locking);
-void BM_stdio_fopen_fgets_fclose_no_locking::Run(int iters) {
- StartBenchmarkTiming();
- FopenFgetsFclose(iters, true);
- StopBenchmarkTiming();
+void BM_stdio_fopen_fgets_fclose_no_locking(benchmark::State& state) {
+ FopenFgetsFclose(state, true);
}
+BENCHMARK(BM_stdio_fopen_fgets_fclose_no_locking);
diff --git a/benchmarks/string_benchmark.cpp b/benchmarks/string_benchmark.cpp
index 866aa00..c04409d 100644
--- a/benchmarks/string_benchmark.cpp
+++ b/benchmarks/string_benchmark.cpp
@@ -17,7 +17,7 @@
#include <stdint.h>
#include <string.h>
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
#define KB 1024
#define MB 1024*KB
@@ -27,87 +27,77 @@
// TODO: test unaligned operation too? (currently everything will be 8-byte aligned by malloc.)
-BENCHMARK_WITH_ARG(BM_string_memcmp, int)->AT_COMMON_SIZES;
-void BM_string_memcmp::Run(int iters, int nbytes) {
- StopBenchmarkTiming();
+static void BM_string_memcmp(benchmark::State& state) {
+ const size_t nbytes = state.range_x();
char* src = new char[nbytes]; char* dst = new char[nbytes];
memset(src, 'x', nbytes);
memset(dst, 'x', nbytes);
- StartBenchmarkTiming();
volatile int c __attribute__((unused)) = 0;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
c += memcmp(dst, src, nbytes);
}
- StopBenchmarkTiming();
- SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+ state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
delete[] src;
delete[] dst;
}
+BENCHMARK(BM_string_memcmp)->AT_COMMON_SIZES;
-BENCHMARK_WITH_ARG(BM_string_memcpy, int)->AT_COMMON_SIZES;
-void BM_string_memcpy::Run(int iters, int nbytes) {
- StopBenchmarkTiming();
+static void BM_string_memcpy(benchmark::State& state) {
+ const size_t nbytes = state.range_x();
char* src = new char[nbytes]; char* dst = new char[nbytes];
memset(src, 'x', nbytes);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
memcpy(dst, src, nbytes);
}
- StopBenchmarkTiming();
- SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+ state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
delete[] src;
delete[] dst;
}
+BENCHMARK(BM_string_memcpy)->AT_COMMON_SIZES;
-BENCHMARK_WITH_ARG(BM_string_memmove, int)->AT_COMMON_SIZES;
-void BM_string_memmove::Run(int iters, int nbytes) {
- StopBenchmarkTiming();
+static void BM_string_memmove(benchmark::State& state) {
+ const size_t nbytes = state.range_x();
char* buf = new char[nbytes + 64];
memset(buf, 'x', nbytes + 64);
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
memmove(buf, buf + 1, nbytes); // Worst-case overlap.
}
- StopBenchmarkTiming();
- SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+ state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
delete[] buf;
}
+BENCHMARK(BM_string_memmove)->AT_COMMON_SIZES;
-BENCHMARK_WITH_ARG(BM_string_memset, int)->AT_COMMON_SIZES;
-void BM_string_memset::Run(int iters, int nbytes) {
- StopBenchmarkTiming();
+static void BM_string_memset(benchmark::State& state) {
+ const size_t nbytes = state.range_x();
char* dst = new char[nbytes];
- StartBenchmarkTiming();
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
memset(dst, 0, nbytes);
}
- StopBenchmarkTiming();
- SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+ state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
delete[] dst;
}
+BENCHMARK(BM_string_memset)->AT_COMMON_SIZES;
-BENCHMARK_WITH_ARG(BM_string_strlen, int)->AT_COMMON_SIZES;
-void BM_string_strlen::Run(int iters, int nbytes) {
- StopBenchmarkTiming();
+static void BM_string_strlen(benchmark::State& state) {
+ const size_t nbytes = state.range_x();
char* s = new char[nbytes];
memset(s, 'x', nbytes);
s[nbytes - 1] = 0;
- StartBenchmarkTiming();
volatile int c __attribute__((unused)) = 0;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
c += strlen(s);
}
- StopBenchmarkTiming();
- SetBenchmarkBytesProcessed(uint64_t(iters) * uint64_t(nbytes));
+ state.SetBytesProcessed(uint64_t(state.iterations()) * uint64_t(nbytes));
delete[] s;
}
+BENCHMARK(BM_string_strlen)->AT_COMMON_SIZES;
diff --git a/benchmarks/time_benchmark.cpp b/benchmarks/time_benchmark.cpp
index 1b0d08d..4a5c2da 100644
--- a/benchmarks/time_benchmark.cpp
+++ b/benchmarks/time_benchmark.cpp
@@ -19,63 +19,43 @@
#include <time.h>
#include <unistd.h>
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
-BENCHMARK_NO_ARG(BM_time_clock_gettime);
-void BM_time_clock_gettime::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_time_clock_gettime(benchmark::State& state) {
timespec t;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
clock_gettime(CLOCK_MONOTONIC, &t);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_time_clock_gettime);
-BENCHMARK_NO_ARG(BM_time_clock_gettime_syscall);
-void BM_time_clock_gettime_syscall::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_time_clock_gettime_syscall(benchmark::State& state) {
timespec t;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &t);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_time_clock_gettime_syscall);
-BENCHMARK_NO_ARG(BM_time_gettimeofday);
-void BM_time_gettimeofday::Run(int iters) {
- StartBenchmarkTiming();
-
+static void BM_time_gettimeofday(benchmark::State& state) {
timeval tv;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
gettimeofday(&tv, NULL);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_time_gettimeofday);
-BENCHMARK_NO_ARG(BM_time_gettimeofday_syscall);
-void BM_time_gettimeofday_syscall::Run(int iters) {
- StartBenchmarkTiming();
-
+void BM_time_gettimeofday_syscall(benchmark::State& state) {
timeval tv;
- for (int i = 0; i < iters; ++i) {
+ while (state.KeepRunning()) {
syscall(__NR_gettimeofday, &tv, NULL);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_time_gettimeofday_syscall);
-BENCHMARK_NO_ARG(BM_time_time);
-void BM_time_time::Run(int iters) {
- StartBenchmarkTiming();
-
- for (int i = 0; i < iters; ++i) {
+void BM_time_time(benchmark::State& state) {
+ while (state.KeepRunning()) {
time(NULL);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_time_time);
diff --git a/benchmarks/unistd_benchmark.cpp b/benchmarks/unistd_benchmark.cpp
index 09ca0e6..b78d3eb 100644
--- a/benchmarks/unistd_benchmark.cpp
+++ b/benchmarks/unistd_benchmark.cpp
@@ -17,55 +17,41 @@
#include <sys/syscall.h>
#include <unistd.h>
-#include <benchmark/Benchmark.h>
+#include <benchmark/benchmark.h>
-BENCHMARK_NO_ARG(BM_unistd_getpid);
-void BM_unistd_getpid::Run(int iters) {
- StartBenchmarkTiming();
-
- for (int i = 0; i < iters; ++i) {
+static void BM_unistd_getpid(benchmark::State& state) {
+ while (state.KeepRunning()) {
getpid();
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_unistd_getpid);
-BENCHMARK_NO_ARG(BM_unistd_getpid_syscall);
-void BM_unistd_getpid_syscall::Run(int iters) {
- StartBenchmarkTiming();
-
- for (int i = 0; i < iters; ++i) {
+static void BM_unistd_getpid_syscall(benchmark::State& state) {
+ while (state.KeepRunning()) {
syscall(__NR_getpid);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_unistd_getpid_syscall);
#if defined(__BIONIC__)
// Stop GCC optimizing out our pure function.
/* Must not be static! */ pid_t (*gettid_fp)() = gettid;
-BENCHMARK_NO_ARG(BM_unistd_gettid);
-void BM_unistd_gettid::Run(int iters) {
- StartBenchmarkTiming();
-
- for (int i = 0; i < iters; ++i) {
+static void BM_unistd_gettid(benchmark::State& state) {
+ while (state.KeepRunning()) {
gettid_fp();
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_unistd_gettid);
#endif
-BENCHMARK_NO_ARG(BM_unistd_gettid_syscall);
-void BM_unistd_gettid_syscall::Run(int iters) {
- StartBenchmarkTiming();
-
- for (int i = 0; i < iters; ++i) {
+void BM_unistd_gettid_syscall(benchmark::State& state) {
+ while (state.KeepRunning()) {
syscall(__NR_gettid);
}
-
- StopBenchmarkTiming();
}
+BENCHMARK(BM_unistd_gettid_syscall);
+
+BENCHMARK_MAIN()
diff --git a/benchmarks/utils.cpp b/benchmarks/utils.cpp
deleted file mode 100644
index 8bbd20a..0000000
--- a/benchmarks/utils.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "utils.h"
-
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include <string>
-
-#include <android-base/stringprintf.h>
-
-int Round(int n) {
- int base = 1;
- while (base*10 < n) {
- base *= 10;
- }
- if (n < 2*base) {
- return 2*base;
- }
- if (n < 5*base) {
- return 5*base;
- }
- return 10*base;
-}
-
-// Similar to the code in art, but supporting both binary and decimal prefixes.
-std::string PrettyInt(long value, size_t base) {
- if (base != 2 && base != 10) abort();
-
- uint64_t count = static_cast<uint64_t>(value);
- bool negative_number = false;
- if (value < 0) {
- negative_number = true;
- count = static_cast<uint64_t>(-value);
- }
-
- // The byte thresholds at which we display amounts. A count is displayed
- // in unit U when kUnitThresholds[U] <= bytes < kUnitThresholds[U+1].
- static const uint64_t kUnitThresholds2[] = {
- 1024*1024*1024 /* Gi */, 2*1024*1024 /* Mi */, 3*1024 /* Ki */, 0,
- };
- static const uint64_t kUnitThresholds10[] = {
- 1000*1000*1000 /* G */, 2*1000*1000 /* M */, 3*1000 /* k */, 0,
- };
- static const uint64_t kAmountPerUnit2[] = { 1024*1024*1024, 1024*1024, 1024, 1 };
- static const uint64_t kAmountPerUnit10[] = { 1000*1000*1000, 1000*1000, 1000, 1 };
- static const char* const kUnitStrings2[] = { "Gi", "Mi", "Ki", "" };
- static const char* const kUnitStrings10[] = { "G", "M", "k", "" };
-
- // Which set are we using?
- const uint64_t* kUnitThresholds = ((base == 2) ? kUnitThresholds2 : kUnitThresholds10);
- const uint64_t* kAmountPerUnit = ((base == 2) ? kAmountPerUnit2 : kAmountPerUnit10);
- const char* const* kUnitStrings = ((base == 2) ? kUnitStrings2 : kUnitStrings10);
-
- size_t i = 0;
- for (; kUnitThresholds[i] != 0; ++i) {
- if (count >= kUnitThresholds[i]) {
- break;
- }
- }
- return android::base::StringPrintf("%s%" PRId64 "%s",
- negative_number ? "-" : "",
- count / kAmountPerUnit[i], kUnitStrings[i]);
-}
diff --git a/libc/bionic/__libc_init_main_thread.cpp b/libc/bionic/__libc_init_main_thread.cpp
index e1445cb..a29d8a7 100644
--- a/libc/bionic/__libc_init_main_thread.cpp
+++ b/libc/bionic/__libc_init_main_thread.cpp
@@ -74,6 +74,10 @@
main_thread.attr.stack_size = 0; // User code should never see this; we'll compute it when asked.
// TODO: the main thread's sched_policy and sched_priority need to be queried.
+ // The TLS stack guard is set from the global, so ensure that we've initialized the global
+ // before we initialize the TLS.
+ __libc_init_global_stack_chk_guard(args);
+
__init_thread(&main_thread);
__init_tls(&main_thread);
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index ebd1595..c2a5fed 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -64,10 +64,17 @@
// Declared in "private/bionic_ssp.h".
uintptr_t __stack_chk_guard = 0;
+void __libc_init_global_stack_chk_guard(KernelArgumentBlock& args) {
+ // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
+ // Take the first 4/8 for the -fstack-protector implementation.
+ __stack_chk_guard = *reinterpret_cast<uintptr_t*>(args.getauxval(AT_RANDOM));
+}
+
void __libc_init_globals(KernelArgumentBlock& args) {
// Initialize libc globals that are needed in both the linker and in libc.
// In dynamic binaries, this is run at least twice for different copies of the
// globals, once for the linker's copy and once for the one in libc.so.
+ __libc_init_global_stack_chk_guard(args);
__libc_auxv = args.auxv;
__libc_globals.initialize();
__libc_globals.mutate([&args](libc_globals* globals) {
@@ -83,9 +90,6 @@
__progname = args.argv[0] ? args.argv[0] : "<unknown>";
__abort_message_ptr = args.abort_message_ptr;
- // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
- __stack_chk_guard = *reinterpret_cast<uintptr_t*>(getauxval(AT_RANDOM));
-
// Get the main thread from TLS and add it to the thread list.
pthread_internal_t* main_thread = __get_thread();
__pthread_internal_add(main_thread);
diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c
index 829b679..cc8b8b4 100644
--- a/libc/dns/net/getaddrinfo.c
+++ b/libc/dns/net/getaddrinfo.c
@@ -1791,10 +1791,14 @@
return -1;
}
}
- if (mark != MARK_UNSET && setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0)
+ if (mark != MARK_UNSET && setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0) {
+ close(sock);
return 0;
- if (uid > 0 && uid != NET_CONTEXT_INVALID_UID && fchown(sock, uid, (gid_t)-1) < 0)
+ }
+ if (uid > 0 && uid != NET_CONTEXT_INVALID_UID && fchown(sock, uid, (gid_t)-1) < 0) {
+ close(sock);
return 0;
+ }
do {
ret = __connect(sock, addr, len);
} while (ret == -1 && errno == EINTR);
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index c802e3a..bcb05a0 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -25,10 +25,12 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#ifndef _PRIVATE_BIONIC_GLOBALS_H
#define _PRIVATE_BIONIC_GLOBALS_H
#include <sys/cdefs.h>
+
#include "private/bionic_malloc_dispatch.h"
#include "private/bionic_vdso.h"
#include "private/WriteProtected.h"
@@ -42,9 +44,9 @@
__LIBC_HIDDEN__ extern WriteProtected<libc_globals> __libc_globals;
class KernelArgumentBlock;
-__LIBC_HIDDEN__ void __libc_init_vdso(libc_globals* globals,
- KernelArgumentBlock& args);
-__LIBC_HIDDEN__ void __libc_init_setjmp_cookie(libc_globals* globals,
- KernelArgumentBlock& args);
+__LIBC_HIDDEN__ void __libc_init_global_stack_chk_guard(KernelArgumentBlock& args);
__LIBC_HIDDEN__ void __libc_init_malloc(libc_globals* globals);
+__LIBC_HIDDEN__ void __libc_init_setjmp_cookie(libc_globals* globals, KernelArgumentBlock& args);
+__LIBC_HIDDEN__ void __libc_init_vdso(libc_globals* globals, KernelArgumentBlock& args);
+
#endif
diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h
index f13615d..c61e2ff 100644
--- a/libc/private/bionic_tls.h
+++ b/libc/private/bionic_tls.h
@@ -30,7 +30,7 @@
#define __BIONIC_PRIVATE_BIONIC_TLS_H_
#include <sys/cdefs.h>
-#include <sys/limits.h>
+
#include "bionic_macros.h"
#include "__get_tls.h"
@@ -117,7 +117,7 @@
#if defined(__cplusplus)
class KernelArgumentBlock;
-extern __LIBC_HIDDEN__ void __libc_init_main_thread(KernelArgumentBlock&);
+extern void __libc_init_main_thread(KernelArgumentBlock&);
#endif
#endif /* __BIONIC_PRIVATE_BIONIC_TLS_H_ */
diff --git a/libm/Android.mk b/libm/Android.mk
index 7e0656d..5dd140b 100644
--- a/libm/Android.mk
+++ b/libm/Android.mk
@@ -345,6 +345,8 @@
x86/libm_reduce_pi04l.S \
x86/libm_sincos_huge.S \
x86/libm_tancot_huge.S \
+ x86/lrint.S \
+ x86/lrintf.S \
x86/s_atan.S \
x86/s_cbrt.S \
x86/s_cos.S \
@@ -372,6 +374,8 @@
upstream-freebsd/lib/msun/src/s_cos.c \
upstream-freebsd/lib/msun/src/s_expm1.c \
upstream-freebsd/lib/msun/src/s_log1p.c \
+ upstream-freebsd/lib/msun/src/s_lrint.c \
+ upstream-freebsd/lib/msun/src/s_lrintf.c \
upstream-freebsd/lib/msun/src/s_sin.c \
upstream-freebsd/lib/msun/src/s_tan.c \
upstream-freebsd/lib/msun/src/s_tanh.c \
@@ -382,6 +386,8 @@
x86/ceilf.S \
x86/floor.S \
x86/floorf.S \
+ x86/rint.S \
+ x86/rintf.S \
x86/trunc.S \
x86/truncf.S \
@@ -390,6 +396,8 @@
upstream-freebsd/lib/msun/src/s_ceilf.c \
upstream-freebsd/lib/msun/src/s_floor.c \
upstream-freebsd/lib/msun/src/s_floorf.c \
+ upstream-freebsd/lib/msun/src/s_rint.c \
+ upstream-freebsd/lib/msun/src/s_rintf.c \
upstream-freebsd/lib/msun/src/s_trunc.c \
upstream-freebsd/lib/msun/src/s_truncf.c \
@@ -412,6 +420,8 @@
x86_64/e_log.S \
x86_64/e_pow.S \
x86_64/e_sinh.S \
+ x86_64/lrint.S \
+ x86_64/lrintf.S \
x86_64/s_atan.S \
x86_64/s_cbrt.S \
x86_64/s_cos.S \
@@ -439,6 +449,10 @@
upstream-freebsd/lib/msun/src/s_cos.c \
upstream-freebsd/lib/msun/src/s_expm1.c \
upstream-freebsd/lib/msun/src/s_log1p.c \
+ upstream-freebsd/lib/msun/src/s_llrint.c \
+ upstream-freebsd/lib/msun/src/s_llrintf.c \
+ upstream-freebsd/lib/msun/src/s_lrint.c \
+ upstream-freebsd/lib/msun/src/s_lrintf.c \
upstream-freebsd/lib/msun/src/s_sin.c \
upstream-freebsd/lib/msun/src/s_tan.c \
upstream-freebsd/lib/msun/src/s_tanh.c \
@@ -449,6 +463,8 @@
x86_64/ceilf.S \
x86_64/floor.S \
x86_64/floorf.S \
+ x86_64/rint.S \
+ x86_64/rintf.S \
x86_64/trunc.S \
x86_64/truncf.S \
@@ -457,6 +473,8 @@
upstream-freebsd/lib/msun/src/s_ceilf.c \
upstream-freebsd/lib/msun/src/s_floor.c \
upstream-freebsd/lib/msun/src/s_floorf.c \
+ upstream-freebsd/lib/msun/src/s_rint.c \
+ upstream-freebsd/lib/msun/src/s_rintf.c \
upstream-freebsd/lib/msun/src/s_trunc.c \
upstream-freebsd/lib/msun/src/s_truncf.c \
diff --git a/libm/fake_long_double.c b/libm/fake_long_double.c
index 5edf839..20148a3 100644
--- a/libm/fake_long_double.c
+++ b/libm/fake_long_double.c
@@ -30,7 +30,9 @@
long double fminl(long double a1, long double a2) { return fmin(a1, a2); }
int ilogbl(long double a1) { return ilogb(a1); }
long long llrintl(long double a1) { return llrint(a1); }
+#if !defined(__i386__) // x86 has an assembler lrint/lrintl.
long lrintl(long double a1) { return lrint(a1); }
+#endif
long long llroundl(long double a1) { return llround(a1); }
long lroundl(long double a1) { return lround(a1); }
long double modfl(long double a1, long double* a2) { double i; double f = modf(a1, &i); *a2 = i; return f; }
diff --git a/libm/x86/lrint.S b/libm/x86/lrint.S
new file mode 100644
index 0000000..48d71dd
--- /dev/null
+++ b/libm/x86/lrint.S
@@ -0,0 +1,36 @@
+/*
+Copyright (c) 2014, Intel Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <private/bionic_asm.h>
+
+ENTRY(lrint)
+ // LP32 sizeof(long) == 4.
+ movsd 0x4(%esp),%xmm0
+ cvtsd2si %xmm0, %eax
+ ret
+END(lrint)
+
+// LP32 sizeof(long double) == sizeof(double).
+ALIAS_SYMBOL(lrintl, lrint);
diff --git a/libm/x86/lrintf.S b/libm/x86/lrintf.S
new file mode 100644
index 0000000..bc8fcb3
--- /dev/null
+++ b/libm/x86/lrintf.S
@@ -0,0 +1,33 @@
+/*
+Copyright (c) 2014, Intel Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <private/bionic_asm.h>
+
+ENTRY(lrintf)
+ // LP32 sizeof(long) == 4.
+ movss 0x4(%esp),%xmm0
+ cvtss2si %xmm0, %eax
+ ret
+END(lrintf)
diff --git a/libm/x86/rint.S b/libm/x86/rint.S
new file mode 100644
index 0000000..85635f2
--- /dev/null
+++ b/libm/x86/rint.S
@@ -0,0 +1,39 @@
+/*
+Copyright (c) 2014, Intel Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <private/bionic_asm.h>
+
+ENTRY(rint)
+ subl $12,%esp
+ movsd 16(%esp),%xmm0
+ roundsd $4,%xmm0,%xmm0
+ movsd %xmm0,(%esp)
+ fldl (%esp)
+ addl $12,%esp
+ ret
+END(rint)
+
+// LP32 sizeof(long double) == sizeof(double).
+ALIAS_SYMBOL(rintl, rint);
diff --git a/libm/x86/rintf.S b/libm/x86/rintf.S
new file mode 100644
index 0000000..9f82400
--- /dev/null
+++ b/libm/x86/rintf.S
@@ -0,0 +1,36 @@
+/*
+Copyright (c) 2014, Intel Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <private/bionic_asm.h>
+
+ENTRY(rintf)
+ subl $12,%esp
+ movss 16(%esp),%xmm0
+ roundss $4,%xmm0,%xmm0
+ movss %xmm0,(%esp)
+ flds (%esp)
+ add $12,%esp
+ ret
+END(rintf)
diff --git a/libm/x86_64/lrint.S b/libm/x86_64/lrint.S
new file mode 100644
index 0000000..f809a1f
--- /dev/null
+++ b/libm/x86_64/lrint.S
@@ -0,0 +1,35 @@
+/*
+Copyright (c) 2014, Intel Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <private/bionic_asm.h>
+
+ENTRY(lrint)
+ // LP64 sizeof(long) == 8.
+ cvtsd2si %xmm0, %rax
+ ret
+END(lrint)
+
+// LP64 sizeof(long long) == sizeof(long).
+ALIAS_SYMBOL(llrint, lrint);
diff --git a/libm/x86_64/lrintf.S b/libm/x86_64/lrintf.S
new file mode 100644
index 0000000..a661cbc
--- /dev/null
+++ b/libm/x86_64/lrintf.S
@@ -0,0 +1,35 @@
+/*
+Copyright (c) 2014, Intel Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <private/bionic_asm.h>
+
+ENTRY(lrintf)
+ // LP64 sizeof(long) == 8.
+ cvtss2si %xmm0, %rax
+ ret
+END(lrintf)
+
+// LP64 sizeof(long long) == sizeof(long).
+ALIAS_SYMBOL(llrintf, lrintf);
diff --git a/libm/x86_64/rint.S b/libm/x86_64/rint.S
new file mode 100644
index 0000000..098fdc5
--- /dev/null
+++ b/libm/x86_64/rint.S
@@ -0,0 +1,31 @@
+/*
+Copyright (c) 2014, Intel Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <private/bionic_asm.h>
+
+ENTRY(rint)
+ roundsd $0x4,%xmm0,%xmm0
+ retq
+END(rint)
diff --git a/libm/x86_64/rintf.S b/libm/x86_64/rintf.S
new file mode 100644
index 0000000..09f5e9c
--- /dev/null
+++ b/libm/x86_64/rintf.S
@@ -0,0 +1,31 @@
+/*
+Copyright (c) 2014, Intel Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of Intel Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <private/bionic_asm.h>
+
+ENTRY(rintf)
+ roundss $0x4,%xmm0,%xmm0
+ retq
+END(rintf)
diff --git a/linker/debugger.cpp b/linker/debugger.cpp
index b7e84ac..d4c7928 100644
--- a/linker/debugger.cpp
+++ b/linker/debugger.cpp
@@ -39,6 +39,7 @@
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/socket.h>
+#include <sys/syscall.h>
#include <sys/un.h>
#include <unistd.h>
@@ -61,7 +62,9 @@
DEBUGGER_ACTION_DUMP_BACKTRACE,
};
-/* message sent over the socket */
+// Message sent over the socket.
+// NOTE: Any changes to this structure must also be reflected in
+// system/core/include/cutils/debugger.h.
struct __attribute__((packed)) debugger_msg_t {
int32_t action;
pid_t tid;
@@ -267,26 +270,32 @@
send_debuggerd_packet(info);
- // Remove our net so we fault for real when we return.
+ // We need to return from the signal handler so that debuggerd can dump the
+ // thread that crashed, but returning here does not guarantee that the signal
+ // will be thrown again, even for SIGSEGV and friends, since the signal could
+ // have been sent manually. Resend the signal with rt_tgsigqueueinfo(2) to
+ // preserve the SA_SIGINFO contents.
signal(signal_number, SIG_DFL);
- // These signals are not re-thrown when we resume. This means that
- // crashing due to (say) SIGABRT doesn't work the way you'd expect it
- // to. We work around this by throwing them manually. We don't want
- // to do this for *all* signals because it'll screw up the si_addr for
- // faults like SIGSEGV. It does screw up the si_code, which is why we
- // passed that to debuggerd above.
- switch (signal_number) {
- case SIGABRT:
- case SIGFPE:
-#if defined(SIGSTKFLT)
- case SIGSTKFLT:
-#endif
- case SIGTRAP:
- tgkill(getpid(), gettid(), signal_number);
- break;
- default: // SIGILL, SIGBUS, SIGSEGV
- break;
+ struct siginfo si;
+ if (!info) {
+ memset(&si, 0, sizeof(si));
+ si.si_code = SI_USER;
+ si.si_pid = getpid();
+ si.si_uid = getuid();
+ info = &si;
+ } else if (info->si_code >= 0 || info->si_code == SI_TKILL) {
+ // rt_tgsigqueueinfo(2)'s documentation appears to be incorrect on kernels
+ // that contain commit 66dd34a (3.9+). The manpage claims to only allow
+ // negative si_code values that are not SI_TKILL, but 66dd34a changed the
+ // check to allow all si_code values in calls coming from inside the house.
+ }
+
+ int rc = syscall(SYS_rt_tgsigqueueinfo, getpid(), gettid(), signal_number, info);
+ if (rc != 0) {
+ __libc_format_log(ANDROID_LOG_FATAL, "libc", "failed to resend signal during crash: %s",
+ strerror(errno));
+ _exit(0);
}
}
diff --git a/tests/Android.mk b/tests/Android.mk
index 4afccac..aeb10ea 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -78,6 +78,7 @@
setjmp_test.cpp \
signal_test.cpp \
stack_protector_test.cpp \
+ stack_protector_test_helper.cpp \
stack_unwinding_test.cpp \
stdatomic_test.cpp \
stdint_test.cpp \
diff --git a/tests/math_data/llrint_intel_data.h b/tests/math_data/llrint_intel_data.h
new file mode 100644
index 0000000..a6861c2
--- /dev/null
+++ b/tests/math_data/llrint_intel_data.h
@@ -0,0 +1,1242 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+static data_llong_1_t<double> g_llrint_intel_data[] = {
+ { // Entry 0
+ (long long int)0.0,
+ -0x1.0p-1074
+ },
+ { // Entry 1
+ (long long int)0.0,
+ -0.0
+ },
+ { // Entry 2
+ (long long int)0.0,
+ 0x1.0p-1074
+ },
+ { // Entry 3
+ (long long int)0.0,
+ 0x1.fffffffffffffp-2
+ },
+ { // Entry 4
+ (long long int)0.0,
+ 0x1.0p-1
+ },
+ { // Entry 5
+ (long long int)0x1.p0,
+ 0x1.0000000000001p-1
+ },
+ { // Entry 6
+ (long long int)0x1.p0,
+ 0x1.fffffffffffffp-1
+ },
+ { // Entry 7
+ (long long int)0x1.p0,
+ 0x1.0p0
+ },
+ { // Entry 8
+ (long long int)0x1.p0,
+ 0x1.0000000000001p0
+ },
+ { // Entry 9
+ (long long int)0x1.p0,
+ 0x1.7ffffffffffffp0
+ },
+ { // Entry 10
+ (long long int)0x1.p1,
+ 0x1.8p0
+ },
+ { // Entry 11
+ (long long int)0x1.p1,
+ 0x1.8000000000001p0
+ },
+ { // Entry 12
+ (long long int)0x1.p1,
+ 0x1.fffffffffffffp0
+ },
+ { // Entry 13
+ (long long int)0x1.p1,
+ 0x1.0p1
+ },
+ { // Entry 14
+ (long long int)0x1.p1,
+ 0x1.0000000000001p1
+ },
+ { // Entry 15
+ (long long int)0x1.p1,
+ 0x1.3ffffffffffffp1
+ },
+ { // Entry 16
+ (long long int)0x1.p1,
+ 0x1.4p1
+ },
+ { // Entry 17
+ (long long int)0x1.80p1,
+ 0x1.4000000000001p1
+ },
+ { // Entry 18
+ (long long int)0x1.90p6,
+ 0x1.8ffffffffffffp6
+ },
+ { // Entry 19
+ (long long int)0x1.90p6,
+ 0x1.9p6
+ },
+ { // Entry 20
+ (long long int)0x1.90p6,
+ 0x1.9000000000001p6
+ },
+ { // Entry 21
+ (long long int)0x1.90p6,
+ 0x1.91fffffffffffp6
+ },
+ { // Entry 22
+ (long long int)0x1.90p6,
+ 0x1.920p6
+ },
+ { // Entry 23
+ (long long int)0x1.94p6,
+ 0x1.9200000000001p6
+ },
+ { // Entry 24
+ (long long int)0x1.f4p9,
+ 0x1.f3fffffffffffp9
+ },
+ { // Entry 25
+ (long long int)0x1.f4p9,
+ 0x1.f40p9
+ },
+ { // Entry 26
+ (long long int)0x1.f4p9,
+ 0x1.f400000000001p9
+ },
+ { // Entry 27
+ (long long int)0x1.f4p9,
+ 0x1.f43ffffffffffp9
+ },
+ { // Entry 28
+ (long long int)0x1.f4p9,
+ 0x1.f44p9
+ },
+ { // Entry 29
+ (long long int)0x1.f480p9,
+ 0x1.f440000000001p9
+ },
+ { // Entry 30
+ (long long int)0x1.p50,
+ 0x1.fffffffffffffp49
+ },
+ { // Entry 31
+ (long long int)0x1.p50,
+ 0x1.0p50
+ },
+ { // Entry 32
+ (long long int)0x1.p50,
+ 0x1.0000000000001p50
+ },
+ { // Entry 33
+ (long long int)0x1.p51,
+ 0x1.fffffffffffffp50
+ },
+ { // Entry 34
+ (long long int)0x1.p51,
+ 0x1.0p51
+ },
+ { // Entry 35
+ (long long int)0x1.p51,
+ 0x1.0000000000001p51
+ },
+ { // Entry 36
+ (long long int)0x1.p52,
+ 0x1.fffffffffffffp51
+ },
+ { // Entry 37
+ (long long int)0x1.p52,
+ 0x1.0p52
+ },
+ { // Entry 38
+ (long long int)0x1.00000000000010p52,
+ 0x1.0000000000001p52
+ },
+ { // Entry 39
+ (long long int)0x1.fffffffffffff0p52,
+ 0x1.fffffffffffffp52
+ },
+ { // Entry 40
+ (long long int)0x1.p53,
+ 0x1.0p53
+ },
+ { // Entry 41
+ (long long int)0x1.00000000000010p53,
+ 0x1.0000000000001p53
+ },
+ { // Entry 42
+ (long long int)0x1.fffffffffffff0p53,
+ 0x1.fffffffffffffp53
+ },
+ { // Entry 43
+ (long long int)0x1.p54,
+ 0x1.0p54
+ },
+ { // Entry 44
+ (long long int)0x1.00000000000010p54,
+ 0x1.0000000000001p54
+ },
+ { // Entry 45
+ (long long int)-0x1.p0,
+ -0x1.0000000000001p-1
+ },
+ { // Entry 46
+ (long long int)0.0,
+ -0x1.0p-1
+ },
+ { // Entry 47
+ (long long int)0.0,
+ -0x1.fffffffffffffp-2
+ },
+ { // Entry 48
+ (long long int)-0x1.p0,
+ -0x1.0000000000001p0
+ },
+ { // Entry 49
+ (long long int)-0x1.p0,
+ -0x1.0p0
+ },
+ { // Entry 50
+ (long long int)-0x1.p0,
+ -0x1.fffffffffffffp-1
+ },
+ { // Entry 51
+ (long long int)-0x1.p1,
+ -0x1.8000000000001p0
+ },
+ { // Entry 52
+ (long long int)-0x1.p1,
+ -0x1.8p0
+ },
+ { // Entry 53
+ (long long int)-0x1.p0,
+ -0x1.7ffffffffffffp0
+ },
+ { // Entry 54
+ (long long int)-0x1.p1,
+ -0x1.0000000000001p1
+ },
+ { // Entry 55
+ (long long int)-0x1.p1,
+ -0x1.0p1
+ },
+ { // Entry 56
+ (long long int)-0x1.p1,
+ -0x1.fffffffffffffp0
+ },
+ { // Entry 57
+ (long long int)-0x1.80p1,
+ -0x1.4000000000001p1
+ },
+ { // Entry 58
+ (long long int)-0x1.p1,
+ -0x1.4p1
+ },
+ { // Entry 59
+ (long long int)-0x1.p1,
+ -0x1.3ffffffffffffp1
+ },
+ { // Entry 60
+ (long long int)-0x1.90p6,
+ -0x1.9000000000001p6
+ },
+ { // Entry 61
+ (long long int)-0x1.90p6,
+ -0x1.9p6
+ },
+ { // Entry 62
+ (long long int)-0x1.90p6,
+ -0x1.8ffffffffffffp6
+ },
+ { // Entry 63
+ (long long int)-0x1.94p6,
+ -0x1.9200000000001p6
+ },
+ { // Entry 64
+ (long long int)-0x1.90p6,
+ -0x1.920p6
+ },
+ { // Entry 65
+ (long long int)-0x1.90p6,
+ -0x1.91fffffffffffp6
+ },
+ { // Entry 66
+ (long long int)-0x1.f4p9,
+ -0x1.f400000000001p9
+ },
+ { // Entry 67
+ (long long int)-0x1.f4p9,
+ -0x1.f40p9
+ },
+ { // Entry 68
+ (long long int)-0x1.f4p9,
+ -0x1.f3fffffffffffp9
+ },
+ { // Entry 69
+ (long long int)-0x1.f480p9,
+ -0x1.f440000000001p9
+ },
+ { // Entry 70
+ (long long int)-0x1.f4p9,
+ -0x1.f44p9
+ },
+ { // Entry 71
+ (long long int)-0x1.f4p9,
+ -0x1.f43ffffffffffp9
+ },
+ { // Entry 72
+ (long long int)-0x1.p50,
+ -0x1.0000000000001p50
+ },
+ { // Entry 73
+ (long long int)-0x1.p50,
+ -0x1.0p50
+ },
+ { // Entry 74
+ (long long int)-0x1.p50,
+ -0x1.fffffffffffffp49
+ },
+ { // Entry 75
+ (long long int)-0x1.p51,
+ -0x1.0000000000001p51
+ },
+ { // Entry 76
+ (long long int)-0x1.p51,
+ -0x1.0p51
+ },
+ { // Entry 77
+ (long long int)-0x1.p51,
+ -0x1.fffffffffffffp50
+ },
+ { // Entry 78
+ (long long int)-0x1.00000000000010p52,
+ -0x1.0000000000001p52
+ },
+ { // Entry 79
+ (long long int)-0x1.p52,
+ -0x1.0p52
+ },
+ { // Entry 80
+ (long long int)-0x1.p52,
+ -0x1.fffffffffffffp51
+ },
+ { // Entry 81
+ (long long int)-0x1.00000000000010p53,
+ -0x1.0000000000001p53
+ },
+ { // Entry 82
+ (long long int)-0x1.p53,
+ -0x1.0p53
+ },
+ { // Entry 83
+ (long long int)-0x1.fffffffffffff0p52,
+ -0x1.fffffffffffffp52
+ },
+ { // Entry 84
+ (long long int)-0x1.00000000000010p54,
+ -0x1.0000000000001p54
+ },
+ { // Entry 85
+ (long long int)-0x1.p54,
+ -0x1.0p54
+ },
+ { // Entry 86
+ (long long int)-0x1.fffffffffffff0p53,
+ -0x1.fffffffffffffp53
+ },
+ { // Entry 87
+ (long long int)0x1.p30,
+ 0x1.fffffffffffffp29
+ },
+ { // Entry 88
+ (long long int)0x1.p30,
+ 0x1.0p30
+ },
+ { // Entry 89
+ (long long int)0x1.p30,
+ 0x1.0000000000001p30
+ },
+ { // Entry 90
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffff7ffffep30
+ },
+ { // Entry 91
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffff7fffffp30
+ },
+ { // Entry 92
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffff80p30
+ },
+ { // Entry 93
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffff800001p30
+ },
+ { // Entry 94
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffff800002p30
+ },
+ { // Entry 95
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffff9ffffep30
+ },
+ { // Entry 96
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffff9fffffp30
+ },
+ { // Entry 97
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffffa0p30
+ },
+ { // Entry 98
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffa00001p30
+ },
+ { // Entry 99
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffa00002p30
+ },
+ { // Entry 100
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffbffffep30
+ },
+ { // Entry 101
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffbfffffp30
+ },
+ { // Entry 102
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffc0p30
+ },
+ { // Entry 103
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffc00001p30
+ },
+ { // Entry 104
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffc00002p30
+ },
+ { // Entry 105
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffdffffep30
+ },
+ { // Entry 106
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffdfffffp30
+ },
+ { // Entry 107
+ (long long int)0x1.p31,
+ 0x1.fffffffe0p30
+ },
+ { // Entry 108
+ (long long int)0x1.p31,
+ 0x1.fffffffe00001p30
+ },
+ { // Entry 109
+ (long long int)0x1.p31,
+ 0x1.fffffffe00002p30
+ },
+ { // Entry 110
+ (long long int)0x1.p31,
+ 0x1.ffffffffffffep30
+ },
+ { // Entry 111
+ (long long int)0x1.p31,
+ 0x1.fffffffffffffp30
+ },
+ { // Entry 112
+ (long long int)0x1.p31,
+ 0x1.0p31
+ },
+ { // Entry 113
+ (long long int)0x1.p31,
+ 0x1.0000000000001p31
+ },
+ { // Entry 114
+ (long long int)0x1.p31,
+ 0x1.0000000000002p31
+ },
+ { // Entry 115
+ (long long int)0x1.p31,
+ 0x1.00000000ffffep31
+ },
+ { // Entry 116
+ (long long int)0x1.p31,
+ 0x1.00000000fffffp31
+ },
+ { // Entry 117
+ (long long int)0x1.p31,
+ 0x1.000000010p31
+ },
+ { // Entry 118
+ (long long int)0x1.00000002p31,
+ 0x1.0000000100001p31
+ },
+ { // Entry 119
+ (long long int)0x1.00000002p31,
+ 0x1.0000000100002p31
+ },
+ { // Entry 120
+ (long long int)0x1.ffffffe0p30,
+ 0x1.ffffffep30
+ },
+ { // Entry 121
+ (long long int)0x1.ffffffe4p30,
+ 0x1.ffffffe40p30
+ },
+ { // Entry 122
+ (long long int)0x1.ffffffe8p30,
+ 0x1.ffffffe80p30
+ },
+ { // Entry 123
+ (long long int)0x1.ffffffecp30,
+ 0x1.ffffffec0p30
+ },
+ { // Entry 124
+ (long long int)0x1.fffffff0p30,
+ 0x1.fffffffp30
+ },
+ { // Entry 125
+ (long long int)0x1.fffffff4p30,
+ 0x1.fffffff40p30
+ },
+ { // Entry 126
+ (long long int)0x1.fffffff8p30,
+ 0x1.fffffff80p30
+ },
+ { // Entry 127
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffc0p30
+ },
+ { // Entry 128
+ (long long int)0x1.p31,
+ 0x1.0p31
+ },
+ { // Entry 129
+ (long long int)0x1.00000002p31,
+ 0x1.000000020p31
+ },
+ { // Entry 130
+ (long long int)-0x1.p30,
+ -0x1.0000000000001p30
+ },
+ { // Entry 131
+ (long long int)-0x1.p30,
+ -0x1.0p30
+ },
+ { // Entry 132
+ (long long int)-0x1.p30,
+ -0x1.fffffffffffffp29
+ },
+ { // Entry 133
+ (long long int)-0x1.fffffff8p30,
+ -0x1.fffffff800002p30
+ },
+ { // Entry 134
+ (long long int)-0x1.fffffff8p30,
+ -0x1.fffffff800001p30
+ },
+ { // Entry 135
+ (long long int)-0x1.fffffff8p30,
+ -0x1.fffffff80p30
+ },
+ { // Entry 136
+ (long long int)-0x1.fffffff8p30,
+ -0x1.fffffff7fffffp30
+ },
+ { // Entry 137
+ (long long int)-0x1.fffffff8p30,
+ -0x1.fffffff7ffffep30
+ },
+ { // Entry 138
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffa00002p30
+ },
+ { // Entry 139
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffa00001p30
+ },
+ { // Entry 140
+ (long long int)-0x1.fffffff8p30,
+ -0x1.fffffffa0p30
+ },
+ { // Entry 141
+ (long long int)-0x1.fffffff8p30,
+ -0x1.fffffff9fffffp30
+ },
+ { // Entry 142
+ (long long int)-0x1.fffffff8p30,
+ -0x1.fffffff9ffffep30
+ },
+ { // Entry 143
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffc00002p30
+ },
+ { // Entry 144
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffc00001p30
+ },
+ { // Entry 145
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffc0p30
+ },
+ { // Entry 146
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffbfffffp30
+ },
+ { // Entry 147
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffbffffep30
+ },
+ { // Entry 148
+ (long long int)-0x1.p31,
+ -0x1.fffffffe00002p30
+ },
+ { // Entry 149
+ (long long int)-0x1.p31,
+ -0x1.fffffffe00001p30
+ },
+ { // Entry 150
+ (long long int)-0x1.p31,
+ -0x1.fffffffe0p30
+ },
+ { // Entry 151
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffdfffffp30
+ },
+ { // Entry 152
+ (long long int)-0x1.fffffffcp30,
+ -0x1.fffffffdffffep30
+ },
+ { // Entry 153
+ (long long int)-0x1.p31,
+ -0x1.0000000000002p31
+ },
+ { // Entry 154
+ (long long int)-0x1.p31,
+ -0x1.0000000000001p31
+ },
+ { // Entry 155
+ (long long int)-0x1.p31,
+ -0x1.0p31
+ },
+ { // Entry 156
+ (long long int)-0x1.p31,
+ -0x1.fffffffffffffp30
+ },
+ { // Entry 157
+ (long long int)-0x1.p31,
+ -0x1.ffffffffffffep30
+ },
+ { // Entry 158
+ (long long int)-0x1.00000002p31,
+ -0x1.0000000100002p31
+ },
+ { // Entry 159
+ (long long int)-0x1.00000002p31,
+ -0x1.0000000100001p31
+ },
+ { // Entry 160
+ (long long int)-0x1.p31,
+ -0x1.000000010p31
+ },
+ { // Entry 161
+ (long long int)-0x1.p31,
+ -0x1.00000000fffffp31
+ },
+ { // Entry 162
+ (long long int)-0x1.p31,
+ -0x1.00000000ffffep31
+ },
+ { // Entry 163
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 164
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 165
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 166
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 167
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 168
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 169
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 170
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 171
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 172
+ (long long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 173
+ (long long int)0x1.ffffffffffffe0p61,
+ 0x1.ffffffffffffep61
+ },
+ { // Entry 174
+ (long long int)0x1.fffffffffffff0p61,
+ 0x1.fffffffffffffp61
+ },
+ { // Entry 175
+ (long long int)0x1.p62,
+ 0x1.0p62
+ },
+ { // Entry 176
+ (long long int)0x1.00000000000010p62,
+ 0x1.0000000000001p62
+ },
+ { // Entry 177
+ (long long int)0x1.00000000000020p62,
+ 0x1.0000000000002p62
+ },
+ { // Entry 178
+ (long long int)0x1.ffffffffffffe0p62,
+ 0x1.ffffffffffffep62
+ },
+ { // Entry 179
+ (long long int)0x1.fffffffffffff0p62,
+ 0x1.fffffffffffffp62
+ },
+ { // Entry 180
+ (long long int)-0x1.00000000000020p62,
+ -0x1.0000000000002p62
+ },
+ { // Entry 181
+ (long long int)-0x1.00000000000010p62,
+ -0x1.0000000000001p62
+ },
+ { // Entry 182
+ (long long int)-0x1.p62,
+ -0x1.0p62
+ },
+ { // Entry 183
+ (long long int)-0x1.fffffffffffff0p61,
+ -0x1.fffffffffffffp61
+ },
+ { // Entry 184
+ (long long int)-0x1.ffffffffffffe0p61,
+ -0x1.ffffffffffffep61
+ },
+ { // Entry 185
+ (long long int)-0x1.p63,
+ -0x1.0p63
+ },
+ { // Entry 186
+ (long long int)-0x1.fffffffffffff0p62,
+ -0x1.fffffffffffffp62
+ },
+ { // Entry 187
+ (long long int)-0x1.ffffffffffffe0p62,
+ -0x1.ffffffffffffep62
+ },
+ { // Entry 188
+ (long long int)0x1.p62,
+ 0x1.0p62
+ },
+ { // Entry 189
+ (long long int)-0x1.p62,
+ -0x1.0p62
+ },
+ { // Entry 190
+ (long long int)-0x1.p63,
+ -0x1.0p63
+ },
+ { // Entry 191
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffbfffffp30
+ },
+ { // Entry 192
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffc0p30
+ },
+ { // Entry 193
+ (long long int)0x1.fffffffcp30,
+ 0x1.fffffffc00001p30
+ },
+ { // Entry 194
+ (long long int)-0x1.p31,
+ -0x1.0000000000001p31
+ },
+ { // Entry 195
+ (long long int)-0x1.p31,
+ -0x1.0p31
+ },
+ { // Entry 196
+ (long long int)-0x1.p31,
+ -0x1.fffffffffffffp30
+ },
+ { // Entry 197
+ (long long int)0x1.p2,
+ 0x1.fffffffffffffp1
+ },
+ { // Entry 198
+ (long long int)0x1.p2,
+ 0x1.0p2
+ },
+ { // Entry 199
+ (long long int)0x1.p2,
+ 0x1.0000000000001p2
+ },
+ { // Entry 200
+ (long long int)0x1.p3,
+ 0x1.fffffffffffffp2
+ },
+ { // Entry 201
+ (long long int)0x1.p3,
+ 0x1.0p3
+ },
+ { // Entry 202
+ (long long int)0x1.p3,
+ 0x1.0000000000001p3
+ },
+ { // Entry 203
+ (long long int)0x1.p4,
+ 0x1.fffffffffffffp3
+ },
+ { // Entry 204
+ (long long int)0x1.p4,
+ 0x1.0p4
+ },
+ { // Entry 205
+ (long long int)0x1.p4,
+ 0x1.0000000000001p4
+ },
+ { // Entry 206
+ (long long int)0x1.p5,
+ 0x1.fffffffffffffp4
+ },
+ { // Entry 207
+ (long long int)0x1.p5,
+ 0x1.0p5
+ },
+ { // Entry 208
+ (long long int)0x1.p5,
+ 0x1.0000000000001p5
+ },
+ { // Entry 209
+ (long long int)0x1.p6,
+ 0x1.fffffffffffffp5
+ },
+ { // Entry 210
+ (long long int)0x1.p6,
+ 0x1.0p6
+ },
+ { // Entry 211
+ (long long int)0x1.p6,
+ 0x1.0000000000001p6
+ },
+ { // Entry 212
+ (long long int)0x1.p7,
+ 0x1.fffffffffffffp6
+ },
+ { // Entry 213
+ (long long int)0x1.p7,
+ 0x1.0p7
+ },
+ { // Entry 214
+ (long long int)0x1.p7,
+ 0x1.0000000000001p7
+ },
+ { // Entry 215
+ (long long int)0x1.p8,
+ 0x1.fffffffffffffp7
+ },
+ { // Entry 216
+ (long long int)0x1.p8,
+ 0x1.0p8
+ },
+ { // Entry 217
+ (long long int)0x1.p8,
+ 0x1.0000000000001p8
+ },
+ { // Entry 218
+ (long long int)0x1.p9,
+ 0x1.fffffffffffffp8
+ },
+ { // Entry 219
+ (long long int)0x1.p9,
+ 0x1.0p9
+ },
+ { // Entry 220
+ (long long int)0x1.p9,
+ 0x1.0000000000001p9
+ },
+ { // Entry 221
+ (long long int)0x1.p10,
+ 0x1.fffffffffffffp9
+ },
+ { // Entry 222
+ (long long int)0x1.p10,
+ 0x1.0p10
+ },
+ { // Entry 223
+ (long long int)0x1.p10,
+ 0x1.0000000000001p10
+ },
+ { // Entry 224
+ (long long int)0x1.p11,
+ 0x1.fffffffffffffp10
+ },
+ { // Entry 225
+ (long long int)0x1.p11,
+ 0x1.0p11
+ },
+ { // Entry 226
+ (long long int)0x1.p11,
+ 0x1.0000000000001p11
+ },
+ { // Entry 227
+ (long long int)0x1.p12,
+ 0x1.fffffffffffffp11
+ },
+ { // Entry 228
+ (long long int)0x1.p12,
+ 0x1.0p12
+ },
+ { // Entry 229
+ (long long int)0x1.p12,
+ 0x1.0000000000001p12
+ },
+ { // Entry 230
+ (long long int)0x1.p2,
+ 0x1.1ffffffffffffp2
+ },
+ { // Entry 231
+ (long long int)0x1.p2,
+ 0x1.2p2
+ },
+ { // Entry 232
+ (long long int)0x1.40p2,
+ 0x1.2000000000001p2
+ },
+ { // Entry 233
+ (long long int)0x1.p3,
+ 0x1.0ffffffffffffp3
+ },
+ { // Entry 234
+ (long long int)0x1.p3,
+ 0x1.1p3
+ },
+ { // Entry 235
+ (long long int)0x1.20p3,
+ 0x1.1000000000001p3
+ },
+ { // Entry 236
+ (long long int)0x1.p4,
+ 0x1.07fffffffffffp4
+ },
+ { // Entry 237
+ (long long int)0x1.p4,
+ 0x1.080p4
+ },
+ { // Entry 238
+ (long long int)0x1.10p4,
+ 0x1.0800000000001p4
+ },
+ { // Entry 239
+ (long long int)0x1.p5,
+ 0x1.03fffffffffffp5
+ },
+ { // Entry 240
+ (long long int)0x1.p5,
+ 0x1.040p5
+ },
+ { // Entry 241
+ (long long int)0x1.08p5,
+ 0x1.0400000000001p5
+ },
+ { // Entry 242
+ (long long int)0x1.p6,
+ 0x1.01fffffffffffp6
+ },
+ { // Entry 243
+ (long long int)0x1.p6,
+ 0x1.020p6
+ },
+ { // Entry 244
+ (long long int)0x1.04p6,
+ 0x1.0200000000001p6
+ },
+ { // Entry 245
+ (long long int)0x1.p7,
+ 0x1.00fffffffffffp7
+ },
+ { // Entry 246
+ (long long int)0x1.p7,
+ 0x1.010p7
+ },
+ { // Entry 247
+ (long long int)0x1.02p7,
+ 0x1.0100000000001p7
+ },
+ { // Entry 248
+ (long long int)0x1.p8,
+ 0x1.007ffffffffffp8
+ },
+ { // Entry 249
+ (long long int)0x1.p8,
+ 0x1.008p8
+ },
+ { // Entry 250
+ (long long int)0x1.01p8,
+ 0x1.0080000000001p8
+ },
+ { // Entry 251
+ (long long int)0x1.p9,
+ 0x1.003ffffffffffp9
+ },
+ { // Entry 252
+ (long long int)0x1.p9,
+ 0x1.004p9
+ },
+ { // Entry 253
+ (long long int)0x1.0080p9,
+ 0x1.0040000000001p9
+ },
+ { // Entry 254
+ (long long int)0x1.p10,
+ 0x1.001ffffffffffp10
+ },
+ { // Entry 255
+ (long long int)0x1.p10,
+ 0x1.002p10
+ },
+ { // Entry 256
+ (long long int)0x1.0040p10,
+ 0x1.0020000000001p10
+ },
+ { // Entry 257
+ (long long int)0x1.0040p10,
+ 0x1.005ffffffffffp10
+ },
+ { // Entry 258
+ (long long int)0x1.0080p10,
+ 0x1.006p10
+ },
+ { // Entry 259
+ (long long int)0x1.0080p10,
+ 0x1.0060000000001p10
+ },
+ { // Entry 260
+ (long long int)0x1.p11,
+ 0x1.000ffffffffffp11
+ },
+ { // Entry 261
+ (long long int)0x1.p11,
+ 0x1.001p11
+ },
+ { // Entry 262
+ (long long int)0x1.0020p11,
+ 0x1.0010000000001p11
+ },
+ { // Entry 263
+ (long long int)0x1.p12,
+ 0x1.0007fffffffffp12
+ },
+ { // Entry 264
+ (long long int)0x1.p12,
+ 0x1.00080p12
+ },
+ { // Entry 265
+ (long long int)0x1.0010p12,
+ 0x1.0008000000001p12
+ },
+ { // Entry 266
+ (long long int)0x1.80p1,
+ 0x1.921fb54442d18p1
+ },
+ { // Entry 267
+ (long long int)-0x1.80p1,
+ -0x1.921fb54442d18p1
+ },
+ { // Entry 268
+ (long long int)0x1.p1,
+ 0x1.921fb54442d18p0
+ },
+ { // Entry 269
+ (long long int)-0x1.p1,
+ -0x1.921fb54442d18p0
+ },
+ { // Entry 270
+ (long long int)0x1.p0,
+ 0x1.0000000000001p0
+ },
+ { // Entry 271
+ (long long int)-0x1.p0,
+ -0x1.0000000000001p0
+ },
+ { // Entry 272
+ (long long int)0x1.p0,
+ 0x1.0p0
+ },
+ { // Entry 273
+ (long long int)-0x1.p0,
+ -0x1.0p0
+ },
+ { // Entry 274
+ (long long int)0x1.p0,
+ 0x1.fffffffffffffp-1
+ },
+ { // Entry 275
+ (long long int)-0x1.p0,
+ -0x1.fffffffffffffp-1
+ },
+ { // Entry 276
+ (long long int)0x1.p0,
+ 0x1.921fb54442d18p-1
+ },
+ { // Entry 277
+ (long long int)-0x1.p0,
+ -0x1.921fb54442d18p-1
+ },
+ { // Entry 278
+ (long long int)0.0,
+ 0x1.0000000000001p-1022
+ },
+ { // Entry 279
+ (long long int)0.0,
+ -0x1.0000000000001p-1022
+ },
+ { // Entry 280
+ (long long int)0.0,
+ 0x1.0p-1022
+ },
+ { // Entry 281
+ (long long int)0.0,
+ -0x1.0p-1022
+ },
+ { // Entry 282
+ (long long int)0.0,
+ 0x1.ffffffffffffep-1023
+ },
+ { // Entry 283
+ (long long int)0.0,
+ -0x1.ffffffffffffep-1023
+ },
+ { // Entry 284
+ (long long int)0.0,
+ 0x1.ffffffffffffcp-1023
+ },
+ { // Entry 285
+ (long long int)0.0,
+ -0x1.ffffffffffffcp-1023
+ },
+ { // Entry 286
+ (long long int)0.0,
+ 0x1.0p-1073
+ },
+ { // Entry 287
+ (long long int)0.0,
+ -0x1.0p-1073
+ },
+ { // Entry 288
+ (long long int)0.0,
+ 0x1.0p-1074
+ },
+ { // Entry 289
+ (long long int)0.0,
+ -0x1.0p-1074
+ },
+ { // Entry 290
+ (long long int)0.0,
+ 0.0
+ },
+ { // Entry 291
+ (long long int)0.0,
+ -0.0
+ },
+ { // Entry 292
+ (long long int)0x1.p1,
+ 0x1.8p0
+ },
+ { // Entry 293
+ (long long int)-0x1.p1,
+ -0x1.8p0
+ },
+ { // Entry 294
+ (long long int)0x1.p1,
+ 0x1.4p1
+ },
+ { // Entry 295
+ (long long int)-0x1.p1,
+ -0x1.4p1
+ },
+ { // Entry 296
+ (long long int)0.0,
+ 0x1.fffffp-2
+ },
+ { // Entry 297
+ (long long int)0.0,
+ 0x1.0p-1
+ },
+ { // Entry 298
+ (long long int)0x1.p0,
+ 0x1.00001p-1
+ },
+ { // Entry 299
+ (long long int)0.0,
+ -0x1.fffffp-2
+ },
+ { // Entry 300
+ (long long int)0.0,
+ -0x1.0p-1
+ },
+ { // Entry 301
+ (long long int)-0x1.p0,
+ -0x1.00001p-1
+ },
+ { // Entry 302
+ (long long int)0x1.p1,
+ 0x1.80001p0
+ },
+ { // Entry 303
+ (long long int)0x1.p0,
+ 0x1.7ffffp0
+ },
+ { // Entry 304
+ (long long int)-0x1.p1,
+ -0x1.80001p0
+ },
+ { // Entry 305
+ (long long int)-0x1.p0,
+ -0x1.7ffffp0
+ }
+};
\ No newline at end of file
diff --git a/tests/math_data/llrintf_intel_data.h b/tests/math_data/llrintf_intel_data.h
new file mode 100644
index 0000000..ecb22da
--- /dev/null
+++ b/tests/math_data/llrintf_intel_data.h
@@ -0,0 +1,1242 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+static data_llong_1_t<float> g_llrintf_intel_data[] = {
+ { // Entry 0
+ (long long int)0.0,
+ -0x1.p-149
+ },
+ { // Entry 1
+ (long long int)0.0,
+ 0.0
+ },
+ { // Entry 2
+ (long long int)0.0,
+ 0x1.p-149
+ },
+ { // Entry 3
+ (long long int)0.0,
+ 0x1.fffffep-2
+ },
+ { // Entry 4
+ (long long int)0.0,
+ 0x1.p-1
+ },
+ { // Entry 5
+ (long long int)0x1.p0,
+ 0x1.000002p-1
+ },
+ { // Entry 6
+ (long long int)0x1.p0,
+ 0x1.fffffep-1
+ },
+ { // Entry 7
+ (long long int)0x1.p0,
+ 0x1.p0
+ },
+ { // Entry 8
+ (long long int)0x1.p0,
+ 0x1.000002p0
+ },
+ { // Entry 9
+ (long long int)0x1.p0,
+ 0x1.7ffffep0
+ },
+ { // Entry 10
+ (long long int)0x1.p1,
+ 0x1.80p0
+ },
+ { // Entry 11
+ (long long int)0x1.p1,
+ 0x1.800002p0
+ },
+ { // Entry 12
+ (long long int)0x1.p1,
+ 0x1.fffffep0
+ },
+ { // Entry 13
+ (long long int)0x1.p1,
+ 0x1.p1
+ },
+ { // Entry 14
+ (long long int)0x1.p1,
+ 0x1.000002p1
+ },
+ { // Entry 15
+ (long long int)0x1.p1,
+ 0x1.3ffffep1
+ },
+ { // Entry 16
+ (long long int)0x1.p1,
+ 0x1.40p1
+ },
+ { // Entry 17
+ (long long int)0x1.80p1,
+ 0x1.400002p1
+ },
+ { // Entry 18
+ (long long int)0x1.90p6,
+ 0x1.8ffffep6
+ },
+ { // Entry 19
+ (long long int)0x1.90p6,
+ 0x1.90p6
+ },
+ { // Entry 20
+ (long long int)0x1.90p6,
+ 0x1.900002p6
+ },
+ { // Entry 21
+ (long long int)0x1.90p6,
+ 0x1.91fffep6
+ },
+ { // Entry 22
+ (long long int)0x1.90p6,
+ 0x1.92p6
+ },
+ { // Entry 23
+ (long long int)0x1.94p6,
+ 0x1.920002p6
+ },
+ { // Entry 24
+ (long long int)0x1.f4p9,
+ 0x1.f3fffep9
+ },
+ { // Entry 25
+ (long long int)0x1.f4p9,
+ 0x1.f4p9
+ },
+ { // Entry 26
+ (long long int)0x1.f4p9,
+ 0x1.f40002p9
+ },
+ { // Entry 27
+ (long long int)0x1.f4p9,
+ 0x1.f43ffep9
+ },
+ { // Entry 28
+ (long long int)0x1.f4p9,
+ 0x1.f440p9
+ },
+ { // Entry 29
+ (long long int)0x1.f480p9,
+ 0x1.f44002p9
+ },
+ { // Entry 30
+ (long long int)0x1.p21,
+ 0x1.fffffep20
+ },
+ { // Entry 31
+ (long long int)0x1.p21,
+ 0x1.p21
+ },
+ { // Entry 32
+ (long long int)0x1.p21,
+ 0x1.000002p21
+ },
+ { // Entry 33
+ (long long int)0x1.p22,
+ 0x1.fffffep21
+ },
+ { // Entry 34
+ (long long int)0x1.p22,
+ 0x1.p22
+ },
+ { // Entry 35
+ (long long int)0x1.p22,
+ 0x1.000002p22
+ },
+ { // Entry 36
+ (long long int)0x1.p23,
+ 0x1.fffffep22
+ },
+ { // Entry 37
+ (long long int)0x1.p23,
+ 0x1.p23
+ },
+ { // Entry 38
+ (long long int)0x1.000002p23,
+ 0x1.000002p23
+ },
+ { // Entry 39
+ (long long int)0x1.fffffep23,
+ 0x1.fffffep23
+ },
+ { // Entry 40
+ (long long int)0x1.p24,
+ 0x1.p24
+ },
+ { // Entry 41
+ (long long int)0x1.000002p24,
+ 0x1.000002p24
+ },
+ { // Entry 42
+ (long long int)0x1.fffffep24,
+ 0x1.fffffep24
+ },
+ { // Entry 43
+ (long long int)0x1.p25,
+ 0x1.p25
+ },
+ { // Entry 44
+ (long long int)0x1.000002p25,
+ 0x1.000002p25
+ },
+ { // Entry 45
+ (long long int)-0x1.p0,
+ -0x1.000002p-1
+ },
+ { // Entry 46
+ (long long int)0.0,
+ -0x1.p-1
+ },
+ { // Entry 47
+ (long long int)0.0,
+ -0x1.fffffep-2
+ },
+ { // Entry 48
+ (long long int)-0x1.p0,
+ -0x1.000002p0
+ },
+ { // Entry 49
+ (long long int)-0x1.p0,
+ -0x1.p0
+ },
+ { // Entry 50
+ (long long int)-0x1.p0,
+ -0x1.fffffep-1
+ },
+ { // Entry 51
+ (long long int)-0x1.p1,
+ -0x1.800002p0
+ },
+ { // Entry 52
+ (long long int)-0x1.p1,
+ -0x1.80p0
+ },
+ { // Entry 53
+ (long long int)-0x1.p0,
+ -0x1.7ffffep0
+ },
+ { // Entry 54
+ (long long int)-0x1.p1,
+ -0x1.000002p1
+ },
+ { // Entry 55
+ (long long int)-0x1.p1,
+ -0x1.p1
+ },
+ { // Entry 56
+ (long long int)-0x1.p1,
+ -0x1.fffffep0
+ },
+ { // Entry 57
+ (long long int)-0x1.80p1,
+ -0x1.400002p1
+ },
+ { // Entry 58
+ (long long int)-0x1.p1,
+ -0x1.40p1
+ },
+ { // Entry 59
+ (long long int)-0x1.p1,
+ -0x1.3ffffep1
+ },
+ { // Entry 60
+ (long long int)-0x1.90p6,
+ -0x1.900002p6
+ },
+ { // Entry 61
+ (long long int)-0x1.90p6,
+ -0x1.90p6
+ },
+ { // Entry 62
+ (long long int)-0x1.90p6,
+ -0x1.8ffffep6
+ },
+ { // Entry 63
+ (long long int)-0x1.94p6,
+ -0x1.920002p6
+ },
+ { // Entry 64
+ (long long int)-0x1.90p6,
+ -0x1.92p6
+ },
+ { // Entry 65
+ (long long int)-0x1.90p6,
+ -0x1.91fffep6
+ },
+ { // Entry 66
+ (long long int)-0x1.f4p9,
+ -0x1.f40002p9
+ },
+ { // Entry 67
+ (long long int)-0x1.f4p9,
+ -0x1.f4p9
+ },
+ { // Entry 68
+ (long long int)-0x1.f4p9,
+ -0x1.f3fffep9
+ },
+ { // Entry 69
+ (long long int)-0x1.f480p9,
+ -0x1.f44002p9
+ },
+ { // Entry 70
+ (long long int)-0x1.f4p9,
+ -0x1.f440p9
+ },
+ { // Entry 71
+ (long long int)-0x1.f4p9,
+ -0x1.f43ffep9
+ },
+ { // Entry 72
+ (long long int)-0x1.p21,
+ -0x1.000002p21
+ },
+ { // Entry 73
+ (long long int)-0x1.p21,
+ -0x1.p21
+ },
+ { // Entry 74
+ (long long int)-0x1.p21,
+ -0x1.fffffep20
+ },
+ { // Entry 75
+ (long long int)-0x1.p22,
+ -0x1.000002p22
+ },
+ { // Entry 76
+ (long long int)-0x1.p22,
+ -0x1.p22
+ },
+ { // Entry 77
+ (long long int)-0x1.p22,
+ -0x1.fffffep21
+ },
+ { // Entry 78
+ (long long int)-0x1.000002p23,
+ -0x1.000002p23
+ },
+ { // Entry 79
+ (long long int)-0x1.p23,
+ -0x1.p23
+ },
+ { // Entry 80
+ (long long int)-0x1.p23,
+ -0x1.fffffep22
+ },
+ { // Entry 81
+ (long long int)-0x1.000002p24,
+ -0x1.000002p24
+ },
+ { // Entry 82
+ (long long int)-0x1.p24,
+ -0x1.p24
+ },
+ { // Entry 83
+ (long long int)-0x1.fffffep23,
+ -0x1.fffffep23
+ },
+ { // Entry 84
+ (long long int)-0x1.000002p25,
+ -0x1.000002p25
+ },
+ { // Entry 85
+ (long long int)-0x1.p25,
+ -0x1.p25
+ },
+ { // Entry 86
+ (long long int)-0x1.fffffep24,
+ -0x1.fffffep24
+ },
+ { // Entry 87
+ (long long int)0x1.fffffep29,
+ 0x1.fffffep29
+ },
+ { // Entry 88
+ (long long int)0x1.p30,
+ 0x1.p30
+ },
+ { // Entry 89
+ (long long int)0x1.000002p30,
+ 0x1.000002p30
+ },
+ { // Entry 90
+ (long long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 91
+ (long long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 92
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 93
+ (long long int)0x1.000002p31,
+ 0x1.000002p31
+ },
+ { // Entry 94
+ (long long int)0x1.000004p31,
+ 0x1.000004p31
+ },
+ { // Entry 95
+ (long long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 96
+ (long long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 97
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 98
+ (long long int)0x1.000002p31,
+ 0x1.000002p31
+ },
+ { // Entry 99
+ (long long int)0x1.000004p31,
+ 0x1.000004p31
+ },
+ { // Entry 100
+ (long long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 101
+ (long long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 102
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 103
+ (long long int)0x1.000002p31,
+ 0x1.000002p31
+ },
+ { // Entry 104
+ (long long int)0x1.000004p31,
+ 0x1.000004p31
+ },
+ { // Entry 105
+ (long long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 106
+ (long long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 107
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 108
+ (long long int)0x1.000002p31,
+ 0x1.000002p31
+ },
+ { // Entry 109
+ (long long int)0x1.000004p31,
+ 0x1.000004p31
+ },
+ { // Entry 110
+ (long long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 111
+ (long long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 112
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 113
+ (long long int)0x1.000002p31,
+ 0x1.000002p31
+ },
+ { // Entry 114
+ (long long int)0x1.000004p31,
+ 0x1.000004p31
+ },
+ { // Entry 115
+ (long long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 116
+ (long long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 117
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 118
+ (long long int)0x1.000002p31,
+ 0x1.000002p31
+ },
+ { // Entry 119
+ (long long int)0x1.000004p31,
+ 0x1.000004p31
+ },
+ { // Entry 120
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 121
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 122
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 123
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 124
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 125
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 126
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 127
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 128
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 129
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 130
+ (long long int)-0x1.000002p30,
+ -0x1.000002p30
+ },
+ { // Entry 131
+ (long long int)-0x1.p30,
+ -0x1.p30
+ },
+ { // Entry 132
+ (long long int)-0x1.fffffep29,
+ -0x1.fffffep29
+ },
+ { // Entry 133
+ (long long int)-0x1.000004p31,
+ -0x1.000004p31
+ },
+ { // Entry 134
+ (long long int)-0x1.000002p31,
+ -0x1.000002p31
+ },
+ { // Entry 135
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 136
+ (long long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 137
+ (long long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 138
+ (long long int)-0x1.000004p31,
+ -0x1.000004p31
+ },
+ { // Entry 139
+ (long long int)-0x1.000002p31,
+ -0x1.000002p31
+ },
+ { // Entry 140
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 141
+ (long long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 142
+ (long long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 143
+ (long long int)-0x1.000004p31,
+ -0x1.000004p31
+ },
+ { // Entry 144
+ (long long int)-0x1.000002p31,
+ -0x1.000002p31
+ },
+ { // Entry 145
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 146
+ (long long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 147
+ (long long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 148
+ (long long int)-0x1.000004p31,
+ -0x1.000004p31
+ },
+ { // Entry 149
+ (long long int)-0x1.000002p31,
+ -0x1.000002p31
+ },
+ { // Entry 150
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 151
+ (long long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 152
+ (long long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 153
+ (long long int)-0x1.000004p31,
+ -0x1.000004p31
+ },
+ { // Entry 154
+ (long long int)-0x1.000002p31,
+ -0x1.000002p31
+ },
+ { // Entry 155
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 156
+ (long long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 157
+ (long long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 158
+ (long long int)-0x1.000004p31,
+ -0x1.000004p31
+ },
+ { // Entry 159
+ (long long int)-0x1.000002p31,
+ -0x1.000002p31
+ },
+ { // Entry 160
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 161
+ (long long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 162
+ (long long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 163
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 164
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 165
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 166
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 167
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 168
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 169
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 170
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 171
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 172
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 173
+ (long long int)0x1.fffffcp61,
+ 0x1.fffffcp61
+ },
+ { // Entry 174
+ (long long int)0x1.fffffep61,
+ 0x1.fffffep61
+ },
+ { // Entry 175
+ (long long int)0x1.p62,
+ 0x1.p62
+ },
+ { // Entry 176
+ (long long int)0x1.000002p62,
+ 0x1.000002p62
+ },
+ { // Entry 177
+ (long long int)0x1.000004p62,
+ 0x1.000004p62
+ },
+ { // Entry 178
+ (long long int)0x1.fffffcp62,
+ 0x1.fffffcp62
+ },
+ { // Entry 179
+ (long long int)0x1.fffffep62,
+ 0x1.fffffep62
+ },
+ { // Entry 180
+ (long long int)-0x1.000004p62,
+ -0x1.000004p62
+ },
+ { // Entry 181
+ (long long int)-0x1.000002p62,
+ -0x1.000002p62
+ },
+ { // Entry 182
+ (long long int)-0x1.p62,
+ -0x1.p62
+ },
+ { // Entry 183
+ (long long int)-0x1.fffffep61,
+ -0x1.fffffep61
+ },
+ { // Entry 184
+ (long long int)-0x1.fffffcp61,
+ -0x1.fffffcp61
+ },
+ { // Entry 185
+ (long long int)-0x1.p63,
+ -0x1.p63
+ },
+ { // Entry 186
+ (long long int)-0x1.fffffep62,
+ -0x1.fffffep62
+ },
+ { // Entry 187
+ (long long int)-0x1.fffffcp62,
+ -0x1.fffffcp62
+ },
+ { // Entry 188
+ (long long int)0x1.p62,
+ 0x1.p62
+ },
+ { // Entry 189
+ (long long int)-0x1.p62,
+ -0x1.p62
+ },
+ { // Entry 190
+ (long long int)-0x1.p63,
+ -0x1.p63
+ },
+ { // Entry 191
+ (long long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 192
+ (long long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 193
+ (long long int)0x1.p31,
+ 0x1.p31
+ },
+ { // Entry 194
+ (long long int)-0x1.000002p31,
+ -0x1.000002p31
+ },
+ { // Entry 195
+ (long long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 196
+ (long long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 197
+ (long long int)0x1.p2,
+ 0x1.fffffep1
+ },
+ { // Entry 198
+ (long long int)0x1.p2,
+ 0x1.p2
+ },
+ { // Entry 199
+ (long long int)0x1.p2,
+ 0x1.000002p2
+ },
+ { // Entry 200
+ (long long int)0x1.p3,
+ 0x1.fffffep2
+ },
+ { // Entry 201
+ (long long int)0x1.p3,
+ 0x1.p3
+ },
+ { // Entry 202
+ (long long int)0x1.p3,
+ 0x1.000002p3
+ },
+ { // Entry 203
+ (long long int)0x1.p4,
+ 0x1.fffffep3
+ },
+ { // Entry 204
+ (long long int)0x1.p4,
+ 0x1.p4
+ },
+ { // Entry 205
+ (long long int)0x1.p4,
+ 0x1.000002p4
+ },
+ { // Entry 206
+ (long long int)0x1.p5,
+ 0x1.fffffep4
+ },
+ { // Entry 207
+ (long long int)0x1.p5,
+ 0x1.p5
+ },
+ { // Entry 208
+ (long long int)0x1.p5,
+ 0x1.000002p5
+ },
+ { // Entry 209
+ (long long int)0x1.p6,
+ 0x1.fffffep5
+ },
+ { // Entry 210
+ (long long int)0x1.p6,
+ 0x1.p6
+ },
+ { // Entry 211
+ (long long int)0x1.p6,
+ 0x1.000002p6
+ },
+ { // Entry 212
+ (long long int)0x1.p7,
+ 0x1.fffffep6
+ },
+ { // Entry 213
+ (long long int)0x1.p7,
+ 0x1.p7
+ },
+ { // Entry 214
+ (long long int)0x1.p7,
+ 0x1.000002p7
+ },
+ { // Entry 215
+ (long long int)0x1.p8,
+ 0x1.fffffep7
+ },
+ { // Entry 216
+ (long long int)0x1.p8,
+ 0x1.p8
+ },
+ { // Entry 217
+ (long long int)0x1.p8,
+ 0x1.000002p8
+ },
+ { // Entry 218
+ (long long int)0x1.p9,
+ 0x1.fffffep8
+ },
+ { // Entry 219
+ (long long int)0x1.p9,
+ 0x1.p9
+ },
+ { // Entry 220
+ (long long int)0x1.p9,
+ 0x1.000002p9
+ },
+ { // Entry 221
+ (long long int)0x1.p10,
+ 0x1.fffffep9
+ },
+ { // Entry 222
+ (long long int)0x1.p10,
+ 0x1.p10
+ },
+ { // Entry 223
+ (long long int)0x1.p10,
+ 0x1.000002p10
+ },
+ { // Entry 224
+ (long long int)0x1.p11,
+ 0x1.fffffep10
+ },
+ { // Entry 225
+ (long long int)0x1.p11,
+ 0x1.p11
+ },
+ { // Entry 226
+ (long long int)0x1.p11,
+ 0x1.000002p11
+ },
+ { // Entry 227
+ (long long int)0x1.p12,
+ 0x1.fffffep11
+ },
+ { // Entry 228
+ (long long int)0x1.p12,
+ 0x1.p12
+ },
+ { // Entry 229
+ (long long int)0x1.p12,
+ 0x1.000002p12
+ },
+ { // Entry 230
+ (long long int)0x1.p2,
+ 0x1.1ffffep2
+ },
+ { // Entry 231
+ (long long int)0x1.p2,
+ 0x1.20p2
+ },
+ { // Entry 232
+ (long long int)0x1.40p2,
+ 0x1.200002p2
+ },
+ { // Entry 233
+ (long long int)0x1.p3,
+ 0x1.0ffffep3
+ },
+ { // Entry 234
+ (long long int)0x1.p3,
+ 0x1.10p3
+ },
+ { // Entry 235
+ (long long int)0x1.20p3,
+ 0x1.100002p3
+ },
+ { // Entry 236
+ (long long int)0x1.p4,
+ 0x1.07fffep4
+ },
+ { // Entry 237
+ (long long int)0x1.p4,
+ 0x1.08p4
+ },
+ { // Entry 238
+ (long long int)0x1.10p4,
+ 0x1.080002p4
+ },
+ { // Entry 239
+ (long long int)0x1.p5,
+ 0x1.03fffep5
+ },
+ { // Entry 240
+ (long long int)0x1.p5,
+ 0x1.04p5
+ },
+ { // Entry 241
+ (long long int)0x1.08p5,
+ 0x1.040002p5
+ },
+ { // Entry 242
+ (long long int)0x1.p6,
+ 0x1.01fffep6
+ },
+ { // Entry 243
+ (long long int)0x1.p6,
+ 0x1.02p6
+ },
+ { // Entry 244
+ (long long int)0x1.04p6,
+ 0x1.020002p6
+ },
+ { // Entry 245
+ (long long int)0x1.p7,
+ 0x1.00fffep7
+ },
+ { // Entry 246
+ (long long int)0x1.p7,
+ 0x1.01p7
+ },
+ { // Entry 247
+ (long long int)0x1.02p7,
+ 0x1.010002p7
+ },
+ { // Entry 248
+ (long long int)0x1.p8,
+ 0x1.007ffep8
+ },
+ { // Entry 249
+ (long long int)0x1.p8,
+ 0x1.0080p8
+ },
+ { // Entry 250
+ (long long int)0x1.01p8,
+ 0x1.008002p8
+ },
+ { // Entry 251
+ (long long int)0x1.p9,
+ 0x1.003ffep9
+ },
+ { // Entry 252
+ (long long int)0x1.p9,
+ 0x1.0040p9
+ },
+ { // Entry 253
+ (long long int)0x1.0080p9,
+ 0x1.004002p9
+ },
+ { // Entry 254
+ (long long int)0x1.p10,
+ 0x1.001ffep10
+ },
+ { // Entry 255
+ (long long int)0x1.p10,
+ 0x1.0020p10
+ },
+ { // Entry 256
+ (long long int)0x1.0040p10,
+ 0x1.002002p10
+ },
+ { // Entry 257
+ (long long int)0x1.0040p10,
+ 0x1.005ffep10
+ },
+ { // Entry 258
+ (long long int)0x1.0080p10,
+ 0x1.0060p10
+ },
+ { // Entry 259
+ (long long int)0x1.0080p10,
+ 0x1.006002p10
+ },
+ { // Entry 260
+ (long long int)0x1.p11,
+ 0x1.000ffep11
+ },
+ { // Entry 261
+ (long long int)0x1.p11,
+ 0x1.0010p11
+ },
+ { // Entry 262
+ (long long int)0x1.0020p11,
+ 0x1.001002p11
+ },
+ { // Entry 263
+ (long long int)0x1.p12,
+ 0x1.0007fep12
+ },
+ { // Entry 264
+ (long long int)0x1.p12,
+ 0x1.0008p12
+ },
+ { // Entry 265
+ (long long int)0x1.0010p12,
+ 0x1.000802p12
+ },
+ { // Entry 266
+ (long long int)0x1.80p1,
+ 0x1.921fb6p1
+ },
+ { // Entry 267
+ (long long int)-0x1.80p1,
+ -0x1.921fb6p1
+ },
+ { // Entry 268
+ (long long int)0x1.p1,
+ 0x1.921fb6p0
+ },
+ { // Entry 269
+ (long long int)-0x1.p1,
+ -0x1.921fb6p0
+ },
+ { // Entry 270
+ (long long int)0x1.p0,
+ 0x1.000002p0
+ },
+ { // Entry 271
+ (long long int)-0x1.p0,
+ -0x1.000002p0
+ },
+ { // Entry 272
+ (long long int)0x1.p0,
+ 0x1.p0
+ },
+ { // Entry 273
+ (long long int)-0x1.p0,
+ -0x1.p0
+ },
+ { // Entry 274
+ (long long int)0x1.p0,
+ 0x1.fffffep-1
+ },
+ { // Entry 275
+ (long long int)-0x1.p0,
+ -0x1.fffffep-1
+ },
+ { // Entry 276
+ (long long int)0x1.p0,
+ 0x1.921fb6p-1
+ },
+ { // Entry 277
+ (long long int)-0x1.p0,
+ -0x1.921fb6p-1
+ },
+ { // Entry 278
+ (long long int)0.0,
+ 0x1.000002p-126
+ },
+ { // Entry 279
+ (long long int)0.0,
+ -0x1.000002p-126
+ },
+ { // Entry 280
+ (long long int)0.0,
+ 0x1.p-126
+ },
+ { // Entry 281
+ (long long int)0.0,
+ -0x1.p-126
+ },
+ { // Entry 282
+ (long long int)0.0,
+ 0x1.fffffcp-127
+ },
+ { // Entry 283
+ (long long int)0.0,
+ -0x1.fffffcp-127
+ },
+ { // Entry 284
+ (long long int)0.0,
+ 0x1.fffff8p-127
+ },
+ { // Entry 285
+ (long long int)0.0,
+ -0x1.fffff8p-127
+ },
+ { // Entry 286
+ (long long int)0.0,
+ 0x1.p-148
+ },
+ { // Entry 287
+ (long long int)0.0,
+ -0x1.p-148
+ },
+ { // Entry 288
+ (long long int)0.0,
+ 0x1.p-149
+ },
+ { // Entry 289
+ (long long int)0.0,
+ -0x1.p-149
+ },
+ { // Entry 290
+ (long long int)0.0,
+ 0.0f
+ },
+ { // Entry 291
+ (long long int)0.0,
+ -0.0f
+ },
+ { // Entry 292
+ (long long int)0x1.p1,
+ 0x1.80p0
+ },
+ { // Entry 293
+ (long long int)-0x1.p1,
+ -0x1.80p0
+ },
+ { // Entry 294
+ (long long int)0x1.p1,
+ 0x1.40p1
+ },
+ { // Entry 295
+ (long long int)-0x1.p1,
+ -0x1.40p1
+ },
+ { // Entry 296
+ (long long int)0.0,
+ 0x1.fffff0p-2
+ },
+ { // Entry 297
+ (long long int)0.0,
+ 0x1.p-1
+ },
+ { // Entry 298
+ (long long int)0x1.p0,
+ 0x1.000010p-1
+ },
+ { // Entry 299
+ (long long int)0.0,
+ -0x1.fffff0p-2
+ },
+ { // Entry 300
+ (long long int)0.0,
+ -0x1.p-1
+ },
+ { // Entry 301
+ (long long int)-0x1.p0,
+ -0x1.000010p-1
+ },
+ { // Entry 302
+ (long long int)0x1.p1,
+ 0x1.800010p0
+ },
+ { // Entry 303
+ (long long int)0x1.p0,
+ 0x1.7ffff0p0
+ },
+ { // Entry 304
+ (long long int)-0x1.p1,
+ -0x1.800010p0
+ },
+ { // Entry 305
+ (long long int)-0x1.p0,
+ -0x1.7ffff0p0
+ }
+};
\ No newline at end of file
diff --git a/tests/math_data/lrint_intel_data.h b/tests/math_data/lrint_intel_data.h
new file mode 100644
index 0000000..a034be4
--- /dev/null
+++ b/tests/math_data/lrint_intel_data.h
@@ -0,0 +1,982 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+static data_long_1_t<double> g_lrint_intel_data[] = {
+ { // Entry 0
+ (long int)0.0,
+ -0x1.0p-1074
+ },
+ { // Entry 1
+ (long int)0.0,
+ -0.0
+ },
+ { // Entry 2
+ (long int)0.0,
+ 0x1.0p-1074
+ },
+ { // Entry 3
+ (long int)0.0,
+ 0x1.fffffffffffffp-2
+ },
+ { // Entry 4
+ (long int)0.0,
+ 0x1.0p-1
+ },
+ { // Entry 5
+ (long int)0x1.p0,
+ 0x1.0000000000001p-1
+ },
+ { // Entry 6
+ (long int)0x1.p0,
+ 0x1.fffffffffffffp-1
+ },
+ { // Entry 7
+ (long int)0x1.p0,
+ 0x1.0p0
+ },
+ { // Entry 8
+ (long int)0x1.p0,
+ 0x1.0000000000001p0
+ },
+ { // Entry 9
+ (long int)0x1.p0,
+ 0x1.7ffffffffffffp0
+ },
+ { // Entry 10
+ (long int)0x1.p1,
+ 0x1.8p0
+ },
+ { // Entry 11
+ (long int)0x1.p1,
+ 0x1.8000000000001p0
+ },
+ { // Entry 12
+ (long int)0x1.p1,
+ 0x1.fffffffffffffp0
+ },
+ { // Entry 13
+ (long int)0x1.p1,
+ 0x1.0p1
+ },
+ { // Entry 14
+ (long int)0x1.p1,
+ 0x1.0000000000001p1
+ },
+ { // Entry 15
+ (long int)0x1.p1,
+ 0x1.3ffffffffffffp1
+ },
+ { // Entry 16
+ (long int)0x1.p1,
+ 0x1.4p1
+ },
+ { // Entry 17
+ (long int)0x1.80p1,
+ 0x1.4000000000001p1
+ },
+ { // Entry 18
+ (long int)0x1.90p6,
+ 0x1.8ffffffffffffp6
+ },
+ { // Entry 19
+ (long int)0x1.90p6,
+ 0x1.9p6
+ },
+ { // Entry 20
+ (long int)0x1.90p6,
+ 0x1.9000000000001p6
+ },
+ { // Entry 21
+ (long int)0x1.90p6,
+ 0x1.91fffffffffffp6
+ },
+ { // Entry 22
+ (long int)0x1.90p6,
+ 0x1.920p6
+ },
+ { // Entry 23
+ (long int)0x1.94p6,
+ 0x1.9200000000001p6
+ },
+ { // Entry 24
+ (long int)0x1.f4p9,
+ 0x1.f3fffffffffffp9
+ },
+ { // Entry 25
+ (long int)0x1.f4p9,
+ 0x1.f40p9
+ },
+ { // Entry 26
+ (long int)0x1.f4p9,
+ 0x1.f400000000001p9
+ },
+ { // Entry 27
+ (long int)0x1.f4p9,
+ 0x1.f43ffffffffffp9
+ },
+ { // Entry 28
+ (long int)0x1.f4p9,
+ 0x1.f44p9
+ },
+ { // Entry 29
+ (long int)0x1.f480p9,
+ 0x1.f440000000001p9
+ },
+ { // Entry 30
+ (long int)-0x1.p0,
+ -0x1.0000000000001p-1
+ },
+ { // Entry 31
+ (long int)0.0,
+ -0x1.0p-1
+ },
+ { // Entry 32
+ (long int)0.0,
+ -0x1.fffffffffffffp-2
+ },
+ { // Entry 33
+ (long int)-0x1.p0,
+ -0x1.0000000000001p0
+ },
+ { // Entry 34
+ (long int)-0x1.p0,
+ -0x1.0p0
+ },
+ { // Entry 35
+ (long int)-0x1.p0,
+ -0x1.fffffffffffffp-1
+ },
+ { // Entry 36
+ (long int)-0x1.p1,
+ -0x1.8000000000001p0
+ },
+ { // Entry 37
+ (long int)-0x1.p1,
+ -0x1.8p0
+ },
+ { // Entry 38
+ (long int)-0x1.p0,
+ -0x1.7ffffffffffffp0
+ },
+ { // Entry 39
+ (long int)-0x1.p1,
+ -0x1.0000000000001p1
+ },
+ { // Entry 40
+ (long int)-0x1.p1,
+ -0x1.0p1
+ },
+ { // Entry 41
+ (long int)-0x1.p1,
+ -0x1.fffffffffffffp0
+ },
+ { // Entry 42
+ (long int)-0x1.80p1,
+ -0x1.4000000000001p1
+ },
+ { // Entry 43
+ (long int)-0x1.p1,
+ -0x1.4p1
+ },
+ { // Entry 44
+ (long int)-0x1.p1,
+ -0x1.3ffffffffffffp1
+ },
+ { // Entry 45
+ (long int)-0x1.90p6,
+ -0x1.9000000000001p6
+ },
+ { // Entry 46
+ (long int)-0x1.90p6,
+ -0x1.9p6
+ },
+ { // Entry 47
+ (long int)-0x1.90p6,
+ -0x1.8ffffffffffffp6
+ },
+ { // Entry 48
+ (long int)-0x1.94p6,
+ -0x1.9200000000001p6
+ },
+ { // Entry 49
+ (long int)-0x1.90p6,
+ -0x1.920p6
+ },
+ { // Entry 50
+ (long int)-0x1.90p6,
+ -0x1.91fffffffffffp6
+ },
+ { // Entry 51
+ (long int)-0x1.f4p9,
+ -0x1.f400000000001p9
+ },
+ { // Entry 52
+ (long int)-0x1.f4p9,
+ -0x1.f40p9
+ },
+ { // Entry 53
+ (long int)-0x1.f4p9,
+ -0x1.f3fffffffffffp9
+ },
+ { // Entry 54
+ (long int)-0x1.f480p9,
+ -0x1.f440000000001p9
+ },
+ { // Entry 55
+ (long int)-0x1.f4p9,
+ -0x1.f44p9
+ },
+ { // Entry 56
+ (long int)-0x1.f4p9,
+ -0x1.f43ffffffffffp9
+ },
+ { // Entry 57
+ (long int)0x1.p30,
+ 0x1.fffffffffffffp29
+ },
+ { // Entry 58
+ (long int)0x1.p30,
+ 0x1.0p30
+ },
+ { // Entry 59
+ (long int)0x1.p30,
+ 0x1.0000000000001p30
+ },
+ { // Entry 60
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffff7ffffep30
+ },
+ { // Entry 61
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffff7fffffp30
+ },
+ { // Entry 62
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffff80p30
+ },
+ { // Entry 63
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffff800001p30
+ },
+ { // Entry 64
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffff800002p30
+ },
+ { // Entry 65
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffff9ffffep30
+ },
+ { // Entry 66
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffff9fffffp30
+ },
+ { // Entry 67
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffffa0p30
+ },
+ { // Entry 68
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffa00001p30
+ },
+ { // Entry 69
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffa00002p30
+ },
+ { // Entry 70
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffbffffep30
+ },
+ { // Entry 71
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffbfffffp30
+ },
+ { // Entry 72
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffc0p30
+ },
+ { // Entry 73
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffc00001p30
+ },
+ { // Entry 74
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffc00002p30
+ },
+ { // Entry 75
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffdffffep30
+ },
+ { // Entry 76
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffdfffffp30
+ },
+ { // Entry 77
+ (long int)0x1.ffffffe0p30,
+ 0x1.ffffffep30
+ },
+ { // Entry 78
+ (long int)0x1.ffffffe4p30,
+ 0x1.ffffffe40p30
+ },
+ { // Entry 79
+ (long int)0x1.ffffffe8p30,
+ 0x1.ffffffe80p30
+ },
+ { // Entry 80
+ (long int)0x1.ffffffecp30,
+ 0x1.ffffffec0p30
+ },
+ { // Entry 81
+ (long int)0x1.fffffff0p30,
+ 0x1.fffffffp30
+ },
+ { // Entry 82
+ (long int)0x1.fffffff4p30,
+ 0x1.fffffff40p30
+ },
+ { // Entry 83
+ (long int)0x1.fffffff8p30,
+ 0x1.fffffff80p30
+ },
+ { // Entry 84
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffc0p30
+ },
+ { // Entry 85
+ (long int)-0x1.p30,
+ -0x1.0000000000001p30
+ },
+ { // Entry 86
+ (long int)-0x1.p30,
+ -0x1.0p30
+ },
+ { // Entry 87
+ (long int)-0x1.p30,
+ -0x1.fffffffffffffp29
+ },
+ { // Entry 88
+ (long int)-0x1.fffffff8p30,
+ -0x1.fffffff800002p30
+ },
+ { // Entry 89
+ (long int)-0x1.fffffff8p30,
+ -0x1.fffffff800001p30
+ },
+ { // Entry 90
+ (long int)-0x1.fffffff8p30,
+ -0x1.fffffff80p30
+ },
+ { // Entry 91
+ (long int)-0x1.fffffff8p30,
+ -0x1.fffffff7fffffp30
+ },
+ { // Entry 92
+ (long int)-0x1.fffffff8p30,
+ -0x1.fffffff7ffffep30
+ },
+ { // Entry 93
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffa00002p30
+ },
+ { // Entry 94
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffa00001p30
+ },
+ { // Entry 95
+ (long int)-0x1.fffffff8p30,
+ -0x1.fffffffa0p30
+ },
+ { // Entry 96
+ (long int)-0x1.fffffff8p30,
+ -0x1.fffffff9fffffp30
+ },
+ { // Entry 97
+ (long int)-0x1.fffffff8p30,
+ -0x1.fffffff9ffffep30
+ },
+ { // Entry 98
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffc00002p30
+ },
+ { // Entry 99
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffc00001p30
+ },
+ { // Entry 100
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffc0p30
+ },
+ { // Entry 101
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffbfffffp30
+ },
+ { // Entry 102
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffbffffep30
+ },
+ { // Entry 103
+ (long int)-0x1.p31,
+ -0x1.fffffffe00002p30
+ },
+ { // Entry 104
+ (long int)-0x1.p31,
+ -0x1.fffffffe00001p30
+ },
+ { // Entry 105
+ (long int)-0x1.p31,
+ -0x1.fffffffe0p30
+ },
+ { // Entry 106
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffdfffffp30
+ },
+ { // Entry 107
+ (long int)-0x1.fffffffcp30,
+ -0x1.fffffffdffffep30
+ },
+ { // Entry 108
+ (long int)-0x1.p31,
+ -0x1.0000000000002p31
+ },
+ { // Entry 109
+ (long int)-0x1.p31,
+ -0x1.0000000000001p31
+ },
+ { // Entry 110
+ (long int)-0x1.p31,
+ -0x1.0p31
+ },
+ { // Entry 111
+ (long int)-0x1.p31,
+ -0x1.fffffffffffffp30
+ },
+ { // Entry 112
+ (long int)-0x1.p31,
+ -0x1.ffffffffffffep30
+ },
+ { // Entry 113
+ (long int)-0x1.p31,
+ -0x1.000000010p31
+ },
+ { // Entry 114
+ (long int)-0x1.p31,
+ -0x1.00000000fffffp31
+ },
+ { // Entry 115
+ (long int)-0x1.p31,
+ -0x1.00000000ffffep31
+ },
+ { // Entry 116
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 117
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 118
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 119
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 120
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 121
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 122
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 123
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 124
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 125
+ (long int)-0x1.ffffffe0p30,
+ -0x1.ffffffep30
+ },
+ { // Entry 126
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffbfffffp30
+ },
+ { // Entry 127
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffc0p30
+ },
+ { // Entry 128
+ (long int)0x1.fffffffcp30,
+ 0x1.fffffffc00001p30
+ },
+ { // Entry 129
+ (long int)-0x1.p31,
+ -0x1.0000000000001p31
+ },
+ { // Entry 130
+ (long int)-0x1.p31,
+ -0x1.0p31
+ },
+ { // Entry 131
+ (long int)-0x1.p31,
+ -0x1.fffffffffffffp30
+ },
+ { // Entry 132
+ (long int)0x1.p2,
+ 0x1.fffffffffffffp1
+ },
+ { // Entry 133
+ (long int)0x1.p2,
+ 0x1.0p2
+ },
+ { // Entry 134
+ (long int)0x1.p2,
+ 0x1.0000000000001p2
+ },
+ { // Entry 135
+ (long int)0x1.p3,
+ 0x1.fffffffffffffp2
+ },
+ { // Entry 136
+ (long int)0x1.p3,
+ 0x1.0p3
+ },
+ { // Entry 137
+ (long int)0x1.p3,
+ 0x1.0000000000001p3
+ },
+ { // Entry 138
+ (long int)0x1.p4,
+ 0x1.fffffffffffffp3
+ },
+ { // Entry 139
+ (long int)0x1.p4,
+ 0x1.0p4
+ },
+ { // Entry 140
+ (long int)0x1.p4,
+ 0x1.0000000000001p4
+ },
+ { // Entry 141
+ (long int)0x1.p5,
+ 0x1.fffffffffffffp4
+ },
+ { // Entry 142
+ (long int)0x1.p5,
+ 0x1.0p5
+ },
+ { // Entry 143
+ (long int)0x1.p5,
+ 0x1.0000000000001p5
+ },
+ { // Entry 144
+ (long int)0x1.p6,
+ 0x1.fffffffffffffp5
+ },
+ { // Entry 145
+ (long int)0x1.p6,
+ 0x1.0p6
+ },
+ { // Entry 146
+ (long int)0x1.p6,
+ 0x1.0000000000001p6
+ },
+ { // Entry 147
+ (long int)0x1.p7,
+ 0x1.fffffffffffffp6
+ },
+ { // Entry 148
+ (long int)0x1.p7,
+ 0x1.0p7
+ },
+ { // Entry 149
+ (long int)0x1.p7,
+ 0x1.0000000000001p7
+ },
+ { // Entry 150
+ (long int)0x1.p8,
+ 0x1.fffffffffffffp7
+ },
+ { // Entry 151
+ (long int)0x1.p8,
+ 0x1.0p8
+ },
+ { // Entry 152
+ (long int)0x1.p8,
+ 0x1.0000000000001p8
+ },
+ { // Entry 153
+ (long int)0x1.p9,
+ 0x1.fffffffffffffp8
+ },
+ { // Entry 154
+ (long int)0x1.p9,
+ 0x1.0p9
+ },
+ { // Entry 155
+ (long int)0x1.p9,
+ 0x1.0000000000001p9
+ },
+ { // Entry 156
+ (long int)0x1.p10,
+ 0x1.fffffffffffffp9
+ },
+ { // Entry 157
+ (long int)0x1.p10,
+ 0x1.0p10
+ },
+ { // Entry 158
+ (long int)0x1.p10,
+ 0x1.0000000000001p10
+ },
+ { // Entry 159
+ (long int)0x1.p11,
+ 0x1.fffffffffffffp10
+ },
+ { // Entry 160
+ (long int)0x1.p11,
+ 0x1.0p11
+ },
+ { // Entry 161
+ (long int)0x1.p11,
+ 0x1.0000000000001p11
+ },
+ { // Entry 162
+ (long int)0x1.p12,
+ 0x1.fffffffffffffp11
+ },
+ { // Entry 163
+ (long int)0x1.p12,
+ 0x1.0p12
+ },
+ { // Entry 164
+ (long int)0x1.p12,
+ 0x1.0000000000001p12
+ },
+ { // Entry 165
+ (long int)0x1.p2,
+ 0x1.1ffffffffffffp2
+ },
+ { // Entry 166
+ (long int)0x1.p2,
+ 0x1.2p2
+ },
+ { // Entry 167
+ (long int)0x1.40p2,
+ 0x1.2000000000001p2
+ },
+ { // Entry 168
+ (long int)0x1.p3,
+ 0x1.0ffffffffffffp3
+ },
+ { // Entry 169
+ (long int)0x1.p3,
+ 0x1.1p3
+ },
+ { // Entry 170
+ (long int)0x1.20p3,
+ 0x1.1000000000001p3
+ },
+ { // Entry 171
+ (long int)0x1.p4,
+ 0x1.07fffffffffffp4
+ },
+ { // Entry 172
+ (long int)0x1.p4,
+ 0x1.080p4
+ },
+ { // Entry 173
+ (long int)0x1.10p4,
+ 0x1.0800000000001p4
+ },
+ { // Entry 174
+ (long int)0x1.p5,
+ 0x1.03fffffffffffp5
+ },
+ { // Entry 175
+ (long int)0x1.p5,
+ 0x1.040p5
+ },
+ { // Entry 176
+ (long int)0x1.08p5,
+ 0x1.0400000000001p5
+ },
+ { // Entry 177
+ (long int)0x1.p6,
+ 0x1.01fffffffffffp6
+ },
+ { // Entry 178
+ (long int)0x1.p6,
+ 0x1.020p6
+ },
+ { // Entry 179
+ (long int)0x1.04p6,
+ 0x1.0200000000001p6
+ },
+ { // Entry 180
+ (long int)0x1.p7,
+ 0x1.00fffffffffffp7
+ },
+ { // Entry 181
+ (long int)0x1.p7,
+ 0x1.010p7
+ },
+ { // Entry 182
+ (long int)0x1.02p7,
+ 0x1.0100000000001p7
+ },
+ { // Entry 183
+ (long int)0x1.p8,
+ 0x1.007ffffffffffp8
+ },
+ { // Entry 184
+ (long int)0x1.p8,
+ 0x1.008p8
+ },
+ { // Entry 185
+ (long int)0x1.01p8,
+ 0x1.0080000000001p8
+ },
+ { // Entry 186
+ (long int)0x1.p9,
+ 0x1.003ffffffffffp9
+ },
+ { // Entry 187
+ (long int)0x1.p9,
+ 0x1.004p9
+ },
+ { // Entry 188
+ (long int)0x1.0080p9,
+ 0x1.0040000000001p9
+ },
+ { // Entry 189
+ (long int)0x1.p10,
+ 0x1.001ffffffffffp10
+ },
+ { // Entry 190
+ (long int)0x1.p10,
+ 0x1.002p10
+ },
+ { // Entry 191
+ (long int)0x1.0040p10,
+ 0x1.0020000000001p10
+ },
+ { // Entry 192
+ (long int)0x1.0040p10,
+ 0x1.005ffffffffffp10
+ },
+ { // Entry 193
+ (long int)0x1.0080p10,
+ 0x1.006p10
+ },
+ { // Entry 194
+ (long int)0x1.0080p10,
+ 0x1.0060000000001p10
+ },
+ { // Entry 195
+ (long int)0x1.p11,
+ 0x1.000ffffffffffp11
+ },
+ { // Entry 196
+ (long int)0x1.p11,
+ 0x1.001p11
+ },
+ { // Entry 197
+ (long int)0x1.0020p11,
+ 0x1.0010000000001p11
+ },
+ { // Entry 198
+ (long int)0x1.p12,
+ 0x1.0007fffffffffp12
+ },
+ { // Entry 199
+ (long int)0x1.p12,
+ 0x1.00080p12
+ },
+ { // Entry 200
+ (long int)0x1.0010p12,
+ 0x1.0008000000001p12
+ },
+ { // Entry 201
+ (long int)0x1.80p1,
+ 0x1.921fb54442d18p1
+ },
+ { // Entry 202
+ (long int)-0x1.80p1,
+ -0x1.921fb54442d18p1
+ },
+ { // Entry 203
+ (long int)0x1.p1,
+ 0x1.921fb54442d18p0
+ },
+ { // Entry 204
+ (long int)-0x1.p1,
+ -0x1.921fb54442d18p0
+ },
+ { // Entry 205
+ (long int)0x1.p0,
+ 0x1.0000000000001p0
+ },
+ { // Entry 206
+ (long int)-0x1.p0,
+ -0x1.0000000000001p0
+ },
+ { // Entry 207
+ (long int)0x1.p0,
+ 0x1.0p0
+ },
+ { // Entry 208
+ (long int)-0x1.p0,
+ -0x1.0p0
+ },
+ { // Entry 209
+ (long int)0x1.p0,
+ 0x1.fffffffffffffp-1
+ },
+ { // Entry 210
+ (long int)-0x1.p0,
+ -0x1.fffffffffffffp-1
+ },
+ { // Entry 211
+ (long int)0x1.p0,
+ 0x1.921fb54442d18p-1
+ },
+ { // Entry 212
+ (long int)-0x1.p0,
+ -0x1.921fb54442d18p-1
+ },
+ { // Entry 213
+ (long int)0.0,
+ 0x1.0000000000001p-1022
+ },
+ { // Entry 214
+ (long int)0.0,
+ -0x1.0000000000001p-1022
+ },
+ { // Entry 215
+ (long int)0.0,
+ 0x1.0p-1022
+ },
+ { // Entry 216
+ (long int)0.0,
+ -0x1.0p-1022
+ },
+ { // Entry 217
+ (long int)0.0,
+ 0x1.ffffffffffffep-1023
+ },
+ { // Entry 218
+ (long int)0.0,
+ -0x1.ffffffffffffep-1023
+ },
+ { // Entry 219
+ (long int)0.0,
+ 0x1.ffffffffffffcp-1023
+ },
+ { // Entry 220
+ (long int)0.0,
+ -0x1.ffffffffffffcp-1023
+ },
+ { // Entry 221
+ (long int)0.0,
+ 0x1.0p-1073
+ },
+ { // Entry 222
+ (long int)0.0,
+ -0x1.0p-1073
+ },
+ { // Entry 223
+ (long int)0.0,
+ 0x1.0p-1074
+ },
+ { // Entry 224
+ (long int)0.0,
+ -0x1.0p-1074
+ },
+ { // Entry 225
+ (long int)0.0,
+ 0.0
+ },
+ { // Entry 226
+ (long int)0.0,
+ -0.0
+ },
+ { // Entry 227
+ (long int)0x1.p1,
+ 0x1.8p0
+ },
+ { // Entry 228
+ (long int)-0x1.p1,
+ -0x1.8p0
+ },
+ { // Entry 229
+ (long int)0x1.p1,
+ 0x1.4p1
+ },
+ { // Entry 230
+ (long int)-0x1.p1,
+ -0x1.4p1
+ },
+ { // Entry 231
+ (long int)0.0,
+ 0x1.fffffp-2
+ },
+ { // Entry 232
+ (long int)0.0,
+ 0x1.0p-1
+ },
+ { // Entry 233
+ (long int)0x1.p0,
+ 0x1.00001p-1
+ },
+ { // Entry 234
+ (long int)0.0,
+ -0x1.fffffp-2
+ },
+ { // Entry 235
+ (long int)0.0,
+ -0x1.0p-1
+ },
+ { // Entry 236
+ (long int)-0x1.p0,
+ -0x1.00001p-1
+ },
+ { // Entry 237
+ (long int)0x1.p1,
+ 0x1.80001p0
+ },
+ { // Entry 238
+ (long int)0x1.p0,
+ 0x1.7ffffp0
+ },
+ { // Entry 239
+ (long int)-0x1.p1,
+ -0x1.80001p0
+ },
+ { // Entry 240
+ (long int)-0x1.p0,
+ -0x1.7ffffp0
+ }
+};
\ No newline at end of file
diff --git a/tests/math_data/lrintf_intel_data.h b/tests/math_data/lrintf_intel_data.h
new file mode 100644
index 0000000..bd771b2
--- /dev/null
+++ b/tests/math_data/lrintf_intel_data.h
@@ -0,0 +1,1002 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+static data_long_1_t<float> g_lrintf_intel_data[] = {
+ { // Entry 0
+ (long int)0.0,
+ -0x1.p-149
+ },
+ { // Entry 1
+ (long int)0.0,
+ 0.0
+ },
+ { // Entry 2
+ (long int)0.0,
+ 0x1.p-149
+ },
+ { // Entry 3
+ (long int)0.0,
+ 0x1.fffffep-2
+ },
+ { // Entry 4
+ (long int)0.0,
+ 0x1.p-1
+ },
+ { // Entry 5
+ (long int)0x1.p0,
+ 0x1.000002p-1
+ },
+ { // Entry 6
+ (long int)0x1.p0,
+ 0x1.fffffep-1
+ },
+ { // Entry 7
+ (long int)0x1.p0,
+ 0x1.p0
+ },
+ { // Entry 8
+ (long int)0x1.p0,
+ 0x1.000002p0
+ },
+ { // Entry 9
+ (long int)0x1.p0,
+ 0x1.7ffffep0
+ },
+ { // Entry 10
+ (long int)0x1.p1,
+ 0x1.80p0
+ },
+ { // Entry 11
+ (long int)0x1.p1,
+ 0x1.800002p0
+ },
+ { // Entry 12
+ (long int)0x1.p1,
+ 0x1.fffffep0
+ },
+ { // Entry 13
+ (long int)0x1.p1,
+ 0x1.p1
+ },
+ { // Entry 14
+ (long int)0x1.p1,
+ 0x1.000002p1
+ },
+ { // Entry 15
+ (long int)0x1.p1,
+ 0x1.3ffffep1
+ },
+ { // Entry 16
+ (long int)0x1.p1,
+ 0x1.40p1
+ },
+ { // Entry 17
+ (long int)0x1.80p1,
+ 0x1.400002p1
+ },
+ { // Entry 18
+ (long int)0x1.90p6,
+ 0x1.8ffffep6
+ },
+ { // Entry 19
+ (long int)0x1.90p6,
+ 0x1.90p6
+ },
+ { // Entry 20
+ (long int)0x1.90p6,
+ 0x1.900002p6
+ },
+ { // Entry 21
+ (long int)0x1.90p6,
+ 0x1.91fffep6
+ },
+ { // Entry 22
+ (long int)0x1.90p6,
+ 0x1.92p6
+ },
+ { // Entry 23
+ (long int)0x1.94p6,
+ 0x1.920002p6
+ },
+ { // Entry 24
+ (long int)0x1.f4p9,
+ 0x1.f3fffep9
+ },
+ { // Entry 25
+ (long int)0x1.f4p9,
+ 0x1.f4p9
+ },
+ { // Entry 26
+ (long int)0x1.f4p9,
+ 0x1.f40002p9
+ },
+ { // Entry 27
+ (long int)0x1.f4p9,
+ 0x1.f43ffep9
+ },
+ { // Entry 28
+ (long int)0x1.f4p9,
+ 0x1.f440p9
+ },
+ { // Entry 29
+ (long int)0x1.f480p9,
+ 0x1.f44002p9
+ },
+ { // Entry 30
+ (long int)0x1.p21,
+ 0x1.fffffep20
+ },
+ { // Entry 31
+ (long int)0x1.p21,
+ 0x1.p21
+ },
+ { // Entry 32
+ (long int)0x1.p21,
+ 0x1.000002p21
+ },
+ { // Entry 33
+ (long int)0x1.p22,
+ 0x1.fffffep21
+ },
+ { // Entry 34
+ (long int)0x1.p22,
+ 0x1.p22
+ },
+ { // Entry 35
+ (long int)0x1.p22,
+ 0x1.000002p22
+ },
+ { // Entry 36
+ (long int)0x1.p23,
+ 0x1.fffffep22
+ },
+ { // Entry 37
+ (long int)0x1.p23,
+ 0x1.p23
+ },
+ { // Entry 38
+ (long int)0x1.000002p23,
+ 0x1.000002p23
+ },
+ { // Entry 39
+ (long int)0x1.fffffep23,
+ 0x1.fffffep23
+ },
+ { // Entry 40
+ (long int)0x1.p24,
+ 0x1.p24
+ },
+ { // Entry 41
+ (long int)0x1.000002p24,
+ 0x1.000002p24
+ },
+ { // Entry 42
+ (long int)0x1.fffffep24,
+ 0x1.fffffep24
+ },
+ { // Entry 43
+ (long int)0x1.p25,
+ 0x1.p25
+ },
+ { // Entry 44
+ (long int)0x1.000002p25,
+ 0x1.000002p25
+ },
+ { // Entry 45
+ (long int)-0x1.p0,
+ -0x1.000002p-1
+ },
+ { // Entry 46
+ (long int)0.0,
+ -0x1.p-1
+ },
+ { // Entry 47
+ (long int)0.0,
+ -0x1.fffffep-2
+ },
+ { // Entry 48
+ (long int)-0x1.p0,
+ -0x1.000002p0
+ },
+ { // Entry 49
+ (long int)-0x1.p0,
+ -0x1.p0
+ },
+ { // Entry 50
+ (long int)-0x1.p0,
+ -0x1.fffffep-1
+ },
+ { // Entry 51
+ (long int)-0x1.p1,
+ -0x1.800002p0
+ },
+ { // Entry 52
+ (long int)-0x1.p1,
+ -0x1.80p0
+ },
+ { // Entry 53
+ (long int)-0x1.p0,
+ -0x1.7ffffep0
+ },
+ { // Entry 54
+ (long int)-0x1.p1,
+ -0x1.000002p1
+ },
+ { // Entry 55
+ (long int)-0x1.p1,
+ -0x1.p1
+ },
+ { // Entry 56
+ (long int)-0x1.p1,
+ -0x1.fffffep0
+ },
+ { // Entry 57
+ (long int)-0x1.80p1,
+ -0x1.400002p1
+ },
+ { // Entry 58
+ (long int)-0x1.p1,
+ -0x1.40p1
+ },
+ { // Entry 59
+ (long int)-0x1.p1,
+ -0x1.3ffffep1
+ },
+ { // Entry 60
+ (long int)-0x1.90p6,
+ -0x1.900002p6
+ },
+ { // Entry 61
+ (long int)-0x1.90p6,
+ -0x1.90p6
+ },
+ { // Entry 62
+ (long int)-0x1.90p6,
+ -0x1.8ffffep6
+ },
+ { // Entry 63
+ (long int)-0x1.94p6,
+ -0x1.920002p6
+ },
+ { // Entry 64
+ (long int)-0x1.90p6,
+ -0x1.92p6
+ },
+ { // Entry 65
+ (long int)-0x1.90p6,
+ -0x1.91fffep6
+ },
+ { // Entry 66
+ (long int)-0x1.f4p9,
+ -0x1.f40002p9
+ },
+ { // Entry 67
+ (long int)-0x1.f4p9,
+ -0x1.f4p9
+ },
+ { // Entry 68
+ (long int)-0x1.f4p9,
+ -0x1.f3fffep9
+ },
+ { // Entry 69
+ (long int)-0x1.f480p9,
+ -0x1.f44002p9
+ },
+ { // Entry 70
+ (long int)-0x1.f4p9,
+ -0x1.f440p9
+ },
+ { // Entry 71
+ (long int)-0x1.f4p9,
+ -0x1.f43ffep9
+ },
+ { // Entry 72
+ (long int)-0x1.p21,
+ -0x1.000002p21
+ },
+ { // Entry 73
+ (long int)-0x1.p21,
+ -0x1.p21
+ },
+ { // Entry 74
+ (long int)-0x1.p21,
+ -0x1.fffffep20
+ },
+ { // Entry 75
+ (long int)-0x1.p22,
+ -0x1.000002p22
+ },
+ { // Entry 76
+ (long int)-0x1.p22,
+ -0x1.p22
+ },
+ { // Entry 77
+ (long int)-0x1.p22,
+ -0x1.fffffep21
+ },
+ { // Entry 78
+ (long int)-0x1.000002p23,
+ -0x1.000002p23
+ },
+ { // Entry 79
+ (long int)-0x1.p23,
+ -0x1.p23
+ },
+ { // Entry 80
+ (long int)-0x1.p23,
+ -0x1.fffffep22
+ },
+ { // Entry 81
+ (long int)-0x1.000002p24,
+ -0x1.000002p24
+ },
+ { // Entry 82
+ (long int)-0x1.p24,
+ -0x1.p24
+ },
+ { // Entry 83
+ (long int)-0x1.fffffep23,
+ -0x1.fffffep23
+ },
+ { // Entry 84
+ (long int)-0x1.000002p25,
+ -0x1.000002p25
+ },
+ { // Entry 85
+ (long int)-0x1.p25,
+ -0x1.p25
+ },
+ { // Entry 86
+ (long int)-0x1.fffffep24,
+ -0x1.fffffep24
+ },
+ { // Entry 87
+ (long int)0x1.fffffep29,
+ 0x1.fffffep29
+ },
+ { // Entry 88
+ (long int)0x1.p30,
+ 0x1.p30
+ },
+ { // Entry 89
+ (long int)0x1.000002p30,
+ 0x1.000002p30
+ },
+ { // Entry 90
+ (long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 91
+ (long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 92
+ (long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 93
+ (long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 94
+ (long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 95
+ (long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 96
+ (long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 97
+ (long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 98
+ (long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 99
+ (long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 100
+ (long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 101
+ (long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 102
+ (long int)-0x1.000002p30,
+ -0x1.000002p30
+ },
+ { // Entry 103
+ (long int)-0x1.p30,
+ -0x1.p30
+ },
+ { // Entry 104
+ (long int)-0x1.fffffep29,
+ -0x1.fffffep29
+ },
+ { // Entry 105
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 106
+ (long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 107
+ (long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 108
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 109
+ (long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 110
+ (long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 111
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 112
+ (long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 113
+ (long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 114
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 115
+ (long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 116
+ (long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 117
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 118
+ (long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 119
+ (long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 120
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 121
+ (long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 122
+ (long int)-0x1.fffffcp30,
+ -0x1.fffffcp30
+ },
+ { // Entry 123
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 124
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 125
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 126
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 127
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 128
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 129
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 130
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 131
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 132
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 133
+ (long int)0x1.fffffcp30,
+ 0x1.fffffcp30
+ },
+ { // Entry 134
+ (long int)0x1.fffffep30,
+ 0x1.fffffep30
+ },
+ { // Entry 135
+ (long int)-0x1.p31,
+ -0x1.p31
+ },
+ { // Entry 136
+ (long int)-0x1.fffffep30,
+ -0x1.fffffep30
+ },
+ { // Entry 137
+ (long int)0x1.p2,
+ 0x1.fffffep1
+ },
+ { // Entry 138
+ (long int)0x1.p2,
+ 0x1.p2
+ },
+ { // Entry 139
+ (long int)0x1.p2,
+ 0x1.000002p2
+ },
+ { // Entry 140
+ (long int)0x1.p3,
+ 0x1.fffffep2
+ },
+ { // Entry 141
+ (long int)0x1.p3,
+ 0x1.p3
+ },
+ { // Entry 142
+ (long int)0x1.p3,
+ 0x1.000002p3
+ },
+ { // Entry 143
+ (long int)0x1.p4,
+ 0x1.fffffep3
+ },
+ { // Entry 144
+ (long int)0x1.p4,
+ 0x1.p4
+ },
+ { // Entry 145
+ (long int)0x1.p4,
+ 0x1.000002p4
+ },
+ { // Entry 146
+ (long int)0x1.p5,
+ 0x1.fffffep4
+ },
+ { // Entry 147
+ (long int)0x1.p5,
+ 0x1.p5
+ },
+ { // Entry 148
+ (long int)0x1.p5,
+ 0x1.000002p5
+ },
+ { // Entry 149
+ (long int)0x1.p6,
+ 0x1.fffffep5
+ },
+ { // Entry 150
+ (long int)0x1.p6,
+ 0x1.p6
+ },
+ { // Entry 151
+ (long int)0x1.p6,
+ 0x1.000002p6
+ },
+ { // Entry 152
+ (long int)0x1.p7,
+ 0x1.fffffep6
+ },
+ { // Entry 153
+ (long int)0x1.p7,
+ 0x1.p7
+ },
+ { // Entry 154
+ (long int)0x1.p7,
+ 0x1.000002p7
+ },
+ { // Entry 155
+ (long int)0x1.p8,
+ 0x1.fffffep7
+ },
+ { // Entry 156
+ (long int)0x1.p8,
+ 0x1.p8
+ },
+ { // Entry 157
+ (long int)0x1.p8,
+ 0x1.000002p8
+ },
+ { // Entry 158
+ (long int)0x1.p9,
+ 0x1.fffffep8
+ },
+ { // Entry 159
+ (long int)0x1.p9,
+ 0x1.p9
+ },
+ { // Entry 160
+ (long int)0x1.p9,
+ 0x1.000002p9
+ },
+ { // Entry 161
+ (long int)0x1.p10,
+ 0x1.fffffep9
+ },
+ { // Entry 162
+ (long int)0x1.p10,
+ 0x1.p10
+ },
+ { // Entry 163
+ (long int)0x1.p10,
+ 0x1.000002p10
+ },
+ { // Entry 164
+ (long int)0x1.p11,
+ 0x1.fffffep10
+ },
+ { // Entry 165
+ (long int)0x1.p11,
+ 0x1.p11
+ },
+ { // Entry 166
+ (long int)0x1.p11,
+ 0x1.000002p11
+ },
+ { // Entry 167
+ (long int)0x1.p12,
+ 0x1.fffffep11
+ },
+ { // Entry 168
+ (long int)0x1.p12,
+ 0x1.p12
+ },
+ { // Entry 169
+ (long int)0x1.p12,
+ 0x1.000002p12
+ },
+ { // Entry 170
+ (long int)0x1.p2,
+ 0x1.1ffffep2
+ },
+ { // Entry 171
+ (long int)0x1.p2,
+ 0x1.20p2
+ },
+ { // Entry 172
+ (long int)0x1.40p2,
+ 0x1.200002p2
+ },
+ { // Entry 173
+ (long int)0x1.p3,
+ 0x1.0ffffep3
+ },
+ { // Entry 174
+ (long int)0x1.p3,
+ 0x1.10p3
+ },
+ { // Entry 175
+ (long int)0x1.20p3,
+ 0x1.100002p3
+ },
+ { // Entry 176
+ (long int)0x1.p4,
+ 0x1.07fffep4
+ },
+ { // Entry 177
+ (long int)0x1.p4,
+ 0x1.08p4
+ },
+ { // Entry 178
+ (long int)0x1.10p4,
+ 0x1.080002p4
+ },
+ { // Entry 179
+ (long int)0x1.p5,
+ 0x1.03fffep5
+ },
+ { // Entry 180
+ (long int)0x1.p5,
+ 0x1.04p5
+ },
+ { // Entry 181
+ (long int)0x1.08p5,
+ 0x1.040002p5
+ },
+ { // Entry 182
+ (long int)0x1.p6,
+ 0x1.01fffep6
+ },
+ { // Entry 183
+ (long int)0x1.p6,
+ 0x1.02p6
+ },
+ { // Entry 184
+ (long int)0x1.04p6,
+ 0x1.020002p6
+ },
+ { // Entry 185
+ (long int)0x1.p7,
+ 0x1.00fffep7
+ },
+ { // Entry 186
+ (long int)0x1.p7,
+ 0x1.01p7
+ },
+ { // Entry 187
+ (long int)0x1.02p7,
+ 0x1.010002p7
+ },
+ { // Entry 188
+ (long int)0x1.p8,
+ 0x1.007ffep8
+ },
+ { // Entry 189
+ (long int)0x1.p8,
+ 0x1.0080p8
+ },
+ { // Entry 190
+ (long int)0x1.01p8,
+ 0x1.008002p8
+ },
+ { // Entry 191
+ (long int)0x1.p9,
+ 0x1.003ffep9
+ },
+ { // Entry 192
+ (long int)0x1.p9,
+ 0x1.0040p9
+ },
+ { // Entry 193
+ (long int)0x1.0080p9,
+ 0x1.004002p9
+ },
+ { // Entry 194
+ (long int)0x1.p10,
+ 0x1.001ffep10
+ },
+ { // Entry 195
+ (long int)0x1.p10,
+ 0x1.0020p10
+ },
+ { // Entry 196
+ (long int)0x1.0040p10,
+ 0x1.002002p10
+ },
+ { // Entry 197
+ (long int)0x1.0040p10,
+ 0x1.005ffep10
+ },
+ { // Entry 198
+ (long int)0x1.0080p10,
+ 0x1.0060p10
+ },
+ { // Entry 199
+ (long int)0x1.0080p10,
+ 0x1.006002p10
+ },
+ { // Entry 200
+ (long int)0x1.p11,
+ 0x1.000ffep11
+ },
+ { // Entry 201
+ (long int)0x1.p11,
+ 0x1.0010p11
+ },
+ { // Entry 202
+ (long int)0x1.0020p11,
+ 0x1.001002p11
+ },
+ { // Entry 203
+ (long int)0x1.p12,
+ 0x1.0007fep12
+ },
+ { // Entry 204
+ (long int)0x1.p12,
+ 0x1.0008p12
+ },
+ { // Entry 205
+ (long int)0x1.0010p12,
+ 0x1.000802p12
+ },
+ { // Entry 206
+ (long int)0x1.80p1,
+ 0x1.921fb6p1
+ },
+ { // Entry 207
+ (long int)-0x1.80p1,
+ -0x1.921fb6p1
+ },
+ { // Entry 208
+ (long int)0x1.p1,
+ 0x1.921fb6p0
+ },
+ { // Entry 209
+ (long int)-0x1.p1,
+ -0x1.921fb6p0
+ },
+ { // Entry 210
+ (long int)0x1.p0,
+ 0x1.000002p0
+ },
+ { // Entry 211
+ (long int)-0x1.p0,
+ -0x1.000002p0
+ },
+ { // Entry 212
+ (long int)0x1.p0,
+ 0x1.p0
+ },
+ { // Entry 213
+ (long int)-0x1.p0,
+ -0x1.p0
+ },
+ { // Entry 214
+ (long int)0x1.p0,
+ 0x1.fffffep-1
+ },
+ { // Entry 215
+ (long int)-0x1.p0,
+ -0x1.fffffep-1
+ },
+ { // Entry 216
+ (long int)0x1.p0,
+ 0x1.921fb6p-1
+ },
+ { // Entry 217
+ (long int)-0x1.p0,
+ -0x1.921fb6p-1
+ },
+ { // Entry 218
+ (long int)0.0,
+ 0x1.000002p-126
+ },
+ { // Entry 219
+ (long int)0.0,
+ -0x1.000002p-126
+ },
+ { // Entry 220
+ (long int)0.0,
+ 0x1.p-126
+ },
+ { // Entry 221
+ (long int)0.0,
+ -0x1.p-126
+ },
+ { // Entry 222
+ (long int)0.0,
+ 0x1.fffffcp-127
+ },
+ { // Entry 223
+ (long int)0.0,
+ -0x1.fffffcp-127
+ },
+ { // Entry 224
+ (long int)0.0,
+ 0x1.fffff8p-127
+ },
+ { // Entry 225
+ (long int)0.0,
+ -0x1.fffff8p-127
+ },
+ { // Entry 226
+ (long int)0.0,
+ 0x1.p-148
+ },
+ { // Entry 227
+ (long int)0.0,
+ -0x1.p-148
+ },
+ { // Entry 228
+ (long int)0.0,
+ 0x1.p-149
+ },
+ { // Entry 229
+ (long int)0.0,
+ -0x1.p-149
+ },
+ { // Entry 230
+ (long int)0.0,
+ 0.0f
+ },
+ { // Entry 231
+ (long int)0.0,
+ -0.0f
+ },
+ { // Entry 232
+ (long int)0x1.p1,
+ 0x1.80p0
+ },
+ { // Entry 233
+ (long int)-0x1.p1,
+ -0x1.80p0
+ },
+ { // Entry 234
+ (long int)0x1.p1,
+ 0x1.40p1
+ },
+ { // Entry 235
+ (long int)-0x1.p1,
+ -0x1.40p1
+ },
+ { // Entry 236
+ (long int)0.0,
+ 0x1.fffff0p-2
+ },
+ { // Entry 237
+ (long int)0.0,
+ 0x1.p-1
+ },
+ { // Entry 238
+ (long int)0x1.p0,
+ 0x1.000010p-1
+ },
+ { // Entry 239
+ (long int)0.0,
+ -0x1.fffff0p-2
+ },
+ { // Entry 240
+ (long int)0.0,
+ -0x1.p-1
+ },
+ { // Entry 241
+ (long int)-0x1.p0,
+ -0x1.000010p-1
+ },
+ { // Entry 242
+ (long int)0x1.p1,
+ 0x1.800010p0
+ },
+ { // Entry 243
+ (long int)0x1.p0,
+ 0x1.7ffff0p0
+ },
+ { // Entry 244
+ (long int)-0x1.p1,
+ -0x1.800010p0
+ },
+ { // Entry 245
+ (long int)-0x1.p0,
+ -0x1.7ffff0p0
+ }
+};
\ No newline at end of file
diff --git a/tests/math_data_test.h b/tests/math_data_test.h
index 8aa2bf1..0aba701 100644
--- a/tests/math_data_test.h
+++ b/tests/math_data_test.h
@@ -30,6 +30,18 @@
T1 input;
};
+template <typename T1>
+struct data_long_1_t {
+ long expected;
+ T1 input;
+};
+
+template <typename T1>
+struct data_llong_1_t {
+ long long expected;
+ T1 input;
+};
+
template <typename RT, typename T1, typename T2>
struct data_1_2_t {
RT expected;
@@ -157,6 +169,28 @@
}
}
+// Runs through the array 'data' applying 'f' to each of the input values
+// and asserting that the result is within ULP ulps of the expected value.
+// For testing a (double) -> long int function like lrint(3).
+template <size_t ULP, typename T, size_t N>
+void DoMathDataTest(data_long_1_t<T> (&data)[N], long f(T)) {
+ fesetenv(FE_DFL_ENV);
+ for (size_t i = 0; i < N; ++i) {
+ EXPECT_EQ(data[i].expected, f(data[i].input)) << "Failed on element " << i;
+ }
+}
+
+// Runs through the array 'data' applying 'f' to each of the input values
+// and asserting that the result is within ULP ulps of the expected value.
+// For testing a (double) -> long long int function like llrint(3).
+template <size_t ULP, typename T, size_t N>
+void DoMathDataTest(data_llong_1_t<T> (&data)[N], long long f(T)) {
+ fesetenv(FE_DFL_ENV);
+ for (size_t i = 0; i < N; ++i) {
+ EXPECT_EQ(data[i].expected, f(data[i].input)) << "Failed on element " << i;
+ }
+}
+
// Runs through the array 'data' applying 'f' to each of the pairs of input values
// and asserting that the result is within ULP ulps of the expected value.
// For testing a (double, double) -> double function like pow(3).
diff --git a/tests/math_test.cpp b/tests/math_test.cpp
index e616e9b..c805cc2 100644
--- a/tests/math_test.cpp
+++ b/tests/math_test.cpp
@@ -1639,6 +1639,16 @@
DoMathDataTest<1>(g_ldexpf_intel_data, ldexpf);
}
+#include "math_data/llrint_intel_data.h"
+TEST(math, llrint_intel) {
+ DoMathDataTest<1>(g_llrint_intel_data, llrint);
+}
+
+#include "math_data/llrintf_intel_data.h"
+TEST(math, llrintf_intel) {
+ DoMathDataTest<1>(g_llrintf_intel_data, llrintf);
+}
+
#include "math_data/log_intel_data.h"
TEST(math, log_intel) {
DoMathDataTest<1>(g_log_intel_data, log);
@@ -1689,6 +1699,16 @@
DoMathDataTest<1>(g_logbf_intel_data, logbf);
}
+#include "math_data/lrint_intel_data.h"
+TEST(math, lrint_intel) {
+ DoMathDataTest<1>(g_lrint_intel_data, lrint);
+}
+
+#include "math_data/lrintf_intel_data.h"
+TEST(math, lrintf_intel) {
+ DoMathDataTest<1>(g_lrintf_intel_data, lrintf);
+}
+
#include "math_data/modf_intel_data.h"
TEST(math, modf_intel) {
DoMathDataTest<1>(g_modf_intel_data, modf);
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
index f8fdc3f..8c1e834 100644
--- a/tests/signal_test.cpp
+++ b/tests/signal_test.cpp
@@ -14,12 +14,14 @@
* limitations under the License.
*/
+#include <errno.h>
#include <signal.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <gtest/gtest.h>
-#include <errno.h>
-
#include "ScopedSignalHandler.h"
static size_t SIGNAL_MIN() {
@@ -375,3 +377,36 @@
ASSERT_EQ(0, sigprocmask(SIG_SETMASK, &original_set, NULL));
}
+
+#if defined(__BIONIC__)
+TEST(signal, rt_tgsigqueueinfo) {
+ // Test whether rt_tgsigqueueinfo allows sending arbitrary si_code values to self.
+ // If this fails, your kernel needs commit 66dd34a to be backported.
+ static constexpr char error_msg[] =
+ "\nPlease ensure that the following kernel patch has been applied:\n"
+ "* https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=66dd34ad31e5963d72a700ec3f2449291d322921\n";
+ static siginfo received;
+
+ struct sigaction handler = {};
+ handler.sa_sigaction = [](int, siginfo_t* siginfo, void*) { received = *siginfo; };
+ handler.sa_flags = SA_SIGINFO;
+
+ ASSERT_EQ(0, sigaction(SIGUSR1, &handler, nullptr));
+
+ siginfo sent = {};
+
+ sent.si_code = SI_TKILL;
+ ASSERT_EQ(0, syscall(SYS_rt_tgsigqueueinfo, getpid(), gettid(), SIGUSR1, &sent))
+ << "rt_tgsigqueueinfo failed: " << strerror(errno) << error_msg;
+ ASSERT_EQ(sent.si_code, received.si_code) << "rt_tgsigqueueinfo modified si_code, expected "
+ << sent.si_code << ", received " << received.si_code
+ << error_msg;
+
+ sent.si_code = SI_USER;
+ ASSERT_EQ(0, syscall(SYS_rt_tgsigqueueinfo, getpid(), gettid(), SIGUSR1, &sent))
+ << "rt_tgsigqueueinfo failed: " << strerror(errno) << error_msg;
+ ASSERT_EQ(sent.si_code, received.si_code) << "rt_tgsigqueueinfo modified si_code, expected "
+ << sent.si_code << ", received " << received.si_code
+ << error_msg;
+}
+#endif
diff --git a/tests/stack_protector_test.cpp b/tests/stack_protector_test.cpp
index 22285d1..5f5a241 100644
--- a/tests/stack_protector_test.cpp
+++ b/tests/stack_protector_test.cpp
@@ -27,108 +27,83 @@
#include <unistd.h>
#include <set>
-extern "C" pid_t gettid();
+#include "private/bionic_tls.h"
-// For x86, bionic and glibc have per-thread stack guard values (all identical).
-#if defined(__i386__)
-static uint32_t GetGuardFromTls() {
- uint32_t guard;
- asm ("mov %%gs:0x14, %0": "=d" (guard));
- return guard;
-}
+extern "C" pid_t gettid(); // glibc defines this but doesn't declare it anywhere.
+
+#if defined(__BIONIC__)
+extern uintptr_t __stack_chk_guard;
+#endif
struct stack_protector_checker {
std::set<pid_t> tids;
- std::set<uint32_t> guards;
+ std::set<void*> guards;
void Check() {
pid_t tid = gettid();
- uint32_t guard = GetGuardFromTls();
+ void* guard = __get_tls()[TLS_SLOT_STACK_GUARD];
- printf("[thread %d] %%gs:0x14 = 0x%08x\n", tid, guard);
+ printf("[thread %d] TLS stack guard = %p\n", tid, guard);
// Duplicate tid. gettid(2) bug? Seeing this would be very upsetting.
ASSERT_TRUE(tids.find(tid) == tids.end());
- // Uninitialized guard. Our bug. Note this is potentially flaky; we _could_ get
- // four random zero bytes, but it should be vanishingly unlikely.
- ASSERT_NE(guard, 0U);
+ // Uninitialized guard. Our bug. Note this is potentially flaky; we _could_
+ // get four random zero bytes, but it should be vanishingly unlikely.
+ ASSERT_NE(guard, nullptr);
+
+#if defined(__BIONIC__)
+ // bionic always has the global too.
+ ASSERT_EQ(__stack_chk_guard, reinterpret_cast<uintptr_t>(guard));
+#endif
tids.insert(tid);
guards.insert(guard);
}
};
-static void* ThreadGuardHelper(void* arg) {
- stack_protector_checker* checker = reinterpret_cast<stack_protector_checker*>(arg);
- checker->Check();
- return NULL;
-}
-#endif // __i386__
-
TEST(stack_protector, same_guard_per_thread) {
-#if defined(__i386__)
+ // Everyone has the TLS slot set, even if their stack protector
+ // implementation doesn't yet use it.
stack_protector_checker checker;
- size_t thread_count = 10;
- for (size_t i = 0; i < thread_count; ++i) {
+
+ // Check the main thread.
+ ASSERT_EQ(getpid(), gettid()); // We are the main thread, right?
+ checker.Check();
+
+ size_t thread_count = 9;
+ for (size_t i = 1; i < thread_count; ++i) {
pthread_t t;
- ASSERT_EQ(0, pthread_create(&t, NULL, ThreadGuardHelper, &checker));
+ ASSERT_EQ(0, pthread_create(&t, NULL, [](void* arg) -> void* {
+ stack_protector_checker* checker = reinterpret_cast<stack_protector_checker*>(arg);
+ checker->Check();
+ return nullptr;
+ }, &checker));
void* result;
ASSERT_EQ(0, pthread_join(t, &result));
ASSERT_EQ(NULL, result);
}
ASSERT_EQ(thread_count, checker.tids.size());
- // bionic and glibc use the same guard for every thread.
+ // Both bionic and glibc use the same guard for every thread.
ASSERT_EQ(1U, checker.guards.size());
-#else // __i386__
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif // __i386__
}
-// For ARM and MIPS, glibc has a global stack check guard value.
-#if defined(__BIONIC__) || defined(__arm__) || defined(__mips__)
-#define TEST_STACK_CHK_GUARD
-
-// Bionic has the global for x86 too, to support binaries that can run on
-// Android releases that didn't implement the TLS guard value.
-extern "C" uintptr_t __stack_chk_guard;
-
-/*
- * When this function returns, the stack canary will be inconsistent
- * with the previous value, which will generate a call to __stack_chk_fail(),
- * eventually resulting in a SIGABRT.
- *
- * This must be marked with "__attribute__ ((noinline))", to ensure the
- * compiler generates the proper stack guards around this function.
- */
-static char* dummy_buf;
-
-__attribute__ ((noinline))
-static void do_modify_stack_chk_guard() {
- char buf[128];
- // Store local array's address to global variable to force compiler to generate stack guards.
- dummy_buf = buf;
- __stack_chk_guard = 0x12345678;
-}
-
-#endif
-
TEST(stack_protector, global_guard) {
-#if defined(TEST_STACK_CHK_GUARD)
+#if defined(__BIONIC__)
+ // Bionic always has a global, even if it's using TLS.
ASSERT_NE(0, gettid());
ASSERT_NE(0U, __stack_chk_guard);
-#else // TEST_STACK_CHK_GUARD
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif // TEST_STACK_CHK_GUARD
+#else
+ GTEST_LOG_(INFO) << "glibc doesn't have a global __stack_chk_guard.\n";
+#endif
}
class stack_protector_DeathTest : public BionicDeathTest {};
TEST_F(stack_protector_DeathTest, modify_stack_protector) {
-#if defined(TEST_STACK_CHK_GUARD)
- ASSERT_EXIT(do_modify_stack_chk_guard(), testing::KilledBySignal(SIGABRT), "");
-#else // TEST_STACK_CHK_GUARD
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif // TEST_STACK_CHK_GUARD
+ // In another file to prevent inlining, which removes stack protection.
+ extern void modify_stack_protector_test();
+ ASSERT_EXIT(modify_stack_protector_test(),
+ testing::KilledBySignal(SIGABRT), "stack corruption detected");
}
diff --git a/benchmarks/utils.h b/tests/stack_protector_test_helper.cpp
similarity index 64%
rename from benchmarks/utils.h
rename to tests/stack_protector_test_helper.cpp
index c3c64ba..34f3c77 100644
--- a/benchmarks/utils.h
+++ b/tests/stack_protector_test_helper.cpp
@@ -14,13 +14,11 @@
* limitations under the License.
*/
-#ifndef BENCHMARKS_UTILS_H
-#define BENCHMARKS_UTILS_H
-
-#include <stddef.h>
-#include <string>
-
-int Round(int n);
-std::string PrettyInt(long value, size_t base);
-
-#endif // BENCHMARKS_UTILS_H
+// Deliberately overwrite the stack canary.
+__attribute__((noinline)) void modify_stack_protector_test() {
+ char buf[128];
+ // We can't use memset here because it's fortified, and we want to test
+ // the line of defense *after* that.
+ char* p = buf;
+ while ((p - buf) < static_cast<int>(sizeof(buf) + sizeof(void*))) *p++ = '\0';
+}