Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(874)

Side by Side Diff: unit_test/unit_test.h

Issue 1662453003: fix for ubsan on unittest.h fastrand() (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: fix lint warning: Weird number of spaces at line-start. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/libyuv/version.h ('k') | unit_test/unit_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 #else 49 #else
50 static inline double get_time() { 50 static inline double get_time() {
51 struct timeval t; 51 struct timeval t;
52 struct timezone tzp; 52 struct timezone tzp;
53 gettimeofday(&t, &tzp); 53 gettimeofday(&t, &tzp);
54 return t.tv_sec + t.tv_usec * 1e-6; 54 return t.tv_sec + t.tv_usec * 1e-6;
55 } 55 }
56 #endif 56 #endif
57 57
58 extern int fastrand_seed; 58 extern unsigned int fastrand_seed;
59 inline int fastrand() { 59 inline int fastrand() {
60 fastrand_seed = fastrand_seed * 214013 + 2531011; 60 fastrand_seed = fastrand_seed * 214013u + 2531011u;
61 return (fastrand_seed >> 16) & 0xffff; 61 return static_cast<int>((fastrand_seed >> 16) & 0xffff);
62 } 62 }
63 63
64 static inline void MemRandomize(uint8* dst, int64 len) { 64 static inline void MemRandomize(uint8* dst, int64 len) {
65 int64 i; 65 int64 i;
66 for (i = 0; i < len - 1; i += 2) { 66 for (i = 0; i < len - 1; i += 2) {
67 *reinterpret_cast<uint16*>(dst) = fastrand(); 67 *reinterpret_cast<uint16*>(dst) = fastrand();
68 dst += 2; 68 dst += 2;
69 } 69 }
70 for (; i < len; ++i) { 70 for (; i < len; ++i) {
71 *dst++ = fastrand(); 71 *dst++ = fastrand();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. 144 int benchmark_iterations_; // Default 1. Use 1000 for benchmarking.
145 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. 145 int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA.
146 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. 146 int benchmark_height_; // Default 720. Use 360 for benchmarking VGA.
147 int benchmark_pixels_div256_; // Total pixels to benchmark / 256. 147 int benchmark_pixels_div256_; // Total pixels to benchmark / 256.
148 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. 148 int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280.
149 int disable_cpu_flags_; // Default 1. Use -1 for benchmarking. 149 int disable_cpu_flags_; // Default 1. Use -1 for benchmarking.
150 int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD. 150 int benchmark_cpu_info_; // Default -1. Use 1 to disable SIMD.
151 }; 151 };
152 152
153 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT 153 #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT
OLDNEW
« no previous file with comments | « include/libyuv/version.h ('k') | unit_test/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698