[committed] libstdc++: Add [[unlikely]] attributes to std::random_device routines

Message ID 20211105181739.2245825-1-jwakely@redhat.com
State Committed
Commit 2627e3b7fd820876bc45c99be48aea05351d210a
Headers
Series [committed] libstdc++: Add [[unlikely]] attributes to std::random_device routines |

Commit Message

Jonathan Wakely Nov. 5, 2021, 6:17 p.m. UTC
  Tested x86+64-linux, pushed to trunk.


libstdc++-v3/ChangeLog:

	* src/c++11/random.cc (__x86_rdrand, __x86_rdseed): Add
	[[unlikely]] attribute.
---
 libstdc++-v3/src/c++11/random.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/libstdc++-v3/src/c++11/random.cc b/libstdc++-v3/src/c++11/random.cc
index 55a73c51fca..4b88818646f 100644
--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -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)
 	    {