squid-
cache.org
Optimising Web Delivery
Docs
Download
Donate
Support
About
Contact
Shop
Blog
src
base
Random.cc
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3
*
4
* Squid software is distributed under GPLv2+ license and includes
5
* contributions from numerous individuals and organizations.
6
* Please see the COPYING and CONTRIBUTORS files for details.
7
*/
8
9
#include "
squid.h
"
10
#include "
base/Random.h
"
11
12
std::mt19937::result_type
13
RandomSeed32
()
14
{
15
// We promise entropy collection without waiting, but there is no standard
16
// way to get that in all environments. We considered these device names:
17
//
18
// * none: The default constructor in some specialized STL implementation or
19
// build might select a device that requires Squid to wait for entropy.
20
//
21
// * "default": Leads to clang (and other STLs) exceptions in some builds
22
// (e.g., when clang is built to use getentropy(3) or rand_s()).
23
//
24
// * "/dev/urandom": Blocks GCC from picking the best entropy source (e.g.,
25
// arc4random(3)) and leads to GCC/clang exceptions in some environments.
26
//
27
// If a special supported environment needs a non-default device name, we
28
// will add a random_device_name configuration directive. We cannot detect
29
// such needs in general code and choose to write simpler code until then.
30
static
std::random_device dev;
31
return
dev();
32
}
33
34
std::mt19937_64::result_type
35
RandomSeed64
()
36
{
37
std::mt19937_64::result_type left =
RandomSeed32
();
38
return
(left << 32) |
RandomSeed32
();
39
}
40
RandomSeed32
std::mt19937::result_type RandomSeed32()
Definition:
Random.cc:13
RandomSeed64
std::mt19937_64::result_type RandomSeed64()
a 64-bit version of RandomSeed32()
Definition:
Random.cc:35
Random.h
squid.h
Introduction
About Squid
Why Squid?
Squid Developers
How to Donate
How to Help Out
Getting Squid
Squid Source Packages
Squid Deployment Case-Studies
Squid Software Foundation
Documentation
Quick Setup
Configuration:
Reference
Examples
FAQ
and
Wiki
Guide Books:
Beginners
Definitive
Non-English
More...
Support
Security Advisories
Bugzilla Database
Mailing lists
Contacting us
Commercial services
Project Sponsors
Squid-based products
Miscellaneous
Developer Resources
Related Writings
Related Software:
Authenticators
Ecap
Icap
Ident
Log Analysis
Monitor
Proxies
Redirectors
General
Squid Artwork
Web Site Translations
Japanese
Mirrors
Website:
il
...
full list
FTP Package Archive