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

Re: error message "Random is not portable"



Hi,

I got this suggestion. But unfortunately I still have problems for this, so
let me describe the phenomenon in detail, though it will be long.

> On Thu, 5 Aug 1999, Mikihiro Ueno wrote:
>
> > I just started learnig ns. Let me ask a basic question.
> > I installed ns-allinone-2.1b5 and it was successful.
> > But following the tutrial (http://titan.cs.uni-bonn.de/~greis/ns/ns.html),
> > I run ns with the file "example1a.tcl" which includes only two nodes and one link,
> > and I got an error message;
> >
> >         % random() called in ns.
> >         Random is not portable, please use Random::uniform() instead.
> >
> > and nam won't be started automatically.
> >
> > What's wrong???
> >
> > can anyone help me this problem?
>
> A programmer forgot about cross-platform considerations; one reason
> why the snapshots a week after a major release are always a good
> bet... It should be fixed in a later snapshot - or you can
>
> grep "random\(\)" *.cc
>
> edit it as suggested, and recompile.
>
> cheers,
>
> L.
>
> Random is not portable?
> So, are we talking about the class here, or random() ? Could be clearer.
>
> <[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>

Following this suggestion, I did as follows;

I found these 9 files(listed below) which include "random()" under ns-allinone-2.1b5/.

1.  ns-2.1b5/random.cc
2.  ns-2.1b5/rancom.h
3.  ns-2.1b5/rng.h
4.  ns-2.1b5/indep-utils/cmu-scen-gen/setdest/calcdest.cc
5.  ns-2.1b5/indep-utils/cmu-scen-gen/setdest/setdest.cc
6.  nam-1.0a7/random.cc
7.  nam-1.0a7/config.h
8.  nam-1.0a7/rng.h
9.  gt-itm/src/ts.c

Then...

For 2, 3, 7, and 8, I did nothing because random() in these files are
only definitions.

For 4, 5, and 9, I changed random() into Random::uniform(), following
the suggestion. I believed that it means random() would not be called
anymore.

For 1 and 6, I editted as below just in case random() is called.

random()
{
        return (long)Random::uniform();
        /*printf("random() called in ns.\nRandom is not portable, please use Random::uniform() instead.\n");
           abort();*/
}

After I recompiled, I could run ns without any error messages.
Then when I run nam with the out.nam, I got a error message "segmentation fault".

To trace what is happening inside, I used the xxgdb in "step mode".
It starts from main() in nam-1.0a7/main.cc, and from line # 297 of main.cc
          Tcl_Interp *interp = Tcl_CreateInterp();
it goes into enetmodel.c (I couldn't understand why???), then after 2 steps,
it goes into rng.cc line # 139
        long
        RNGImplementation::next()
        {
                long L, H;
                L = A * (seed_ & 0xffff);         // <---here!!

and suddenly runs into "segmentation fault".

I wondered if some modification I did was incorrect.
So, I re-editted the file nam-1.0a7/random.cc (No.6 in the list above) as below

random()
{
        printf("random() called in ns.\nRandom is not portable, please use Random::uniform() instead.\n");
        return (long)Random::uniform();
         /*abort();*/
}


After I recompiled, I used the xxgdb again.
Then I found that, right before the "segmentation fault" happens, random()
in random.cc is called.
I really can't understand why!
I believe that I changed all random() into Random::uniform(), but still
random() is called somehow????

Does anybody know WHO calls random() and what I should do for this problem?
And from the first step, these modifications I did for the error message
"random() is not portable" were really correct?
Is there any other file I should edit random() into Random::uniform()?



Any suggestions would be appreciated.



Mikihiro Ueno