7cb5ebab3f
- aggiornamento Vroni a 7.8.
70 lines
2.4 KiB
C
70 lines
2.4 KiB
C
/*****************************************************************************/
|
|
/* */
|
|
/* Copyright (C) 1999-2025 M. Held */
|
|
/* */
|
|
/* This code is not in the public domain. All rights reserved! Please make */
|
|
/* sure to read the full copyright statement contained in "README.txt" or in */
|
|
/* the "main" file of this code, such as "main.cc". */
|
|
/* */
|
|
/*****************************************************************************/
|
|
/* */
|
|
/* Written by: Martin Held */
|
|
/* */
|
|
/* E-Mail: held@cs.sbg.ac.at */
|
|
/* Fax Mail: (+43 662) 8044-611 */
|
|
/* Voice Mail: (+43 662) 8044-6304 */
|
|
/* Snail Mail: Martin Held */
|
|
/* FB Informatik */
|
|
/* Universitaet Salzburg */
|
|
/* A-5020 Salzburg, Austria */
|
|
/* */
|
|
/*****************************************************************************/
|
|
|
|
#ifndef VRONI_RANDOM_H
|
|
#define VRONI_RANDOM_H
|
|
|
|
|
|
#ifndef RAND
|
|
|
|
#ifdef RANDOM_R
|
|
|
|
#define RandomInteger(N, result) \
|
|
{\
|
|
assert(N > 0); \
|
|
random_r(rdata, &result); \
|
|
result = result % N;}
|
|
|
|
#define InitRandom(seed) \
|
|
{\
|
|
rdata = (random_data*) calloc(1,sizeof(struct random_data)); \
|
|
initstate_r(seed, statebuf, 8, rdata); }
|
|
|
|
#else
|
|
|
|
#define RandomInteger(N, result) \
|
|
{\
|
|
assert(N > 0); \
|
|
result = random() % N;}
|
|
|
|
#define InitRandom(seed) \
|
|
{\
|
|
srandom(seed); }
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define RandomInteger(N, result) \
|
|
{\
|
|
assert(N > 0); \
|
|
result = rand() % N;}
|
|
|
|
#define InitRandom(seed) \
|
|
{\
|
|
srand(seed); }
|
|
|
|
#endif
|
|
|
|
|
|
#endif
|