Add mkfile to keep indices up to date.
Remove man pages for things we don't provide.
This commit is contained in:
parent
058b0118a5
commit
a19c44b83b
18 changed files with 45 additions and 2321 deletions
|
|
@ -1,18 +0,0 @@
|
|||
.TH ABORT 3
|
||||
.SH NAME
|
||||
abort \- generate a fault
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.nf
|
||||
.B
|
||||
void abort(void)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.I Abort
|
||||
causes an access fault, causing the current process to enter the `Broken' state.
|
||||
The process can then be inspected by a debugger.
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/9sys/abort.c
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
.TH ACCESS 3
|
||||
.SH NAME
|
||||
access \- determine accessibility of file
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.B
|
||||
int access(char *name, int mode)
|
||||
.SH DESCRIPTION
|
||||
.I Access
|
||||
evaluates the given
|
||||
file
|
||||
.I name
|
||||
for accessibility.
|
||||
If \fImode\fL&4\fR
|
||||
is nonzero,
|
||||
read permission is expected;
|
||||
if \fImode\fL&2\fR,
|
||||
write permission;
|
||||
if \fImode\fL&1\fR,
|
||||
execute permission.
|
||||
If \fImode\fL==0\fR,
|
||||
the file merely need exist.
|
||||
In any case
|
||||
all directories leading to the file
|
||||
must permit searches.
|
||||
Zero is returned if the desired access is permitted,
|
||||
\-1 if not.
|
||||
.PP
|
||||
Only access for open is checked.
|
||||
A file may look executable, but
|
||||
.IR exec (3)
|
||||
will fail unless it is in proper format.
|
||||
.PP
|
||||
The include file
|
||||
.F <libc.h>
|
||||
defines
|
||||
.BR AEXIST =0,
|
||||
.BR AEXEC =1,
|
||||
.BR AWRITE =2,
|
||||
and
|
||||
.BR AREAD =4.
|
||||
.PP
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/9sys/access.c
|
||||
.SH SEE ALSO
|
||||
.IR stat (3)
|
||||
.SH DIAGNOSTICS
|
||||
Sets
|
||||
.IR errstr .
|
||||
.SH BUGS
|
||||
Since file permissions are checked by the server and group information
|
||||
is not known to the client,
|
||||
.I access
|
||||
must open the file to check permissions.
|
||||
(It calls
|
||||
.IR stat (3)
|
||||
to check simple existence.)
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
.TH ASSERT 3
|
||||
.SH NAME
|
||||
assert \- check program invariants
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.B
|
||||
#define assert if(cond);else _assert("cond")
|
||||
.PP
|
||||
.B
|
||||
void _assert(int cond)
|
||||
.SH DESCRIPTION
|
||||
.I Assert
|
||||
is a preprocessor macro that
|
||||
(via
|
||||
.IR _assert )
|
||||
prints a message and calls
|
||||
.I abort
|
||||
when
|
||||
.I cond
|
||||
is false.
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/port/_assert.c
|
||||
160
man/man3/ctype.3
160
man/man3/ctype.3
|
|
@ -1,160 +0,0 @@
|
|||
.TH CTYPE 3
|
||||
.SH NAME
|
||||
isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isascii, toascii, _toupper, _tolower, toupper, tolower \- ASCII character classification
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.br
|
||||
.B #include <ctype.h>
|
||||
.PP
|
||||
.if t .2C
|
||||
.B isalpha(c)
|
||||
.PP
|
||||
.B isupper(c)
|
||||
.PP
|
||||
.B islower(c)
|
||||
.PP
|
||||
.B isdigit(c)
|
||||
.PP
|
||||
.B isxdigit(c)
|
||||
.PP
|
||||
.B isalnum(c)
|
||||
.PP
|
||||
.B isspace(c)
|
||||
.PP
|
||||
.B ispunct(c)
|
||||
.PP
|
||||
.B isprint(c)
|
||||
.PP
|
||||
.B isgraph(c)
|
||||
.PP
|
||||
.B iscntrl(c)
|
||||
.PP
|
||||
.B isascii(c)
|
||||
.PP
|
||||
.B _toupper(c)
|
||||
.PP
|
||||
.B _tolower(c)
|
||||
.PP
|
||||
.B toupper(c)
|
||||
.PP
|
||||
.B tolower(c)
|
||||
.PP
|
||||
.B toascii(c)
|
||||
.if t .1C
|
||||
.SH DESCRIPTION
|
||||
These macros classify
|
||||
.SM ASCII\c
|
||||
-coded integer values
|
||||
by table lookup.
|
||||
Each is a predicate returning nonzero for true,
|
||||
zero for false.
|
||||
.I Isascii
|
||||
is defined on all integer values; the rest
|
||||
are defined only where
|
||||
.I isascii
|
||||
is true and on the single non-\c
|
||||
.SM ASCII
|
||||
value
|
||||
.BR EOF ;
|
||||
see
|
||||
.IR fopen (3).
|
||||
.TP "\w'isalnum 'u"
|
||||
.I isalpha
|
||||
.I c
|
||||
is a letter, a\-z or A\-Z
|
||||
.TP
|
||||
.I isupper
|
||||
.I c
|
||||
is an upper case letter, A\-Z
|
||||
.TP
|
||||
.I islower
|
||||
.I c
|
||||
is a lower case letter, a\-z
|
||||
.TP
|
||||
.I isdigit
|
||||
.I c
|
||||
is a digit, 0\-9
|
||||
.TP
|
||||
.I isxdigit
|
||||
.I c
|
||||
is a hexadecimal digit, 0\-9 or a\-f or A\-F
|
||||
.TP
|
||||
.I isalnum
|
||||
.I c
|
||||
is an alphanumeric character, a\-z or A\-Z or 0\-9
|
||||
.TP
|
||||
.I isspace
|
||||
.I c
|
||||
is a space, horizontal tab, newline, vertical tab, formfeed, or carriage return
|
||||
(0x20, 0x9, 0xA, 0xB, 0xC, 0xD)
|
||||
.TP
|
||||
.I ispunct
|
||||
.I c
|
||||
is a punctuation character
|
||||
(one of
|
||||
.L
|
||||
!"#$%&'()*+,-./:;<=>?@[\e]^_`{|}~\fR)
|
||||
.TP
|
||||
.I isprint
|
||||
.I c
|
||||
is a printing character, 0x20 (space)
|
||||
through 0x7E (tilde)
|
||||
.TP
|
||||
.I isgraph
|
||||
.I c
|
||||
is a visible printing character, 0x21 (exclamation) through 0x7E
|
||||
(tilde)
|
||||
.TP
|
||||
.I iscntrl
|
||||
.I c
|
||||
is a delete character, 0x7F,
|
||||
or ordinary control character, 0x0 through 0x1F
|
||||
.TP
|
||||
.I isascii
|
||||
.I c
|
||||
is an
|
||||
.SM ASCII
|
||||
character, 0x0 through 0x7F
|
||||
.PP
|
||||
.I Toascii
|
||||
is not a classification macro;
|
||||
it converts its argument to
|
||||
.SM ASCII
|
||||
range by
|
||||
.IR and ing
|
||||
with 0x7F.
|
||||
.PP
|
||||
If
|
||||
.I c
|
||||
is an upper case letter,
|
||||
.I tolower
|
||||
returns the lower case version of the character;
|
||||
otherwise it returns the original character.
|
||||
.I Toupper
|
||||
is similar, returning the upper case version of a character
|
||||
or the original character.
|
||||
.I Tolower
|
||||
and
|
||||
.I toupper
|
||||
are functions;
|
||||
.I _tolower
|
||||
and
|
||||
.I _toupper
|
||||
are corresponding macros which should only be used when it
|
||||
is known that the argument is upper case or lower case, respectively.
|
||||
.SH SOURCE
|
||||
.TF /usr/local/plan9/src/libc/port/ctype.c
|
||||
.TP
|
||||
.B /sys/include/ctype.h
|
||||
for the macros.
|
||||
.TP
|
||||
.B /usr/local/plan9/src/libc/port/ctype.c
|
||||
for the tables.
|
||||
.SH "SEE ALSO
|
||||
.IR isalpharune (3)
|
||||
.SH BUGS
|
||||
These macros are
|
||||
.SM ASCII \c
|
||||
-centric.
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
.TH GETFCR 3
|
||||
.SH NAME
|
||||
getfcr, setfcr, getfsr, setfsr \- control floating point
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.B
|
||||
ulong getfcr(void)
|
||||
.PP
|
||||
.B
|
||||
void setfcr(ulong fcr)
|
||||
.PP
|
||||
.B
|
||||
ulong getfsr(void)
|
||||
.PP
|
||||
.B
|
||||
void setfsr(ulong fsr)
|
||||
.SH DESCRIPTION
|
||||
These routines provide a fairly portable interface to control the
|
||||
rounding and exception characteristics of IEEE 754 floating point units.
|
||||
In effect, they define a pair of pseudo-registers, the floating
|
||||
point control register,
|
||||
.BR fcr ,
|
||||
which affects rounding, precision, and exceptions, and the
|
||||
floating point status register,
|
||||
.BR fsr ,
|
||||
which holds the accrued exception bits.
|
||||
Each register has a
|
||||
.I get
|
||||
routine to retrieve its value, a
|
||||
.I set
|
||||
routine to modify it,
|
||||
and macros that identify its contents.
|
||||
.PP
|
||||
The
|
||||
.B fcr
|
||||
contains bits that, when set, halt execution upon exceptions:
|
||||
.B FPINEX
|
||||
(enable inexact exceptions),
|
||||
.B FPOVFL
|
||||
(enable overflow exceptions),
|
||||
.B FPUNFL
|
||||
(enable underflow exceptions),
|
||||
.B FPZDIV
|
||||
(enable zero divide exceptions), and
|
||||
.B FPINVAL
|
||||
(enable invalid operation exceptions).
|
||||
Rounding is controlled by installing in
|
||||
.BR fcr ,
|
||||
under mask
|
||||
.BR FPRMASK ,
|
||||
one of the values
|
||||
.B FPRNR
|
||||
(round to nearest),
|
||||
.B FPRZ
|
||||
(round towards zero),
|
||||
.B FPRPINF
|
||||
(round towards positive infinity), and
|
||||
.B FPRNINF
|
||||
(round towards negative infinity).
|
||||
Precision is controlled by installing in
|
||||
.BR fcr ,
|
||||
under mask
|
||||
.BR FPPMASK ,
|
||||
one of the values
|
||||
.B FPPEXT
|
||||
(extended precision),
|
||||
.B FPPSGL
|
||||
(single precision), and
|
||||
.B FPPDBL
|
||||
(double precision).
|
||||
.PP
|
||||
The
|
||||
.B fsr
|
||||
holds the accrued exception bits
|
||||
.BR FPAINEX ,
|
||||
.BR FPAOVFL ,
|
||||
.BR FPAUNFL ,
|
||||
.BR FPAZDIV ,
|
||||
and
|
||||
.BR FPAINVAL ,
|
||||
corresponding to the
|
||||
.B fsr
|
||||
bits without the
|
||||
.B A
|
||||
in the name.
|
||||
.PP
|
||||
Not all machines support all modes. If the corresponding mask
|
||||
is zero, the machine does not support the rounding or precision modes.
|
||||
On some machines it is not possible to clear selective accrued
|
||||
exception bits; a
|
||||
.I setfsr
|
||||
clears them all.
|
||||
The exception bits defined here work on all architectures.
|
||||
By default, the initial state is equivalent to
|
||||
.IP
|
||||
.EX
|
||||
setfcr(FPPDBL|FPRNR|FPINVAL|FPZDIV|FPOVFL);
|
||||
.EE
|
||||
.PP
|
||||
The default state of the floating point unit is fixed for a given
|
||||
architecture but is undefined across Plan 9: the default is
|
||||
to provide what the hardware does most efficiently.
|
||||
Use these routines
|
||||
if you need guaranteed behavior.
|
||||
Also, gradual underflow is not available on some machines.
|
||||
.SH EXAMPLE
|
||||
To enable overflow traps and make sure registers are rounded
|
||||
to double precision (for example on the MC68020, where the
|
||||
internal registers are 80 bits long):
|
||||
.EX
|
||||
.IP
|
||||
.ft L
|
||||
ulong fcr;
|
||||
fcr = getfcr();
|
||||
fcr |= FPOVFL;
|
||||
fcr &= ~FPPMASK;
|
||||
fcr |= FPPDBL;
|
||||
setfcr(fcr);
|
||||
.ft
|
||||
.EE
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/$objtype/getfcr.s
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
.TH HYPOT 3
|
||||
.SH NAME
|
||||
hypot \- Euclidean distance
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.nf
|
||||
.B
|
||||
double hypot(double x, double y)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.I Hypot
|
||||
returns
|
||||
.EX
|
||||
sqrt(x*x + y*y)
|
||||
.EE
|
||||
taking precautions against unwarranted overflows.
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/port/hypot.c
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
.TH MKTEMP 3
|
||||
.SH NAME
|
||||
mktemp \- make a unique file name
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.nf
|
||||
.B
|
||||
char* mktemp(char *template)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.I Mktemp
|
||||
replaces
|
||||
.I template
|
||||
by a unique file name, and returns the
|
||||
address of the template.
|
||||
The template should look like a file name with eleven trailing
|
||||
.LR X s.
|
||||
The
|
||||
.LR X s
|
||||
are replaced by a letter followed by the current process id.
|
||||
Letters from
|
||||
.L a
|
||||
to
|
||||
.L z
|
||||
are tried until a name that can be accessed
|
||||
(see
|
||||
.IR access (3))
|
||||
is generated.
|
||||
If no such name can be generated,
|
||||
.I mktemp
|
||||
returns
|
||||
\f5"/"\f1 .
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/port/mktemp.c
|
||||
.SH "SEE ALSO"
|
||||
.IR getpid (3),
|
||||
.IR access (3)
|
||||
329
man/man3/pool.3
329
man/man3/pool.3
|
|
@ -1,329 +0,0 @@
|
|||
.TH POOL 3
|
||||
.SH NAME
|
||||
poolalloc, poolfree, poolmsize, poolrealloc, poolcompact, poolcheck, poolblockcheck,
|
||||
pooldump \- general memory management routines
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.PP
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.B #include <pool.h>
|
||||
.PP
|
||||
.B
|
||||
void* poolalloc(Pool* pool, ulong size)
|
||||
.PP
|
||||
.B
|
||||
void poolfree(Pool* pool, void* ptr)
|
||||
.PP
|
||||
.B
|
||||
ulong poolmsize(Pool* pool, void* ptr)
|
||||
.PP
|
||||
.B
|
||||
void* poolrealloc(Pool* pool, void* ptr, ulong size)
|
||||
.PP
|
||||
.B
|
||||
void poolcompact(Pool* pool)
|
||||
.PP
|
||||
.B
|
||||
void poolcheck(Pool *pool)
|
||||
.PP
|
||||
.B
|
||||
void poolblockcheck(Pool *pool, void *ptr)
|
||||
.PP
|
||||
.B
|
||||
void pooldump(Pool *pool);
|
||||
.SH DESCRIPTION
|
||||
These routines provide a general memory management facility.
|
||||
Memory is retrieved from a coarser allocator (e.g.
|
||||
.I sbrk
|
||||
or the kernel's
|
||||
.IR xalloc )
|
||||
and then allocated to callers.
|
||||
The routines are locked and thus may safely be used in
|
||||
multiprocess programs.
|
||||
.PP
|
||||
.I Poolalloc
|
||||
attempts to allocate a block of size
|
||||
.BR size ;
|
||||
it returns a pointer to the block when successful and nil otherwise.
|
||||
The call
|
||||
.B "poolalloc(0)
|
||||
returns a non-nil pointer.
|
||||
.I Poolfree
|
||||
returns an allocated block to the pool.
|
||||
It is an error to free a block more than once or to free a
|
||||
pointer not returned by
|
||||
.IR poolalloc .
|
||||
The call
|
||||
.B "poolfree(nil)
|
||||
is legal and is a no-op.
|
||||
.I Poolrealloc
|
||||
attempts to resize to
|
||||
.B nsize
|
||||
bytes the block associated with
|
||||
.BR ptr ,
|
||||
which must have been previously returned by
|
||||
.I poolalloc
|
||||
or
|
||||
.IR poolrealloc .
|
||||
If the block's size can be adjusted, a (possibly different) pointer to the new block is returned.
|
||||
The contents up to the lesser of the old and new sizes are unchanged.
|
||||
After a successful call to
|
||||
.IR poolrealloc ,
|
||||
the return value should be used rather than
|
||||
.B ptr
|
||||
to access the block.
|
||||
If the request cannot be satisfied,
|
||||
.I poolrealloc
|
||||
returns nil, and the old pointer remains valid.
|
||||
.PP
|
||||
When blocks are allocated, there is often some extra space left at the end
|
||||
that would usually go unused.
|
||||
.IR Poolmsize
|
||||
grows the block to encompass this extra space and returns the new size.
|
||||
.PP
|
||||
The
|
||||
.I poolblockcheck
|
||||
and
|
||||
.I poolcheck
|
||||
routines validate a single allocated block or the entire pool, respectively.
|
||||
They call
|
||||
.B panic
|
||||
(see below)
|
||||
if corruption is detected.
|
||||
.I Pooldump
|
||||
prints a summary line for every block in the
|
||||
pool, using the
|
||||
.B print
|
||||
function (see below).
|
||||
.PP
|
||||
The
|
||||
.B Pool
|
||||
structure itself provides much of the setup interface.
|
||||
.IP
|
||||
.EX
|
||||
.ta \w'\fL 'u +\w'\fLulong 'u +\w'\fLlastcompact; 'u
|
||||
typedef struct Pool Pool;
|
||||
struct Pool {
|
||||
char* name;
|
||||
ulong maxsize; /* of entire Pool */
|
||||
ulong cursize; /* of Pool */
|
||||
ulong curfree; /* total free bytes in Pool */
|
||||
ulong curalloc; /* total allocated bytes in Pool */
|
||||
ulong minarena; /* smallest size of new arena */
|
||||
ulong quantum; /* allocated blocks should be multiple of */
|
||||
ulong minblock; /* smallest newly allocated block */
|
||||
int flags;
|
||||
int nfree; /* number of calls to free */
|
||||
int lastcompact; /* nfree at time of last poolcompact */
|
||||
void* (*alloc)(ulong);
|
||||
int (*merge)(void*, void*);
|
||||
void (*move)(void* from, void* to);
|
||||
void (*lock)(Pool*);
|
||||
void (*unlock)(Pool*);
|
||||
void (*print)(Pool*, char*, ...);
|
||||
void (*panic)(Pool*, char*, ...);
|
||||
void (*logstack)(Pool*);
|
||||
void* private;
|
||||
};
|
||||
.ta \w'\fL 'u +\w'POOL_ANTAGONISM 'u
|
||||
enum { /* flags */
|
||||
POOL_ANTAGONISM = 1<<0,
|
||||
POOL_PARANOIA = 1<<1,
|
||||
POOL_VERBOSITY = 1<<2,
|
||||
POOL_DEBUGGING = 1<<3,
|
||||
POOL_LOGGING = 1<<4,
|
||||
POOL_TOLERANCE = 1<<5,
|
||||
POOL_NOREUSE = 1<<6,
|
||||
};
|
||||
.EE
|
||||
.PP
|
||||
The pool obtains arenas of memory to manage by calling the the given
|
||||
.B alloc
|
||||
routine.
|
||||
The total number of requested bytes will not exceed
|
||||
.BR maxsize .
|
||||
Each allocation request will be for at least
|
||||
.B minarena
|
||||
bytes.
|
||||
.PP
|
||||
When a new arena is allocated, the pool routines try to
|
||||
merge it with the surrounding arenas, in an attempt to combat fragmentation.
|
||||
If
|
||||
.B merge
|
||||
is non-nil, it is called with the addresses of two blocks from
|
||||
.B alloc
|
||||
that the pool routines suspect might be adjacent.
|
||||
If they are not mergeable,
|
||||
.B merge
|
||||
must return zero.
|
||||
If they are mergeable,
|
||||
.B merge
|
||||
should merge them into one block in its own bookkeeping
|
||||
and return non-zero.
|
||||
.PP
|
||||
To ease fragmentation and make
|
||||
block reuse easier, the sizes requested of the pool routines are rounded up to a multiple of
|
||||
.B quantum
|
||||
before
|
||||
the carrying out requests.
|
||||
If, after rounding, the block size is still less than
|
||||
.B minblock
|
||||
bytes,
|
||||
.B minblock
|
||||
will be used as the block size.
|
||||
.PP
|
||||
.I Poolcompact
|
||||
defragments the pool, moving blocks in order to aggregate
|
||||
the free space.
|
||||
Each time it moves a block, it notifies the
|
||||
.B move
|
||||
routine that the contents have moved.
|
||||
At the time that
|
||||
.B move
|
||||
is called, the contents have already moved,
|
||||
so
|
||||
.B from
|
||||
should never be dereferenced.
|
||||
If no
|
||||
.B move
|
||||
routine is supplied (i.e. it is nil), then calling
|
||||
.I poolcompact
|
||||
is a no-op.
|
||||
.PP
|
||||
When the pool routines need to allocate a new arena but cannot,
|
||||
either because
|
||||
.B alloc
|
||||
has returned nil or because doing so would use more than
|
||||
.B maxsize
|
||||
bytes,
|
||||
.I poolcompact
|
||||
is called once to defragment the memory
|
||||
and the request is retried.
|
||||
.PP
|
||||
.I Pools
|
||||
are protected by the pool routines calling
|
||||
.B lock
|
||||
(when non-nil)
|
||||
before modifying the pool, and
|
||||
calling
|
||||
.B unlock
|
||||
when finished.
|
||||
.PP
|
||||
When internal corruption is detected,
|
||||
.B panic
|
||||
is called with a
|
||||
.IR print (3)
|
||||
style argument that specifies what happened.
|
||||
It is assumed that
|
||||
.B panic
|
||||
never returns.
|
||||
When the pool routines wish to convey a message
|
||||
to the caller (usually because logging is turned on; see below),
|
||||
.B print
|
||||
is called, also with a
|
||||
.IR print (3)
|
||||
style argument.
|
||||
.PP
|
||||
.B Flags
|
||||
is a bit vector that tweaks the behavior of the pool routines
|
||||
in various ways.
|
||||
Most are useful for debugging in one way or another.
|
||||
When
|
||||
.B POOL_ANTAGONISM
|
||||
is set,
|
||||
.I poolalloc
|
||||
fills blocks with non-zero garbage before releasing them to the user,
|
||||
and
|
||||
.I poolfree
|
||||
fills the blocks on receipt.
|
||||
This tickles both user programs and the innards of the allocator.
|
||||
Specifically, each 32-bit word of the memory is marked with a pointer value exclusive-or'ed
|
||||
with a constant.
|
||||
The pointer value is the pointer to the beginning of the allocated block
|
||||
and the constant varies in order to distinguish different markings.
|
||||
Freed blocks use the constant
|
||||
.BR 0xF7000000 ,
|
||||
newly allocated blocks
|
||||
.BR 0xF9000000 ,
|
||||
and newly created unallocated blocks
|
||||
.BR 0xF1000000 .
|
||||
For example, if
|
||||
.B POOL_ANTAGONISM
|
||||
is set and
|
||||
.I poolalloc
|
||||
returns a block starting at
|
||||
.BR 0x00012345 ,
|
||||
each word of the block will contain the value
|
||||
.BR 0xF90012345 .
|
||||
Recognizing these numbers in memory-related crashes can
|
||||
help diagnose things like double-frees or dangling pointers.
|
||||
.PP
|
||||
Setting
|
||||
.B POOL_PARANOIA
|
||||
causes the allocator to walk the entire pool whenever locking or unlocking itself,
|
||||
looking for corruption.
|
||||
This slows runtime by a few orders of magnitude
|
||||
when many blocks are in use.
|
||||
If
|
||||
.B POOL_VERBOSITY
|
||||
is set,
|
||||
the entire pool structure is printed
|
||||
(via
|
||||
.BR print )
|
||||
each time the pool is locked or unlocked.
|
||||
.B POOL_DEBUGGING
|
||||
enables internal
|
||||
debugging output,
|
||||
whose format is unspecified and volatile.
|
||||
It should not be used by most programs.
|
||||
When
|
||||
.B POOL_LOGGING
|
||||
is set, a single line is printed via
|
||||
.B print
|
||||
at the beginning and end of each pool call.
|
||||
If
|
||||
.B logstack
|
||||
is not nil,
|
||||
it will be called as well.
|
||||
This provides a mechanism for external programs to search for leaks.
|
||||
(See
|
||||
.IR leak (1)
|
||||
for one such program.)
|
||||
.PP
|
||||
The pool routines are strict about the amount of space callers use.
|
||||
If even a single byte is written past the end of the allotted space of a block, they
|
||||
will notice when that block is next used in a call to
|
||||
.I poolrealloc
|
||||
or
|
||||
.I free
|
||||
(or at the next entry into the allocator, when
|
||||
.B POOL_PARANOIA
|
||||
is set),
|
||||
and
|
||||
.B panic
|
||||
will be called.
|
||||
Since forgetting to allocate space for the
|
||||
terminating NUL on strings is such a common error,
|
||||
if
|
||||
.B POOL_TOLERANCE
|
||||
is set and a single NUL is found written past the end of a block,
|
||||
.B print
|
||||
will be called with a notification, but
|
||||
.B panic
|
||||
will not be.
|
||||
.PP
|
||||
When
|
||||
.B POOL_NOREUSE
|
||||
is set,
|
||||
.B poolfree
|
||||
fills the passed block with garbage rather than
|
||||
return it to the free pool.
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/port/pool.c
|
||||
.SH SEE ALSO
|
||||
.IR malloc (3),
|
||||
.IR brk (3)
|
||||
.PP
|
||||
.B /usr/local/plan9/src/libc/port/malloc.c
|
||||
is a complete example.
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
.TH READV 3
|
||||
.SH NAME
|
||||
readv, writev, preadv, pwritev \- scatter/gather read and write
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.nf
|
||||
.ft L
|
||||
typedef
|
||||
struct IOchunk
|
||||
{
|
||||
void *addr;
|
||||
ulong len;
|
||||
} IOchunk;
|
||||
.fi
|
||||
.PP
|
||||
.B
|
||||
long readv(int fd, IOchunk *io, int nio)
|
||||
.PP
|
||||
.B
|
||||
long preadv(int fd, IOchunk *io, int nio, vlong off)
|
||||
.PP
|
||||
.B
|
||||
long writev(int fd, IOchunk *io, int nio)
|
||||
.PP
|
||||
.B
|
||||
long pwritev(int fd, IOchunk *io, int nio, vlong off)
|
||||
.SH DESCRIPTION
|
||||
These functions supplement the standard read and write operations of
|
||||
.IR read (3)
|
||||
with facilities for scatter/gather I/O.
|
||||
The set of I/O buffers is collected into an array of
|
||||
.B IOchunk
|
||||
structures passed as an argument.
|
||||
.PP
|
||||
.I Readv
|
||||
reads data from
|
||||
.I fd
|
||||
and returns the total number of bytes received.
|
||||
The received data is stored in the successive
|
||||
.I nio
|
||||
elements of the
|
||||
.B IOchunk
|
||||
array, storing
|
||||
.IB io [0].len
|
||||
bytes at
|
||||
.IB io [0].addr\f1,
|
||||
the next
|
||||
.IB io [1].len
|
||||
at
|
||||
.IB io [1].addr\f1,
|
||||
and so on.
|
||||
.I Preadv
|
||||
does the same, but implicitly seeks to I/O offset
|
||||
.I off
|
||||
by analogy with
|
||||
.IR readv .
|
||||
.PP
|
||||
.I Writev
|
||||
and
|
||||
.I pwritev
|
||||
are the analogous write routines.
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/9sys/readv.c
|
||||
.br
|
||||
.B /usr/local/plan9/src/libc/9sys/writev.c
|
||||
.SH SEE ALSO
|
||||
.IR intro (3),
|
||||
.IR read (3)
|
||||
.SH DIAGNOSTICS
|
||||
These functions set
|
||||
.IR errstr .
|
||||
.SH BUGS
|
||||
The implementations use
|
||||
.IR malloc (3)
|
||||
to build a single buffer for a standard call to
|
||||
.B read
|
||||
or
|
||||
.BR write .
|
||||
They are placeholders for possible future system calls.
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
.TH REMOVE 3
|
||||
.SH NAME
|
||||
remove \- remove a file
|
||||
.SH SYNOPSIS
|
||||
.B #include <u.h>
|
||||
.br
|
||||
.B #include <libc.h>
|
||||
.PP
|
||||
.B
|
||||
int remove(char *file)
|
||||
.SH DESCRIPTION
|
||||
.I Remove
|
||||
removes
|
||||
.I file
|
||||
from the directory containing it and discards the contents of the file.
|
||||
The user must have write permission in the containing directory.
|
||||
If
|
||||
.I file
|
||||
is a directory, it must be empty.
|
||||
.SH SOURCE
|
||||
.B /usr/local/plan9/src/libc/9syscall
|
||||
.SH SEE ALSO
|
||||
.IR intro (3),
|
||||
.IR remove (5),
|
||||
the description of
|
||||
.B ORCLOSE
|
||||
in
|
||||
.IR open (3).
|
||||
.SH DIAGNOSTICS
|
||||
Sets
|
||||
.IR errstr .
|
||||
Loading…
Add table
Add a link
Reference in a new issue