summaryrefslogtreecommitdiffstats
path: root/src/H5.c
diff options
context:
space:
mode:
authorLeon Arber <larber@ncsa.uiuc.edu>2006-03-16 21:35:32 (GMT)
committerLeon Arber <larber@ncsa.uiuc.edu>2006-03-16 21:35:32 (GMT)
commitbac394c4956281bcd5b4f653a152c659b3f5bb9c (patch)
tree1a4c7eee21291119be17d07c00ec5d13e60e8ba0 /src/H5.c
parent6e8ba9561dff2585c5078a01c4d6db0f790ba1fb (diff)
downloadhdf5-bac394c4956281bcd5b4f653a152c659b3f5bb9c.zip
hdf5-bac394c4956281bcd5b4f653a152c659b3f5bb9c.tar.gz
hdf5-bac394c4956281bcd5b4f653a152c659b3f5bb9c.tar.bz2
[svn-r12110] Purpose:
Optimization Description: Get rid of unnecessary function call for systems that don't have rand_r. Solution: If rand_r isn't present on a system, then macros can be used to simply call the underlying random function instead of calling the HDrand/HDsrand functions that keep track of the random seed within the library. Platforms tested: heping (minor change) Misc. update:
Diffstat (limited to 'src/H5.c')
-rw-r--r--src/H5.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/H5.c b/src/H5.c
index 724ea35..9988414 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -3119,12 +3119,11 @@ H5_trace (const double *returning, const char *func, const char *type, ...)
* Function: HDrand/HDsrand
*
* Purpose: Wrapper function for rand. If rand_r exists on this system,
- * use it. Otherwise, just call random() or rand().
+ * use it.
*
* Wrapper function for srand. If rand_r is available, it will keep
* track of the seed locally instead of using srand() which modifies
- * global state and can break other programs. Otherwise, just call
- * srandom() or srand().
+ * global state and can break other programs.
*
* Return: Success: Random number from 0 to RAND_MAX
*
@@ -3136,26 +3135,18 @@ H5_trace (const double *returning, const char *func, const char *type, ...)
* Modifications:
*-------------------------------------------------------------------------
*/
+#ifdef H5_HAVE_RAND_R
+
static unsigned int g_seed = 42;
int HDrand(void)
{
-#ifdef H5_HAVE_RAND_R
return rand_r(&g_seed);
-#elif H5_HAVE_RANDOM
- return random();
-#else
- return rand();
-#endif
}
void HDsrand(unsigned int seed)
{
-#ifdef H5_HAVE_RAND_R
g_seed = seed;
-#elif H5_HAVE_RANDOM
- srandom(seed);
-#else
- srand(seed);
-#endif
}
+
+#endif