fix mdoc references and mistakes

This commit is contained in:
fair 1998-04-28 21:19:49 +00:00
parent a27dd1341b
commit aba63e6a51
5 changed files with 72 additions and 60 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: free.3,v 1.5 1998/02/05 18:49:54 perry Exp $
.\" $NetBSD: free.3,v 1.6 1998/04/28 21:19:49 fair Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -54,21 +54,19 @@ The
.Fn free
function causes the space pointed to by
.Fa ptr
to be deallocated, that is, made available
for further allocation.
to be deallocated, that is, made available for further allocation.
If
.Fa ptr
is a null pointer, no action occurs.
Otherwise, if the argument does not match a pointer earlier
returned by the
.Xr calloc ,
.Xr malloc ,
Otherwise, if the argument does not match a pointer earlier returned by the
.Fn calloc
.Fn malloc
or
.Xr realloc
.Fn realloc
function, or if the space has been deallocated by a call to
.Fn free
or
.Xr realloc ,
.Fn realloc ,
general havoc may occur.
.Sh RETURN VALUES
The

View File

@ -1,4 +1,4 @@
.\" $NetBSD: getopt.3,v 1.12 1998/02/05 18:49:57 perry Exp $
.\" $NetBSD: getopt.3,v 1.13 1998/04/28 21:19:49 fair Exp $
.\"
.\" Copyright (c) 1988, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -151,8 +151,8 @@ Setting
.Va opterr
to a zero will disable these error messages.
If
.Va optstring
has a leading
.Va optstring
has a leading
.Ql \&:
then a missing option argument causes a
.Ql \&:
@ -206,13 +206,13 @@ function appeared
The
.Fn getopt
function was once specified to return
.Dv EOF
.Dv EOF
instead of \-1.
This was changed by
.St -p1003.2-92
to decouple
to decouple
.Fn getopt
from
from
.Pa <stdio.h> .
.Pp
A single dash

View File

@ -1,4 +1,4 @@
.\" $NetBSD: rand48.3,v 1.4 1998/02/05 18:50:15 perry Exp $
.\" $NetBSD: rand48.3,v 1.5 1998/04/28 21:19:49 fair Exp $
.\"
.\" Copyright (c) 1993 Martin Birgmeier
.\" All rights reserved.
@ -51,12 +51,13 @@
The
.Fn rand48
family of functions generates pseudo-random numbers using a linear
congruential algorithm working on integers 48 bits in size. The
particular formula employed is
congruential algorithm working on integers 48 bits in size.
The particular formula employed is
r(n+1) = (a * r(n) + c) mod m
where the default values are
for the multiplicand a = 0xfdeece66d = 25214903917 and
the addend c = 0xb = 11. The modulus is always fixed at m = 2 ** 48.
the addend c = 0xb = 11.
The modulus is always fixed at m = 2 ** 48.
r(n) is called the seed of the random number generator.
.Pp
For all the six generator routines described next, the first
@ -65,30 +66,30 @@ computational step is to perform a single iteration of the algorithm.
.Fn drand48
and
.Fn erand48
return values of type double. The full 48 bits of r(n+1) are
loaded into the mantissa of the returned value, with the exponent set
such that the values produced lie in the interval [0.0, 1.0).
return values of type double.
The full 48 bits of r(n+1) are loaded into the mantissa of the
returned value, with the exponent set such that the values produced
lie in the interval [0.0, 1.0).
.Pp
.Fn lrand48
and
.Fn nrand48
return values of type long in the range
[0, 2**31-1]. The high-order (31) bits of
r(n+1) are loaded into the lower bits of the returned value, with
the topmost (sign) bit set to zero.
return values of type long in the range [0, 2**31-1].
The high-order (31) bits of r(n+1) are loaded into the lower bits
of the returned value, with the topmost (sign) bit set to zero.
.Pp
.Fn mrand48
and
.Fn jrand48
return values of type long in the range
[-2**31, 2**31-1]. The high-order (32) bits of
r(n+1) are loaded into the returned value.
return values of type long in the range [-2**31, 2**31-1].
The high-order (32) bits of r(n+1) are loaded into the returned value.
.Pp
.Fn drand48 ,
.Fn lrand48 ,
and
.Fn mrand48
use an internal buffer to store r(n). For these functions
use an internal buffer to store r(n).
For these functions
the initial value of r(0) = 0x1234abcd330e = 20017429951246.
.Pp
On the other hand,
@ -96,9 +97,9 @@ On the other hand,
.Fn nrand48 ,
and
.Fn jrand48
use a user-supplied buffer to store the seed r(n),
which consists of an array of 3 shorts, where the zeroth member
holds the least significant bits.
use a user-supplied buffer to store the seed r(n), which consists
of an array of 3 shorts, where the zeroth member holds the least
significant bits.
.Pp
All functions share the same multiplicand and addend.
.Pp
@ -120,8 +121,8 @@ also initializes the internal buffer r(n) of
and
.Fn mrand48 ,
but here all 48 bits of the seed can be specified in an array of 3 shorts,
where the zeroth member specifies the lowest bits. Again,
the constant multiplicand and addend of the algorithm are
where the zeroth member specifies the lowest bits.
Again, the constant multiplicand and addend of the algorithm are
reset to the default values given above.
.Fn seed48
returns a pointer to an array of 3 shorts which contains the old seed.

