代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/glibc 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 359653aaacad463d916323f03c0ac3c47405aafa Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed, 16 Jan 2019 18:10:56 +0000
Subject: [PATCH] Do not use HP_TIMING_NOW for random bits
This patch removes the HP_TIMING_BITS usage for fast random bits and replace
with clock_gettime (CLOCK_MONOTONIC). It has unspecified starting time and
nano-second accuracy, so its randomness is significantly better than
gettimeofday.
Althoug it should incur in more overhead (specially for architecture that
support hp-timing), the symbol is also common implemented as a vDSO.
Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also
checked on a i686-gnu build.
* include/random-bits.h: New file.
* resolv/res_mkquery.c [HP_TIMING_AVAIL] (RANDOM_BITS,
(__res_context_mkquery): Remove usage hp-timing usage and replace with
random_bits.
* resolv/res_send.c [HP_TIMING_AVAIL] (nameserver_offset): Likewise.
* sysdeps/posix/tempname.c [HP_TIMING_AVAIL] (__gen_tempname):
Likewise.
note that this patch is just parts of the origin one to adapt glibc-2.28
---
resolv/res_mkquery.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c
index 213abeef..7ba40640 100644
--- a/resolv/res_mkquery.c
+++ b/resolv/res_mkquery.c
@@ -95,6 +95,7 @@
#include <hp-timing.h>
#include <stdint.h>
+#include <time.h>
#if HP_TIMING_AVAIL
# define RANDOM_BITS(Var) { uint64_t v64; HP_TIMING_NOW (v64); Var = v64; }
#endif
@@ -124,9 +125,12 @@ __res_context_mkquery (struct resolv_context *ctx, int op, const char *dname,
#ifdef RANDOM_BITS
RANDOM_BITS (randombits);
#else
- struct timeval tv;
- __gettimeofday (&tv, NULL);
- randombits = (tv.tv_sec << 8) ^ tv.tv_usec;
+ struct timespec tv;
+ clock_gettime (CLOCK_MONOTONIC, &tv);
+ /* Shuffle the lower bits to minimize the clock bias. */
+ uint32_t ret = tv.tv_nsec ^ tv.tv_sec;
+ ret ^= (ret << 24) | (ret >> 8);
+ randombits = ret;
#endif
hp->id = randombits;
--
2.19.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。