This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cross-platform thread-safe RNG drand48_r


Qianqian Fang <fangqq@gmail.com> writes:

> I was trying to compile a simulation code on
> multiple platforms. It involves a thread-safe
> 48bit POSIX random number generator (RNG),
> drand48_r/seed48_r. I tried gcc 4.4 on Ubuntu
> 10.4 and it compiled fine. However, when
> I run gcc 4.0 on Mac OS X, it gave me error:
>
> posix_randr.h:29: error: array type has incomplete element type
>
> and the offending lines read like:
>
> typedef struct drand48_data RandType;
> __device__ float rand_uniform01(RandType t[RAND_BUF_LEN]);
> ...
>
> Similar error when compiling on Windows with
> MinGW gcc 3.4.
>
> Because drand48 is supposed to be a POSIX function,
> I am a bit surprised when seeing multiple platforms
> responded differently. Did I miss anything? or
> this is the correct behavior?

As far as I know drand48 is not in POSIX.  It's in the SVID and it's
in X/Open, but I don't think it's in POSIX proper.  And as far as I
know drand48_r is just a GNU extension to drand48.  But it's certainly
possible that POSIX picked this up somewhere.

In any case, this sounds like a bug, but it sounds like a library bug;
it doesn't sound like a compiler bug.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]