pearse@hound.UUCP (S.PEARSE) (07/05/85)
Hi, I am trying to compile a program posted to the net a while back called "insult", using kafka as pre-processor. I think insult is a BSD-based program. It uses reference to random and srandom, producing symbol referencing errors in the link stage of the compile. Does anyone know what I should use in place of random and srandom? And, what I would *really* like, does anyone have a compilation of the most-often-used BSD to UNIX conversion tricks?? I know of a few basic ones, like the strchr to strrchr fixes. It seems that 90% of BSD programs can be converted to SYSV with just #include changes and a few other things. Please send mail to me or post BSD-UNIX summary to the net. Thanks! -- Steve Pearse ihnp4!hound!pearse
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (07/07/85)
> Does anyone know what I should use in place of random and srandom?
Lesson # 3. Using the manual:
Look in the Permuted Index at the front of your PRM.
Under "random" we find reference to rand(3C) & rand(3F).
In Section 3, RAND(3C) describes the traditional UNIX
random number generator, and the "SEE ALSO" section
of this manual entry refers us to drand48(3C), which
describes a collection of better RNGs.
guy@sun.uucp (Guy Harris) (07/09/85)
> > Does anyone know what I should use in place of random and srandom? > > Lesson # 3. Using the manual: Using the System V manual isn't sufficient; you need the 4.2BSD manual to tell you what "random" does in the first place. The guy may not have a 4.2BSD manual, in which case telling him to "use the manual" doesn't help much. Guy Harris
gam@amdahl.UUCP (G A Moffett) (07/10/85)
In article <2399@sun.uucp> guy@sun.uucp (Guy Harris) writes: >> > Does anyone know what I should use in place of random and srandom? >> >> Lesson # 3. Using the manual: > >Using the System V manual isn't sufficient; you need the 4.2BSD manual to >tell you what "random" does in the first place. The guy may not have a >4.2BSD manual, in which case telling him to "use the manual" doesn't help >much. > > Guy Harris Guy raises an important point: If you are going to be working around Unix for a while it is a good idea to have available to you manuals of the various versions, especially SVR2, 4.[12] BSD, and Version 7. As in this example there are compatible routines with different names, and it just takes a bit of effort to figure these things out. If you don't already have these references available to you, it is *well worth* the investment to have them. Ecclectic knowledge of Unix (of anything?) is a good thing. -- Gordon A. Moffett ...!{ihnp4,cbosgd,sun}!amdahl!gam
edward@ukecc.UUCP (Edward C. Bennett) (07/11/85)
In article <2399@sun.uucp>, guy@sun.uucp (Guy Harris) writes: > > > Does anyone know what I should use in place of random and srandom? > > > > Lesson # 3. Using the manual: > > Using the System V manual isn't sufficient; you need the 4.2BSD manual to > tell you what "random" does in the first place. The guy may not have a > 4.2BSD manual, in which case telling him to "use the manual" doesn't help > much. > In particular, while BSD and sysV RNGs both return ints, you must pay attention to what an int is. On a local VAX 11/750 an int is 4 bytes. On our 3B20S an int is 2 bytes. Usually this won't make any difference, but every now and then you'll probably find a program where it does. -- Edward C. Bennett UUCP: ihnp4!cbosgd!ukma!ukecc!edward /* A charter member of the Scooter bunch */
edward@ukecc.UUCP (Edward C. Bennett) (07/14/85)
In article <156@ukecc.UUCP>, edward@ukecc.UUCP (Edward C. Bennett) writes: > In article <2399@sun.uucp>, guy@sun.uucp (Guy Harris) writes: > > > > Does anyone know what I should use in place of random and srandom? > > > > In particular, while BSD and sysV RNGs both return ints, you > must pay attention to what an int is. On a local VAX 11/750 an int is 4 > bytes. On our 3B20S an int is 2 bytes. > Usually this won't make any difference, but every now and then > you'll probably find a program where it does. It seems that I spoke too soon. Ints on our 3B20S are indeed 4 bytes long. rand() returns a 4 byte value BUT (this is the catch) the value is masked to its lower 15 bits yeilding 0 <= rand() <= 32767. -- Edward C. Bennett UUCP: ihnp4!cbosgd!ukma!ukecc!edward /* A charter member of the Scooter bunch */
guy@sun.uucp (Guy Harris) (07/16/85)
> In particular, while BSD and sysV RNGs both return ints, you > must pay attention to what an int is. On a local VAX 11/750 an int is 4 > bytes. On our 3B20S an int is 2 bytes. Geepers, that flies in the face of whatever I've heard about the 3B20. (BTW, I think the changes of the size of an "int" being different on other VAXes, even if they're different models, are somewhere between zip, zero, and nil.) What I think you mean to say is In particular, while 4.xBSD and (PDP-11 V7/System III/System V) RNGs both return "int"s, you must pay attention to what subrange of the range of an "int" they return. On 4.xBSD they return a number in the range 0 - 2^31 - 1. On Systems III and V, and on V7 implementations on 16-bit machines, they return a number in the range 0 - 2^15 - 1. (On UNIX/32V it returns a number in the range 0 - 2^31 - 1, which is presumably why 4.xBSD does so also. I presume they decided to make it return the same range on 16-bit-"int" and 32-bit-"int" machines in System III - or UNIX/TS - to make it possible to reduce the result of "rand" to a fixed range without #ifdefing code for different "int" sizes.) Guy Harris
whp@cbnap.UUCP (W. H. Pollock x4575 3S235) (07/17/85)
>> . . . On a local VAX 11/750 an int is 4 >> bytes. On our 3B20S an int is 2 bytes. > >Geepers, that flies in the face of whatever I've heard about the 3B20. On a 3B20S an int is 4 bytes. Don't beleive everything you read in usenet!