Commit 1208456
libstdc++: Implement std::philox_engine for targets without __int128
This moves the __detail::_Select_uint_least_t<N>::type class to
namespace scope and extends it with more 128-bit arithmetic operations,
implemented in terms of uint64_t.
Now std::philox_engine can use _Select_uint_least_t<w*2>::type instead
of __uint128_t, so that it works on targets without 128-bit integers.
This also means that targets that do support __uint128_t only use it
when actually necessary, so that we use uint64_t when generating a
32-bit result (e.g. with std::philox4x32).
libstdc++-v3/ChangeLog:
* include/bits/random.h [!__SIZEOF_INT128__] (__rand_uint128):
Refactor and rename _Select_uint_least_t<128>::type to a new
class. Make all members constexpr. Add new member functions for
additional arithmetic and bitwise operations, and comparisons.
(__detail::_Select_uint_least_t<>::type): Define as an alias of
__rand_uint128.
* include/bits/random.tcc (philox_engine::_M_mulhi): Use
_Select_uint_least_t<w*2>::type instead of __uint128_t.
(philox_engine::_M_transition): Likewise.
* include/bits/version.def (philox_engine): Remove extra_cond.
* include/bits/version.h: Regenerate.
* testsuite/26_numerics/random/philox4x32.cc: Remove
dg-require-cpp-feature-test directive.
* testsuite/26_numerics/random/philox4x64.cc: Likewise.
* testsuite/26_numerics/random/philox_engine/cons/copy.cc:
Likewise.
* testsuite/26_numerics/random/philox_engine/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/philox_engine/cons/seed.cc:
Likewise.
* testsuite/26_numerics/random/philox_engine/operators/equal.cc:
Likewise.
* testsuite/26_numerics/random/philox_engine/operators/serialize.cc:
Likewise.
* testsuite/26_numerics/random/philox_engine/requirements/constants.cc:
Likewise.
* testsuite/26_numerics/random/philox_engine/requirements/typedefs.cc:
Likewise.
Co-authored-by: Jakub Jelinek <[email protected]>
Reviewed-by: Tomasz Kamiński <[email protected]>1 parent a9eb2f2 commit 1208456
File tree
13 files changed
+440
-127
lines changed- libstdc++-v3
- include/bits
- testsuite/26_numerics/random
- philox_engine
- cons
- operators
- requirements
13 files changed
+440
-127
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
918 | | - | |
919 | | - | |
920 | | - | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
921 | 921 | | |
922 | 922 | | |
923 | 923 | | |
| |||
938 | 938 | | |
939 | 939 | | |
940 | 940 | | |
| 941 | + | |
| 942 | + | |
941 | 943 | | |
942 | 944 | | |
943 | 945 | | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
953 | 954 | | |
954 | 955 | | |
955 | 956 | | |
956 | 957 | | |
957 | 958 | | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | | - | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
962 | 963 | | |
963 | 964 | | |
964 | 965 | | |
965 | | - | |
966 | | - | |
967 | | - | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
968 | 969 | | |
969 | 970 | | |
970 | 971 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2241 | 2241 | | |
2242 | 2242 | | |
2243 | 2243 | | |
2244 | | - | |
2245 | 2244 | | |
2246 | 2245 | | |
2247 | 2246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2507 | 2507 | | |
2508 | 2508 | | |
2509 | 2509 | | |
2510 | | - | |
| 2510 | + | |
2511 | 2511 | | |
2512 | 2512 | | |
2513 | 2513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
0 commit comments