From 0d6d5035ce4458d46b1251a2aa23de4a3d24cc58 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 3 May 2024 19:10:26 +0300 Subject: [PATCH] v7 microsecond timestamp can exceed 999 when the system clock resolution is too coarse (e.g. MinGW) --- doc/uuid/changes.adoc | 16 +++++++++------- test/test_time_generator_v7.cpp | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/uuid/changes.adoc b/doc/uuid/changes.adoc index e09f654..701c97f 100644 --- a/doc/uuid/changes.adoc +++ b/doc/uuid/changes.adoc @@ -8,25 +8,27 @@ * {cpp}03 is no longer supported, a {cpp}11 compiler is required. This includes GCC 4.8 or later, MSVC 14.0 or later, and MinGW-w64. * Removed direct dependencies on Core, Io, Move, NumericConversion, StaticAssert, TTI, Random, ContainerHash. - The library now only has five Boost dependencies (as opposed to 39 in Boost 1.85.) + The library now only has five Boost dependencies in total (as opposed to 39 in Boost 1.85.) * Moved `std::hash` support from `uuid_hash.hpp` to `uuid.hpp`. * Moved serialization support from `uuid_serialize.hpp` to `uuid.hpp`. -* Added convenience header ``. * Improved the quality and speed of `hash_value`. -* Removed platform-specific entropy providers; the implementation now uses `std::random_device` as the source of entropy. -* Since `basic_name_generator` had only two valid instantiations, both of which are already provided (`name_generator_md5` and `name_generator_sha1`), - it was made a private implementation detail and is no longer part of the public interface. -* While `name_generator` and `name_generator_latest` are still provided for compatibility, their use is no longer encouraged. -* The definitions of the well-known RFC 4122 namespaces have been moved to their own header, `boost/uuid/namespaces.hpp`. * Added `operator\<\=>`. * The generic (non-SIMD) implementations of `is_nil`, `operator==`, `operator<`, `swap`, and `operator\<\=>` now use `__uint128_t` operations when that type is available, and `uint64_t` operations otherwise. +* Added convenience header ``. +* Removed platform-specific entropy providers; the implementation now uses `std::random_device` as the source of entropy. * `basic_random_generator` has been moved to its own header, `boost/uuid/basic_random_generator.hpp`. * `basic_random_generator` has been changed to hold the underlying generator by value, to avoid dynamic allocation and restore copyability. * `random_generator_pure` is now an alias for `basic_random_generator` and its use is discouraged. * `random_generator_mt19937` is now an alias for `basic_random_generator` and its use is discouraged. * `random_generator` now uses a cryptographically strong pseudorandom number generator (ChaCha20/12), seeded with entropy from `std::random_device`. It's the recommended way to generate version 4 UUIDs. +* Since `basic_name_generator` had only two valid instantiations, both of which are already provided (`name_generator_md5` and `name_generator_sha1`), + it was made a private implementation detail and is no longer part of the public interface. +* While `name_generator` and `name_generator_latest` are still provided for compatibility, their use is no longer encouraged. +* The definitions of the well-known RFC 4122 namespaces have been moved to their own header, `boost/uuid/namespaces.hpp`. * Added `time_generator_v1`, a generator that produces version 1 time-based UUIDs. +* Added `time_generator_v6`, a generator that produces version 6 time-based UUIDs. +* Added `time_generator_v7`, a generator that produces version 7 time-based UUIDs. * Added `uuid_clock`, a ``-compatible clock with an epoch and a resolution as specified in RFC 4122. * Accessors for the timestamp, the time point, the clock sequence, and the node identifier have been added to `uuid`. * Improved the `what()` strings of the `std::runtime_error` exceptions thrown by `string_generator`. diff --git a/test/test_time_generator_v7.cpp b/test/test_time_generator_v7.cpp index 3e0f5d3..6d7064f 100644 --- a/test/test_time_generator_v7.cpp +++ b/test/test_time_generator_v7.cpp @@ -25,7 +25,7 @@ uuid generate_and_test( time_generator_v7& gen ) // break in future releases. std::uint64_t time_in_us = u.timestamp_v6() & 0xFFF; // v6 time_low field - BOOST_TEST_LT( time_in_us, 1000 ); + BOOST_TEST_LT( time_in_us, 1010 ); auto sys_after = std::chrono::time_point_cast( std::chrono::system_clock::now() );