summaryrefslogtreecommitdiff
path: root/components/libc/compilers/minilibc/rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'components/libc/compilers/minilibc/rand.c')
-rw-r--r--components/libc/compilers/minilibc/rand.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/components/libc/compilers/minilibc/rand.c b/components/libc/compilers/minilibc/rand.c
index 88603dc808..8bbf42a32b 100644
--- a/components/libc/compilers/minilibc/rand.c
+++ b/components/libc/compilers/minilibc/rand.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -13,10 +13,10 @@
static unsigned int _seed=1;
/* Knuth's TAOCP section 3.6 */
-#define M ((1U<<31) -1)
-#define A 48271
-#define Q 44488 // M/A
-#define R 3399 // M%A; R < Q !!!
+#define M ((1U<<31) -1)
+#define A 48271
+#define Q 44488 // M/A
+#define R 3399 // M%A; R < Q !!!
int rand_r(unsigned int* seed)
{ int32_t X;
@@ -24,7 +24,7 @@ int rand_r(unsigned int* seed)
X = *seed;
X = A*(X%Q) - R * (int32_t) (X/Q);
if (X < 0)
- X += M;
+ X += M;
*seed = X;
return X;
@@ -35,8 +35,8 @@ int rand(void) {
}
void srand(unsigned int i)
-{
- _seed=i;
+{
+ _seed=i;
}
int random(void) __attribute__((alias("rand")));