Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qrandom.cpp File Reference
#include "qrandom.h"
#include "qrandom_p.h"
#include <qendian.h>
#include <qmutex.h>
#include <qobjectdefs.h>
#include <errno.h>
#include "qdeadlinetimer.h"
#include "qhashfunctions.h"
#include <qt_windows.h>
#include <assert.h>
+ Include dependency graph for qrandom.cpp:

Go to the source code of this file.

Classes

struct  QRandomGenerator::SystemGenerator
 
struct  QRandomGenerator::SystemAndGlobalGenerators
 
struct  QRandomGenerator::SystemAndGlobalGenerators::ShortenedSystem
 
struct  QRandomGenerator::SystemAndGlobalGenerators::PRNGLocker
 

Macros

#define _CRT_RAND_S
 
#define Q_ASSERT(cond)   assert(cond)
 
#define Q_ASSERT_X(cond, x, msg)   assert(cond && msg)
 

Enumerations

enum  { FillBufferNoexcept = true }
 

Functions

DECLSPEC_IMPORT BOOLEAN WINAPI SystemFunction036 (PVOID RandomBuffer, ULONG RandomBufferLength)
 
static void fallback_update_seed (unsigned value)
 
static Q_NEVER_INLINE void fallback_fill (quint32 *ptr, qsizetype left) noexcept
 
bool operator== (const QRandomGenerator &rng1, const QRandomGenerator &rng2)
 
template<typename Generator , typename FillBufferType , typename T >
static qsizetype callFillBuffer (FillBufferType f, T *v)
 
QRandomGenerator::InitialRandomData qt_initial_random_value () noexcept
 

Variables

static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed = Q_BASIC_ATOMIC_INITIALIZER(0U)
 

Macro Definition Documentation

◆ _CRT_RAND_S

#define _CRT_RAND_S

Definition at line 6 of file qrandom.cpp.

◆ Q_ASSERT

#define Q_ASSERT (   cond)    assert(cond)

Definition at line 47 of file qrandom.cpp.

◆ Q_ASSERT_X

#define Q_ASSERT_X (   cond,
  x,
  msg 
)    assert(cond && msg)

Definition at line 48 of file qrandom.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FillBufferNoexcept 

Definition at line 56 of file qrandom.cpp.

Function Documentation

◆ callFillBuffer()

template<typename Generator , typename FillBufferType , typename T >
static qsizetype callFillBuffer ( FillBufferType  f,
T *  v 
)
static

Definition at line 1266 of file qrandom.cpp.

◆ fallback_fill()

static Q_NEVER_INLINE void fallback_fill ( quint32 ptr,
qsizetype  left 
)
staticnoexcept

Definition at line 209 of file qrandom.cpp.

References base, QDeadlineTimer::current(), QDeadlineTimer::deadline(), fallback_update_seed(), generator, Qt::PreciseTimer, ptr(), Q_ASSERT, seed, and sseq().

Referenced by QRandomGenerator::SystemGenerator::generate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fallback_update_seed()

static void fallback_update_seed ( unsigned  value)
static

Definition at line 197 of file qrandom.cpp.

References seed.

Referenced by fallback_fill(), and QRandomGenerator::SystemGenerator::generate().

+ Here is the caller graph for this function:

◆ operator==()

bool operator== ( const QRandomGenerator rng1,
const QRandomGenerator rng2 
)
related

Definition at line 1219 of file qrandom.cpp.

