Skip to content

Commit

Permalink
runtime: avoid name collision with getrandom() from libc [Jafar Al-Gh…
Browse files Browse the repository at this point in the history
…araibeh]

This is a slight rework of commit 27b385c. It is needed because the
PRNG code uses unicon_getrandom() in fmisc.r as well as init.r
  • Loading branch information
Don-Ward committed Nov 14, 2024
1 parent 3de3a0c commit 4186187
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/h/rproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/fmisc.r
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/runtime/init.r
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -1675,7 +1674,7 @@ int err()
return strcmp(a->pstrep, b->pstrep);
}

static word unicon_getrandom(void)
word unicon_getrandom()
{
#ifndef NoRandomize
/*
Expand Down

0 comments on commit 4186187

Please sign in to comment.