bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (random t) always returns the same number under HP-UX 10.20


From: Klaus Zeitler
Subject: Re: (random t) always returns the same number under HP-UX 10.20
Date: 05 Dec 2001 11:04:19 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Eli" == Eli Zaretskii <address@hidden> writes:
    Eli> 
    Eli> On 3 Dec 2001, Klaus Zeitler wrote:
    Eli> 
    >> >> (random t) always returns the same number when I call it right after
    >> >> starting emacs -q. According to the docu this call should set a
    >> >> random seed from the current time and pid.
    Eli> 
    Eli> What happens if you invoke (random t) and then (random 100000)
    Eli> repeatedly?
    Eli> 
    Eli> You are not supposed to call (random t) more than once per a random
    Eli> sequence.  (random t) simply calls `srandom' (or a similar function),
    Eli> which seeds the RNG.  The real sequence comes from the subsequent
    Eli> calls to `random' whose argument is anything _but_ t.
    Eli> 
yes I know that, but I misunderstood your question above
    Eli> 
    Eli> Could you please look at src/s/hpux10.h and src/sysdep.c, and see what
    Eli> macros related to random are defined in your build?  (Search for
    Eli> "random" case-insensitively in these two files.)
    Eli> 
    Eli> Also, what are the prototypes of `srandom', `random', `srand48', and
    Eli> `lrand48' on your HP-UX machine (should be in stdlib.h)?  Perhaps by
    Eli> comparing the prototypes with the above-mentioned Emacs files, you
    Eli> could find some discrepancy that explains the problems?
    Eli> 
well I took a look at this random stuff (I'm still dizzy from all those
defines and includes :-). There's quite a bunch of hpux includes:
hpux10 -> hpux9shr.h -> hpux9.h -> hpux8.h -> hpux.h

In hpux.h there's:
#define random lrand48
#define srandom srand48

and in hpux10.h there's:
#undef srandom
#undef srand48

This looks to me as if there's a mixture of random and rand48 functions.
Therefore I added to hpux10.h:
#undef random

i.e. the following simple patch
---------------------------
11a12
> #undef random
---------------------------

and that did it for me, i.e. under HP-UX 10 the standard srandom/random
functions are now used. One could probably also use the combination
lrand48/srand48 but I haven't tried this. If this were to prefer maybe
one would have to make sure that HAVE_RANDOM is not set (just speculating,
since I don't know what the preferred random function pair is)

BTW hpux10.h contains in the first few lines twice the statement:
#define HPUX10

HTH

Klaus

-- 
 ------------------------------------------
|  Klaus Zeitler      Lucent Technologies  |
|  Email:             address@hidden  |
 ------------------------------------------
---
Westheimer's Discovery:  A couple of months in the laboratory
can frequently save a couple of hours in the library.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]