]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add [[unlikely]] attributes to std::random_device routines
authorJonathan Wakely <jwakely@redhat.com>
Fri, 5 Nov 2021 12:18:52 +0000 (12:18 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 5 Nov 2021 18:14:41 +0000 (18:14 +0000)
libstdc++-v3/ChangeLog:

* src/c++11/random.cc (__x86_rdrand, __x86_rdseed): Add
[[unlikely]] attribute.

libstdc++-v3/src/c++11/random.cc

index 55a73c51fcaae8bf4dcda97c39ed4fcc41b7ead7..4b88818646f14fef3996ddd7521166b3501963a0 100644 (file)
@@ -97,7 +97,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
       unsigned int retries = 100;
       unsigned int val;
 
-      while (__builtin_ia32_rdrand32_step(&val) == 0)
+      while (__builtin_ia32_rdrand32_step(&val) == 0) [[__unlikely__]]
        if (--retries == 0)
          std::__throw_runtime_error(__N("random_device: rdrand failed"));
 
@@ -113,7 +113,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
       unsigned int retries = 100;
       unsigned int val;
 
-      while (__builtin_ia32_rdseed_si_step(&val) == 0)
+      while (__builtin_ia32_rdseed_si_step(&val) == 0) [[__unlikely__]]
        {
          if (--retries == 0)
            {