Referenced by QPainterPath::Element::operator!=(), QPixmapCache::Key::operator!=(), QtFontStyle::Key::operator!=(), QAuthenticator::operator!=(), QBrush::operator!=(), QCameraFormat::operator!=(), QColor::operator!=(), QDir::operator!=(), QEasingCurve::operator!=(), QEventPoint::operator!=(), QFileSystemModelPrivate::QFileSystemNode::operator!=(), QFileInfo::operator!=(), QFontMetrics::operator!=(), QFontMetricsF::operator!=(), QGeoCoordinateObject::operator!=(), QGeoCoordinateObject::operator!=(), QGlyphRun::operator!=(), QGradient::operator!=(), QHostAddress::operator!=(), QHttpPart::operator!=(), QImageEncoderSettings::operator!=(), QItemSelectionRange::operator!=(), QMediaEncoderSettings::operator!=(), QMediaFormat::operator!=(), QMimeType::operator!=(), QNdefRecord::operator!=(), QNetworkRequest::operator!=(), QOpenGLDebugMessage::operator!=(), QPalette::operator!=(), QPen::operator!=(), QPersistentModelIndex::operator!=(), QRawFont::operator!=(), QRegion::operator!=(), QRegularExpression::operator!=(), QSqlField::operator!=(), QSqlRecord::operator!=(), QSslCertificate::operator!=(), QSslCipher::operator!=(), QSslKey::operator!=(), QTextFormat::operator!=(), QTextTableCell::operator!=(), QXmlStreamAttribute::operator!=(), QXmlStreamEntityDeclaration::operator!=(), QXmlStreamNamespaceDeclaration::operator!=(), QXmlStreamNotationDeclaration::operator!=(), QTextOption::Tab::operator!=(), QHostAddress::operator!=(), and QT6_ONLY().

+ Here is the caller graph for this function:

◆ qt_initial_random_value()

QRandomGenerator::InitialRandomData qt_initial_random_value ( )
noexcept

Returns an initial random value (useful for QHash's global seed). This function attempts to use OS-provided random values to avoid initializing QRandomGenerator::system() and qsimd.cpp.

Note: on some systems, this functionn may rerturn the same value every time it is called.

Definition at line 1287 of file qrandom.cpp.

◆ SystemFunction036()

DECLSPEC_IMPORT BOOLEAN WINAPI SystemFunction036 ( PVOID  RandomBuffer,
ULONG  RandomBufferLength 
)

Variable Documentation

◆ seed

Q_CONSTINIT QBasicAtomicInteger<unsigned> seed = Q_BASIC_ATOMIC_INITIALIZER(0U)
static

Definition at line 196 of file qrandom.cpp.

Referenced by QHashPrivate::calculateHash(), fallback_fill(), fallback_update_seed(), QHashPrivate::hash(), QTlsPrivate::X509CertificateOpenSSL::hash(), QTlsPrivate::X509CertificateGeneric::hash(), QVLABase< T >::hash(), QGeoCirclePrivate::hash(), QGeoPathPrivate::hash(), QGeoPolygonPrivate::hash(), QGeoRectanglePrivate::hash(), QPRand::init(), murmurhash(), QHashPrivate::noexceptPairHash(), QtPrivate::QHashCombine::operator()(), QtPrivate::QHashCombineCommutative::operator()(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), qHash(), qHash(), QSGBatchRenderer::qHash(), QSGBatchRenderer::qHash(), QV4::qHash(), QHash< Key, T >::qHash(), QByteArray::FromBase64Result::qHash(), qHash(), qHash(), qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), qHash(), qHash(), qHash(), qHash(), QFont::qHash(), qHash(), qHash(), qHash(), QGeoAddress::qHash(), QHash< Key, T >::qHash(), QGeoLocation::qHash(), QHash< Key, T >::qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), QQC2_NAMESPACE::qHash(), qHash(), QMultiHash< Key, T >::qHash(), QHash< Key, T >::qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), QRawFont::qHash(), qHash(), QRhiShaderResourceBinding::qHash(), qHash(), qHash(), qHash(), QShaderKey::qHash(), qHash(), QSharedPointer< T >::qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), qHash(), qHash(), qHash(), QTransform::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QUuid::qHash(), qHash(), qHash(), qHash(), QHash< Key, T >::qHash(), qHash(), qHash(), QV4::qHash(), qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), qHash(), qHash(), QHash< Key, T >::qHash(), qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), qHash(), qHash(), qHash(), qHash(), QHash< Key, T >::qHash(), qHash(), QHash< Key, T >::qHash(), qHash(), QHash< Key, T >::qHash(), QMetaType::qHash(), QHash< Key, T >::qHash(), QPointingDeviceUniqueId::qHash(), qHash(), QStringView::qHash(), qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), QHash< Key, T >::qHashBits(), QHash< Key, T >::qHashMulti(), QHash< Key, T >::qHashMultiCommutative(), QHash< Key, T >::qHashRange(), QHash< Key, T >::qHashRangeCommutative(), QT6_ONLY(), and siphash().