summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-16 15:21:59 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-16 15:22:23 +0000
commit139f19f867bec728466af6b29f9a96178b96992b (patch)
treeb35a3eeff60bd5a06e97aac7dfa240788810e2ec /util/nvmutil
parent4ecce163d601a4df007bc48ed0b9f2f11b3cfc47 (diff)
util/nvmutil: portable gettimeofday
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 12a6cf5a..8de30619 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -373,6 +373,7 @@ static ushort hextonum(char ch_s);
static ushort rhex(void);
static ushort read_urandom(void);
static ulong entropy_jitter(void);
+static int x_i_gettimeofday(struct timeval *tv, void *tz);
static void write_mac_part(size_t partnum);
/*
@@ -1356,7 +1357,7 @@ rhex(void)
/* Fallback */
- gettimeofday(&tv, NULL);
+ x_i_gettimeofday(&tv, NULL);
mix = (ulong)tv.tv_sec
^ (ulong)tv.tv_usec
@@ -1421,9 +1422,9 @@ entropy_jitter(void)
int i;
for (i = 0; i < 8; i++) {
- gettimeofday(&a, NULL);
+ x_i_gettimeofday(&a, NULL);
getpid();
- gettimeofday(&b, NULL);
+ x_i_gettimeofday(&b, NULL);
/*
* prevent negative numbers to prevent overflow,
@@ -1440,6 +1441,21 @@ entropy_jitter(void)
return mix;
}
+static int
+x_i_gettimeofday(struct timeval *tv, void *tz)
+{
+ time_t t;
+
+ (void)tz;
+
+ t = time(NULL);
+
+ tv->tv_sec = t;
+ tv->tv_usec = (long)clock() % 1000000;
+
+ return 0;
+}
+
static void
write_mac_part(size_t partnum)
{