random.h 969 B

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