X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a0cf866ecda011f77f1fa22ea33a8e8d2bce7b1b..7817355e1053db0ad176750462d290516dc993e3:/src/surf/random_mgr.c diff --git a/src/surf/random_mgr.c b/src/surf/random_mgr.c index e65576afa7..74210edf23 100644 --- a/src/surf/random_mgr.c +++ b/src/surf/random_mgr.c @@ -1,12 +1,14 @@ -/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team. +/* Copyright (c) 2007-2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ #include "surf/random_mgr.h" #include "xbt/sysdep.h" -#include "gras_config.h" /*_XBT_WIN32*/ +#include "src/internal_config.h" /*_XBT_WIN32*/ +#include +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(random, surf, "Random part of surf"); @@ -54,7 +56,7 @@ union ieee754_double { } ieee_nan; }; -#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */ +#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */ double drand48(void); @@ -191,7 +193,7 @@ int _rand_r(unsigned int *pseed) #endif -static double custom_random(Generator generator, long int *seed) +static double custom_random(e_random_generator_t generator, long int *seed) { switch (generator) { @@ -200,8 +202,8 @@ static double custom_random(Generator generator, long int *seed) case RAND: return (double) rand_r((unsigned int *) seed) / RAND_MAX; case RNGSTREAM : - XBT_INFO("Seen RNGSTREAM"); - return 0.0; + XBT_INFO("Seen RNGSTREAM"); + return 0.0; default: return drand48(); } @@ -252,7 +254,7 @@ double random_generate(random_data_t random) return X * (random->max - random->min) + random->min; } -random_data_t random_new(Generator generator, long int seed, +random_data_t random_new(e_random_generator_t generator, long int seed, double min, double max, double mean, double std) { random_data_t random = xbt_new0(s_random_data_t, 1); @@ -264,12 +266,12 @@ random_data_t random_new(Generator generator, long int seed, /* Check user stupidities */ if (max < min) - THROW2(arg_error, 0, "random->max < random->min (%f < %f)", max, min); + THROWF(arg_error, 0, "random->max < random->min (%f < %f)", max, min); if (mean < min) - THROW2(arg_error, 0, "random->mean < random->min (%f < %f)", mean, + THROWF(arg_error, 0, "random->mean < random->min (%f < %f)", mean, min); if (mean > max) - THROW2(arg_error, 0, "random->mean > random->max (%f > %f)", mean, + THROWF(arg_error, 0, "random->mean > random->max (%f > %f)", mean, max); /* normalize the mean and standard deviation before storing */ @@ -277,7 +279,7 @@ random_data_t random_new(Generator generator, long int seed, random->std = std / (max - min); if (random->mean * (1 - random->mean) < random->std * random->std) - THROW2(arg_error, 0, "Invalid mean and standard deviation (%f and %f)", + THROWF(arg_error, 0, "Invalid mean and standard deviation (%f and %f)", random->mean, random->std); return random;