View File

@ -1,4 +1,4 @@
.\" $NetBSD: random.3,v 1.7 1998/02/05 18:50:16 perry Exp $
.\" $NetBSD: random.3,v 1.8 1998/04/28 21:19:50 fair Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -46,7 +46,7 @@
.Lb libc
.Sh SYNOPSIS
.Fd #include <stdlib.h>
.Ft long
.Ft long
.Fn random void
.Ft void
.Fn srandom "unsigned seed"
@ -68,46 +68,56 @@ The period of this random number generator is very large, approximately
.if n 16*((2**31)\(mi1).
.Pp
The
.Fn random Ns / Fn srandom
have (almost) the same calling sequence and initialization properties as
.Xr rand 3 Ns / Xr srand 3 .
The difference is that
.Xr rand
produces a much less random sequence \(em in fact, the low dozen bits
generated by rand go through a cyclic pattern. All the bits generated by
.Fn random
are usable. For example,
and
.Fn srandom
have (almost) the same calling sequence and initialization properties as
.Xr rand 3
and
.Xr srand 3 .
The difference is that
.Xr rand 3
produces a much less random sequence \(em in fact, the low dozen bits
generated by
.Xr rand 3
go through a cyclic pattern.
All the bits generated by
.Fn random
are usable.
For example,
.Sq Li random()&01
will produce a random binary
value.
will produce a random binary value.
.Pp
Unlike
.Xr srand ,
.Xr srand 3 ,
.Fn srandom
does not return the old seed; the reason for this is that the amount of
state information used is much more than a single word. (Two other
routines are provided to deal with restarting/changing random
number generators). Like
state information used is much more than a single word.
(Two other routines are provided to deal with restarting/changing
random number generators).
Like
.Xr rand 3 ,
however,
.Fn random
will by default produce a sequence of numbers that can be duplicated
by calling
.Fn srandom
with
with
.Ql 1
as the seed.
.Pp
The
.Fn initstate
routine allows a state array, passed in as an argument, to be initialized
for future use. The size of the state array (in bytes) is used by
for future use.
The size of the state array (in bytes) is used by
.Fn initstate
to decide how sophisticated a random number generator it should use \(em the
more state, the better the random numbers will be.
(Current "optimal" values for the amount of state information are
8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to
the nearest known amount. Using less than 8 bytes will cause an error.)
the nearest known amount.
Using less than 8 bytes will cause an error).
The seed for the initialization (which specifies a starting point for
the random number sequence, and provides for restarting at the same
point) is also an argument.
@ -160,10 +170,13 @@ is called with less than 8 bytes of state information, or if
detects that the state information has been garbled, error
messages are printed on the standard error output.
.Sh SEE ALSO
.Xr rand 3
.Xr rand 3 ,
.Xr srand 3 ,
.Xr rnd 4 ,
.Xr rnd 9
.Sh HISTORY
These
functions appeared in
functions appeared in
.Bx 4.2 .
.Sh BUGS
About 2/3 the speed of

View File

@ -1,4 +1,4 @@
.\" $NetBSD: realloc.3,v 1.8 1998/02/05 18:50:17 perry Exp $
.\" $NetBSD: realloc.3,v 1.9 1998/04/28 21:19:50 fair Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -68,16 +68,16 @@ Otherwise, if
does not match a pointer earlier returned by the
.Xr calloc 3 ,
.Xr malloc 3 ,
or
or
.Fn realloc
function, or if the space has been deallocated
by a call to the
.Xr free
.Fn free
or
.Fn realloc
function, unpredictable and usually detrimental
behavior will occur.
If the space cannot be allocated, the object
If the space cannot be allocated, the object
pointed to by
.Fa ptr
is unchanged.