1 // Copyright 2019 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef PARTITION_ALLOC_RANDOM_H_ 6 #define PARTITION_ALLOC_RANDOM_H_ 7 8 #include <cstdint> 9 10 #include "partition_alloc/partition_alloc_base/component_export.h" 11 12 namespace partition_alloc { 13 14 namespace internal { 15 16 // Returns a random value. The generator's internal state is initialized with 17 // `base::RandUint64` which is very unpredictable, but which is expensive due to 18 // the need to call into the kernel. Therefore this generator uses a fast, 19 // entirely user-space function after initialization. 20 PA_COMPONENT_EXPORT(PARTITION_ALLOC) uint32_t RandomValue(); 21 22 } // namespace internal 23 24 // Sets the seed for the random number generator to a known value, to cause the 25 // RNG to generate a predictable sequence of outputs. May be called multiple 26 // times. 27 PA_COMPONENT_EXPORT(PARTITION_ALLOC) void SetMmapSeedForTesting(uint64_t seed); 28 29 } // namespace partition_alloc 30 31 #endif // PARTITION_ALLOC_RANDOM_H_ 32