Rename lib_rand.c to lib_srand.c

This commit is contained in:
Gregory Nutt 2016-07-17 07:11:09 -06:00
parent 6cefbc0c3f
commit ffd3a31649
3 changed files with 10 additions and 10 deletions

View File

@ -138,20 +138,20 @@ static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer,
/* Align buffer pointer to 4-byte boundry */
if ((unsigned)buffer & 0x03)
if (((unsigned)buffer & 0x03) != 0)
{
/* Generate a pseudo random number */
rnd = xorshift128();
while ((unsigned)buffer & 0x03)
while (((unsigned)buffer & 0x03) != 0)
{
if (n <= 0)
{
return len;
}
*buffer++ = rnd & 0xFF;
*buffer++ = rnd & 0xff;
rnd >>= 8;
--n;
}

View File

@ -37,7 +37,7 @@
CSRCS += lib_abs.c lib_abort.c lib_div.c lib_ldiv.c lib_lldiv.c
CSRCS += lib_imaxabs.c lib_itoa.c lib_labs.c lib_llabs.c
CSRCS += lib_bsearch.c lib_rand.c lib_qsort.c
CSRCS += lib_bsearch.c lib_srand.c lib_qsort.c
CSRCS += lib_strtol.c lib_strtoll.c lib_strtoul.c lib_strtoull.c
CSRCS += lib_strtod.c lib_checkbase.c

View File

@ -1,7 +1,7 @@
/****************************************************************************
* libc/stdlib/lib_rand.c
* libc/stdlib/lib_srand.c
*
* Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2011, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -70,7 +70,7 @@
* Private Function Prototypes
****************************************************************************/
static unsigned int nrand(unsigned int nLimit);
static unsigned int nrand(unsigned int limit);
/* First order congruential generators */
@ -111,7 +111,7 @@ static unsigned long g_randint3;
* Private Functions
****************************************************************************/
static unsigned int nrand(unsigned int nLimit)
static unsigned int nrand(unsigned int limit)
{
unsigned long result;
double_t ratio;
@ -132,9 +132,9 @@ static unsigned int nrand(unsigned int nLimit)
/* Then, produce the return-able value */
result = (unsigned long)(((double_t)nLimit) * ratio);
result = (unsigned long)(((double_t)limit) * ratio);
}
while (result >= (unsigned long)nLimit);
while (result >= (unsigned long)limit);
return (unsigned int)result;
}