Skip to content

Commit 3d9e676

Browse files
pefoley2copybara-github
authored andcommitted
Internal cleanup
PiperOrigin-RevId: 950841043 Change-Id: I8948415dec8790c284a31738bd037572a7ddbba2
1 parent 1e6d60b commit 3d9e676

33 files changed

Lines changed: 116 additions & 71 deletions

absl/random/internal/BUILD.bazel

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ cc_library(
194194
":platform",
195195
":randen",
196196
":seed_material",
197+
"//absl/algorithm:container",
197198
"//absl/base",
198199
"//absl/base:config",
199200
"//absl/base:core_headers",
@@ -367,8 +368,9 @@ cc_library(
367368
deps = [
368369
":platform",
369370
":randen_hwaes",
371+
":randen_hwaes_impl",
370372
":randen_slow",
371-
"//absl/base:raw_logging_internal",
373+
"//absl/base:config",
372374
],
373375
)
374376

@@ -394,13 +396,11 @@ cc_library(
394396
],
395397
hdrs = [
396398
"randen_detect.h",
397-
"randen_hwaes.h",
398399
],
399400
copts = ABSL_DEFAULT_COPTS,
400401
linkopts = ABSL_DEFAULT_LINKOPTS,
401402
deps = [
402403
":platform",
403-
":randen_hwaes_impl",
404404
"//absl/base:config",
405405
],
406406
)
@@ -410,6 +410,8 @@ cc_library(
410410
name = "randen_hwaes_impl",
411411
srcs = [
412412
"randen_hwaes.cc",
413+
],
414+
hdrs = [
413415
"randen_hwaes.h",
414416
],
415417
copts = ABSL_DEFAULT_COPTS + ABSL_RANDOM_RANDEN_COPTS + select({
@@ -421,7 +423,6 @@ cc_library(
421423
deps = [
422424
":platform",
423425
"//absl/base:config",
424-
"//absl/base:core_headers",
425426
"//absl/numeric:int128",
426427
],
427428
)
@@ -433,6 +434,7 @@ cc_binary(
433434
],
434435
linkopts = ABSL_DEFAULT_LINKOPTS,
435436
deps = [
437+
"//absl/base:config",
436438
"//absl/base:core_headers",
437439
"//absl/random:distributions",
438440
],
@@ -537,7 +539,8 @@ cc_test(
537539
linkopts = ABSL_DEFAULT_LINKOPTS,
538540
deps = [
539541
":explicit_seed_seq",
540-
"//absl/random:seed_sequences",
542+
"//absl/base:config",
543+
"//absl/base:core_headers",
541544
"@googletest//:gtest",
542545
"@googletest//:gtest_main",
543546
],
@@ -551,6 +554,8 @@ cc_test(
551554
linkopts = ABSL_DEFAULT_LINKOPTS,
552555
deps = [
553556
":salted_seed_seq",
557+
":seed_material",
558+
"//absl/base:core_headers",
554559
"@googletest//:gtest",
555560
"@googletest//:gtest_main",
556561
],
@@ -566,6 +571,7 @@ cc_test(
566571
linkopts = ABSL_DEFAULT_LINKOPTS,
567572
deps = [
568573
":distribution_test_util",
574+
"//absl/algorithm:container",
569575
"//absl/base:core_headers",
570576
"@googletest//:gtest",
571577
"@googletest//:gtest_main",
@@ -582,6 +588,7 @@ cc_test(
582588
linkopts = ABSL_DEFAULT_LINKOPTS,
583589
deps = [
584590
":fast_uniform_bits",
591+
"//absl/base:config",
585592
"@googletest//:gtest",
586593
"@googletest//:gtest_main",
587594
],
@@ -621,8 +628,8 @@ cc_test(
621628
linkopts = ABSL_DEFAULT_LINKOPTS,
622629
deps = [
623630
":nonsecure_base",
631+
"//absl/algorithm:container",
624632
"//absl/container:flat_hash_set",
625-
"//absl/meta:type_traits",
626633
"//absl/random",
627634
"//absl/random:distributions",
628635
"//absl/synchronization",
@@ -672,7 +679,6 @@ cc_test(
672679
deps = [
673680
":explicit_seed_seq",
674681
":pcg_engine",
675-
"//absl/time",
676682
"@googletest//:gtest",
677683
"@googletest//:gtest_main",
678684
],
@@ -690,7 +696,6 @@ cc_test(
690696
":explicit_seed_seq",
691697
":randen_engine",
692698
"//absl/log",
693-
"//absl/strings",
694699
"//absl/time",
695700
"@googletest//:gtest",
696701
"@googletest//:gtest_main",
@@ -705,7 +710,6 @@ cc_test(
705710
linkopts = ABSL_DEFAULT_LINKOPTS,
706711
deps = [
707712
":randen",
708-
"//absl/meta:type_traits",
709713
"@googletest//:gtest",
710714
"@googletest//:gtest_main",
711715
],
@@ -720,7 +724,6 @@ cc_test(
720724
deps = [
721725
":platform",
722726
":randen_slow",
723-
"//absl/base:endian",
724727
"@googletest//:gtest",
725728
"@googletest//:gtest_main",
726729
],
@@ -738,7 +741,6 @@ cc_test(
738741
":randen_hwaes",
739742
":randen_hwaes_impl", # build_cleaner: keep
740743
"//absl/log",
741-
"//absl/strings:str_format",
742744
"@googletest//:gtest",
743745
],
744746
)
@@ -750,6 +752,7 @@ cc_test(
750752
copts = ABSL_TEST_COPTS,
751753
linkopts = ABSL_DEFAULT_LINKOPTS,
752754
deps = [
755+
":traits",
753756
":wide_multiply",
754757
"//absl/numeric:int128",
755758
"@googletest//:gtest",
@@ -765,6 +768,7 @@ cc_library(
765768
deps = [
766769
":platform",
767770
":randen_engine",
771+
"//absl/algorithm:container",
768772
"//absl/base:config",
769773
"//absl/base:core_headers",
770774
"//absl/base:raw_logging_internal",
@@ -811,6 +815,7 @@ cc_test(
811815
],
812816
deps = [
813817
":nanobenchmark",
818+
"//absl/base:config",
814819
"//absl/log",
815820
"//absl/log:check",
816821
"//absl/strings",
@@ -829,7 +834,6 @@ cc_test(
829834
tags = ABSL_RANDOM_NONPORTABLE_TAGS + ["benchmark"],
830835
deps = [
831836
":nanobenchmark",
832-
":platform",
833837
":randen",
834838
":randen_engine",
835839
":randen_hwaes",

absl/random/internal/chi_square.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <cmath>
1818

19+
#include "absl/base/config.h"
1920
#include "absl/random/internal/distribution_test_util.h"
2021

2122
namespace absl {

absl/random/internal/chi_square_test.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <vector>
2323

2424
#include "gtest/gtest.h"
25+
#include "absl/algorithm/container.h"
2526
#include "absl/base/macros.h"
2627

2728
using absl::random_internal::ChiSquare;
@@ -176,8 +177,8 @@ TEST(ChiSquareTest, CalcChiSquareInt64) {
176177
// $ python -c "import scipy.stats
177178
// > print scipy.stats.chisquare([910293487, 910292491, 910216780])[0]"
178179
// 4.25410123524
179-
double sum = std::accumulate(std::begin(data), std::end(data), double{0});
180-
size_t n = std::distance(std::begin(data), std::end(data));
180+
double sum = absl::c_accumulate(data, double{0});
181+
size_t n = absl::c_distance(data);
181182
double a = ChiSquareWithExpected(std::begin(data), std::end(data), sum / n);
182183
EXPECT_NEAR(4.254101, a, 1e-6);
183184

@@ -343,8 +344,8 @@ TEST(ChiSquareTest, DiceRolls) {
343344
// The dof value of 4, @95% = 9.488 (see above test)
344345
// The dof value of 5, @95% = 11.070
345346
const int rolls[6] = {22, 11, 17, 14, 20, 18};
346-
double sum = std::accumulate(std::begin(rolls), std::end(rolls), double{0});
347-
size_t n = std::distance(std::begin(rolls), std::end(rolls));
347+
double sum = absl::c_accumulate(rolls, double{0});
348+
size_t n = absl::c_distance(rolls);
348349

349350
double a = ChiSquareWithExpected(std::begin(rolls), std::end(rolls), sum / n);
350351
EXPECT_NEAR(a, 4.70588, 1e-5);

absl/random/internal/distribution_test_util.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414

1515
#include "absl/random/internal/distribution_test_util.h"
1616

17+
#include <algorithm>
1718
#include <cassert>
1819
#include <cmath>
20+
#include <limits>
21+
#include <ostream>
1922
#include <string>
20-
#include <vector>
2123

24+
#include "absl/base/config.h"
2225
#include "absl/base/internal/raw_logging.h"
2326
#include "absl/base/macros.h"
2427
#include "absl/strings/str_cat.h"
2528
#include "absl/strings/str_format.h"
29+
#include "absl/strings/string_view.h"
30+
#include "absl/types/span.h"
2631

2732
namespace absl {
2833
ABSL_NAMESPACE_BEGIN

absl/random/internal/distribution_test_util_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
#include "absl/random/internal/distribution_test_util.h"
1616

17+
#include <utility>
18+
#include <vector>
19+
1720
#include "gtest/gtest.h"
1821

1922
namespace {

absl/random/internal/entropy_pool.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cstring>
2121
#include <iterator>
2222

23+
#include "absl/algorithm/container.h"
2324
#include "absl/base/attributes.h"
2425
#include "absl/base/call_once.h"
2526
#include "absl/base/config.h"
@@ -56,21 +57,21 @@ class alignas(std::max(size_t{ABSL_CACHELINE_SIZE}, size_t{32}))
5657

5758
void Init(absl::Span<const uint32_t> data) {
5859
SpinLockHolder l(mu_); // Always uncontested.
59-
std::copy(data.begin(), data.end(), std::begin(state_));
60+
absl::c_copy(data, std::begin(state_));
6061
next_ = kState;
6162
}
6263

6364
// Copy bytes into out.
6465
void Fill(uint8_t* out, size_t bytes) ABSL_LOCKS_EXCLUDED(mu_);
6566

66-
inline void MaybeRefill() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
67+
void MaybeRefill() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
6768
if (next_ >= kState) {
6869
next_ = kCapacity;
6970
impl_.Generate(state_);
7071
}
7172
}
7273

73-
inline size_t available() const ABSL_SHARED_LOCKS_REQUIRED(mu_) {
74+
size_t available() const ABSL_SHARED_LOCKS_REQUIRED(mu_) {
7475
return kState - next_;
7576
}
7677

absl/random/internal/explicit_seed_seq_test.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414

1515
#include "absl/random/internal/explicit_seed_seq.h"
1616

17+
#include <cstddef>
18+
#include <cstdint>
1719
#include <iterator>
1820
#include <random>
1921
#include <utility>
22+
#include <vector>
2023

2124
#include "gmock/gmock.h"
2225
#include "gtest/gtest.h"
23-
#include "absl/random/seed_sequences.h"
26+
#include "absl/base/config.h"
27+
#include "absl/base/macros.h"
2428

2529
namespace {
2630

absl/random/internal/fast_uniform_bits_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414

1515
#include "absl/random/internal/fast_uniform_bits.h"
1616

17+
#include <cstddef>
18+
#include <cstdint>
19+
#include <limits>
1720
#include <random>
1821

1922
#include "gtest/gtest.h"
23+
#include "absl/base/config.h"
2024

2125
namespace absl {
2226
ABSL_NAMESPACE_BEGIN

absl/random/internal/fastmath_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
#include "absl/random/internal/fastmath.h"
1616

17+
#include <cmath>
18+
#include <cstdint>
19+
1720
#include "gtest/gtest.h"
1821

1922
#if defined(__EMSCRIPTEN__)

absl/random/internal/gaussian_distribution_gentables.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <limits>
2323
#include <string>
2424

25+
#include "absl/base/config.h"
2526
#include "absl/base/macros.h"
2627
#include "absl/random/gaussian_distribution.h"
2728

0 commit comments

Comments
 (0)