#ifndef PORTABLE_UTILS_H
#define PORTABLE_UTILS_H

#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef HAVE_DRAND48
// Some system (e.g., Windows) doesn't come with drand48(), srand48().
// Use rand, and srand for such system.

// Remove extern declarations to avoid conflicts
// extern double drand48(void); // Change this to static if it should be static

extern double drand48(void)
{
    return ((double)rand())/RAND_MAX;
}

// Remove extern declarations to avoid conflicts
// extern double srand48(long int seedval); // Change this to static if it should be static

extern void srand48(long int seedval)
{
    srand(seedval);
}
#endif

#ifdef __cplusplus
}
#endif

#endif