Fix incompatible API on AIX with random_r and initstate_r
https://bugs.freedesktop.org/show_bug.cgi?id=74603
This commit is contained in:
parent
7d75653285
commit
e310d2fac2
|
@ -170,14 +170,27 @@ FcRandom(void)
|
||||||
static struct random_data fcrandbuf;
|
static struct random_data fcrandbuf;
|
||||||
static char statebuf[256];
|
static char statebuf[256];
|
||||||
static FcBool initialized = FcFalse;
|
static FcBool initialized = FcFalse;
|
||||||
|
#ifdef _AIX
|
||||||
|
static char *retval;
|
||||||
|
long res;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (initialized != FcTrue)
|
if (initialized != FcTrue)
|
||||||
{
|
{
|
||||||
initstate_r(time(NULL), statebuf, 256, &fcrandbuf);
|
#ifdef _AIX
|
||||||
|
initstate_r (time (NULL), statebuf, 256, &retval, &fcrandbuf);
|
||||||
|
#else
|
||||||
|
initstate_r (time (NULL), statebuf, 256, &fcrandbuf);
|
||||||
|
#endif
|
||||||
initialized = FcTrue;
|
initialized = FcTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
random_r(&fcrandbuf, &result);
|
#ifdef _AIX
|
||||||
|
random_r (&res, &fcrandbuf);
|
||||||
|
result = (int32_t)res;
|
||||||
|
#else
|
||||||
|
random_r (&fcrandbuf, &result);
|
||||||
|
#endif
|
||||||
#elif HAVE_RANDOM
|
#elif HAVE_RANDOM
|
||||||
static char statebuf[256];
|
static char statebuf[256];
|
||||||
char *state;
|
char *state;
|
||||||
|
@ -185,30 +198,30 @@ FcRandom(void)
|
||||||
|
|
||||||
if (initialized != FcTrue)
|
if (initialized != FcTrue)
|
||||||
{
|
{
|
||||||
state = initstate(time(NULL), statebuf, 256);
|
state = initstate (time (NULL), statebuf, 256);
|
||||||
initialized = FcTrue;
|
initialized = FcTrue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
state = setstate(statebuf);
|
state = setstate (statebuf);
|
||||||
|
|
||||||
result = random();
|
result = random ();
|
||||||
|
|
||||||
setstate(state);
|
setstate (state);
|
||||||
#elif HAVE_LRAND48
|
#elif HAVE_LRAND48
|
||||||
result = lrand48();
|
result = lrand48 ();
|
||||||
#elif HAVE_RAND_R
|
#elif HAVE_RAND_R
|
||||||
static unsigned int seed = time(NULL);
|
static unsigned int seed = time (NULL);
|
||||||
|
|
||||||
result = rand_r(&seed);
|
result = rand_r (&seed);
|
||||||
#elif HAVE_RAND
|
#elif HAVE_RAND
|
||||||
static FcBool initialized = FcFalse;
|
static FcBool initialized = FcFalse;
|
||||||
|
|
||||||
if (initialized != FcTrue)
|
if (initialized != FcTrue)
|
||||||
{
|
{
|
||||||
srand(time(NULL));
|
srand (time (NULL));
|
||||||
initialized = FcTrue;
|
initialized = FcTrue;
|
||||||
}
|
}
|
||||||
result = rand();
|
result = rand ();
|
||||||
#else
|
#else
|
||||||
# error no random number generator function available.
|
# error no random number generator function available.
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue