mirror of
https://github.com/AuxXxilium/arc-lkm.git
synced 2024-11-23 23:00:57 +07:00
d288da5003
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
16 lines
417 B
C
Executable File
16 lines
417 B
C
Executable File
#include "math_helper.h"
|
|
#include <linux/random.h> //prandom_u32()
|
|
|
|
int prandom_int_range_stable(int *cur_val, int dev, int min, int max)
|
|
{
|
|
if (likely(*cur_val != 0)) {
|
|
int new_min = (*cur_val) - dev;
|
|
int new_max = (*cur_val) + dev;
|
|
min = new_min < min ? min : new_min;
|
|
max = new_max > max ? max : new_max;
|
|
}
|
|
|
|
*cur_val = prandom_int_range(min, max);
|
|
|
|
return *cur_val;
|
|
} |