Reindent server/core/random_jkiss.c
This commit is contained in:
@ -99,7 +99,12 @@ random_jkiss_devrand(void)
|
|||||||
{
|
{
|
||||||
int fn;
|
int fn;
|
||||||
unsigned int r;
|
unsigned int r;
|
||||||
if ((fn = open("/dev/urandom", O_RDONLY)) == -1) return 0;
|
|
||||||
|
if ((fn = open("/dev/urandom", O_RDONLY)) == -1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (read(fn, &r, sizeof(r)) != sizeof(r))
|
if (read(fn, &r, sizeof(r)) != sizeof(r))
|
||||||
{
|
{
|
||||||
r = 0;
|
r = 0;
|
||||||
@ -118,14 +123,32 @@ static void
|
|||||||
random_init_jkiss(void)
|
random_init_jkiss(void)
|
||||||
{
|
{
|
||||||
int newrand, i;
|
int newrand, i;
|
||||||
|
|
||||||
spinlock_acquire(&random_jkiss_spinlock);
|
spinlock_acquire(&random_jkiss_spinlock);
|
||||||
if ((newrand = random_jkiss_devrand()) != 0) x = newrand;
|
|
||||||
if ((newrand = random_jkiss_devrand()) != 0) y = newrand;
|
|
||||||
if ((newrand = random_jkiss_devrand()) != 0) z = newrand;
|
|
||||||
if ((newrand = random_jkiss_devrand()) != 0)
|
if ((newrand = random_jkiss_devrand()) != 0)
|
||||||
|
{
|
||||||
|
x = newrand;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((newrand = random_jkiss_devrand()) != 0)
|
||||||
|
{
|
||||||
|
y = newrand;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((newrand = random_jkiss_devrand()) != 0)
|
||||||
|
{
|
||||||
|
z = newrand;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((newrand = random_jkiss_devrand()) != 0)
|
||||||
|
{
|
||||||
c = newrand % 698769068 + 1; /* Should be less than 698769069 */
|
c = newrand % 698769068 + 1; /* Should be less than 698769069 */
|
||||||
|
}
|
||||||
spinlock_release(&random_jkiss_spinlock);
|
spinlock_release(&random_jkiss_spinlock);
|
||||||
|
|
||||||
/* "Warm up" our random number generator */
|
/* "Warm up" our random number generator */
|
||||||
for (i = 0; i < 100; i++) random_jkiss();
|
for (i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
random_jkiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,23 @@
|
|||||||
|
#ifndef RANDOM_JKISS_H
|
||||||
|
#define RANDOM_JKISS_H
|
||||||
|
/*
|
||||||
|
* This file is distributed as part of the MariaDB Corporation MaxScale. It is free
|
||||||
|
* software: you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation,
|
||||||
|
* version 2.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||||
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Copyright MariaDB Corporation Ab 2013-2014
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* File: random_jkiss.h
|
* File: random_jkiss.h
|
||||||
* Author: mbrampton
|
* Author: mbrampton
|
||||||
@ -5,9 +25,6 @@
|
|||||||
* Created on 26 August 2015, 15:34
|
* Created on 26 August 2015, 15:34
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RANDOM_JKISS_H
|
|
||||||
#define RANDOM_JKISS_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -19,4 +36,3 @@ extern unsigned int random_jkiss(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* RANDOM_H */
|
#endif /* RANDOM_H */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user