From 4186187484d51c5f9bdba9672740b72b1e707705 Mon Sep 17 00:00:00 2001 From: Don Ward Date: Mon, 1 Jul 2024 11:28:39 +0100 Subject: [PATCH] runtime: avoid name collision with getrandom() from libc [Jafar Al-Gharaibeh] This is a slight rework of commit 27b385c3. It is needed because the PRNG code uses unicon_getrandom() in fmisc.r as well as init.r --- src/h/rproto.h | 1 + src/runtime/fmisc.r | 4 ++-- src/runtime/init.r | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/h/rproto.h b/src/h/rproto.h index eb11a33f2..0cecd8e6c 100644 --- a/src/h/rproto.h +++ b/src/h/rproto.h @@ -279,6 +279,7 @@ int fldlookup (struct b_record *rec, const char * const fld); void fpetrap (void); int getenv_r (const char *name, char *buf, size_t len); +word unicon_getrandom(void); int getvar (char *s,dptr vp); int getkeyword (char *s, dptr vp); diff --git a/src/runtime/fmisc.r b/src/runtime/fmisc.r index c738b4e1d..c9112586e 100644 --- a/src/runtime/fmisc.r +++ b/src/runtime/fmisc.r @@ -2842,7 +2842,7 @@ body { /* Revert to built-in rngIcon */ curtstate->rng = NULL; curtstate->Kywd_ran = zerodesc; - IntVal(curtstate->Kywd_ran) = getrandom(); /* Reinitialize */ + IntVal(curtstate->Kywd_ran) = unicon_getrandom(); /* Reinitialize */ } else { #ifndef Arrays /* The rng state is stored as an array of integers */ @@ -2958,7 +2958,7 @@ body { /* Call startRng */ { struct rng_rt_api api; - api.getInitialBits = getrandom; + api.getInitialBits = unicon_getrandom; api.getRngState = getRngState; api.putErrorCode = putErrorCode; diff --git a/src/runtime/init.r b/src/runtime/init.r index 54e7c3e70..e6185d164 100644 --- a/src/runtime/init.r +++ b/src/runtime/init.r @@ -15,7 +15,6 @@ static FILE * readhdr (char *name, struct header *hdr); /* * Prototypes. */ -static word unicon_getrandom(void); static void env_err (char *msg, char *name, char *val); FILE *pathOpen (char *fname, char *mode); @@ -1675,7 +1674,7 @@ int err() return strcmp(a->pstrep, b->pstrep); } -static word unicon_getrandom(void) +word unicon_getrandom() { #ifndef NoRandomize /*