Many small edits.

This commit is contained in:
rsc 2005-01-13 04:49:19 +00:00
parent 741f510ce7
commit c8b6342d3c
160 changed files with 2204 additions and 864 deletions

395
man/man3/0intro.3 Normal file
View file

@ -0,0 +1,395 @@
.TH INTRO 3
.SH NAME
intro \- introduction to library functions
.SH SYNOPSIS
.nf
.B #include <u.h>
.PP
.B #include \fIany Unix headers\fR
.PP
.B #include <libc.h>
.PP
.B #include <auth.h>
.PP
.B #include <bio.h>
.PP
.B #include <draw.h>
.PP
.B #include <fcall.h>
.PP
.B #include <frame.h>
.PP
.B #include <mach.h>
.PP
.B #include <regexp.h>
.PP
.B #include <thread.h>
.fi
.SH DESCRIPTION
This section describes functions
in various libraries.
For the most part, each library is defined by a single C include
file, such as those listed above, and a single archive file containing
the library proper. The name of the archive is
.BI \*9/lib/lib x .a \f1,
where
.I x
is the base of the include file name, stripped of a leading
.B lib
if present.
For example,
.B <draw.h>
defines the contents of library
.BR \*9/lib/libdraw.a ,
which may be abbreviated when named to the loader as
.BR -ldraw .
In practice, each include file contains a magic pragma
that directs the loader to pick up the associated archive
automatically, so it is rarely necessary to tell the loader
which
libraries a program needs;
see
.IR 9c (1).
.PP
The library to which a function belongs is defined by the
header file that defines its interface.
The `C library',
.IR libc ,
contains most of the basic subroutines such
as
.IR strlen .
Declarations for all of these functions are
in
.BR <libc.h> ,
which must be preceded by
.RI ( needs )
an include of
.BR <u.h> .
The graphics library,
.IR draw ,
is defined by
.BR <draw.h> ,
which needs
.B <libc.h>
and
.BR <u.h> .
The Buffered I/O library,
.IR libbio ,
is defined by
.BR <bio.h> ,
which needs
.B <libc.h>
and
.BR <u.h> .
The ANSI C Standard I/O library,
.IR libstdio ,
is defined by
.BR <stdio.h> ,
which needs
.BR <u.h> .
There are a few other, less commonly used libraries defined on
individual pages of this section.
.PP
The include file
.BR <u.h> ,
a prerequisite of several other include files,
declares the architecture-dependent and -independent types, including:
.IR uchar ,
.IR ushort ,
and
.IR ulong ,
the unsigned integer types;
.IR schar ,
the signed char type;
.I vlong
and
.IR uvlong ,
the signed and unsigned very long integral types;
.IR Rune ,
the Unicode character type;
.IR u8int ,
.IR u16int ,
.IR u32int ,
and
.IR u64int ,
the unsigned integral types with specific widths;
.IR jmp_buf ,
the type of the argument to
.I setjmp
and
.IR longjmp ,
plus macros that define the layout of
.IR jmp_buf
(see
.IR setjmp (3));
.\" definitions of the bits in the floating-point control register
.\" as used by
.\" .IR getfcr (2);
and
the macros
.B va_arg
and friends for accessing arguments of variadic functions (identical to the
macros defined in
.B <stdarg.h>
in ANSI C).
.PP
Plan 9 and Unix use many similarly-named functions for different purposes:
for example, Plan 9's
.I dup
is closer to (but not exactly) Unix's
.IR dup2 .
To avoid name conflicts,
.B <libc.h>
defines many of these names as preprocessor macros to add a
.I p9
prefix,
so that
.I dup
becomes
.IR p9dup .
To disable this renaming,
.B #define
.B NOPLAN9DEFINES
before including
.BR <libc.h> .
If Unix headers must be included in a program,
they should be included after
.BR <u.h> ,
which sets important preprocessor directives
(for example, to enable 64-bit file offsets),
but before
.BR <libc.h> ,
to avoid renaming problems.
.SS "Name space
Files are collected into a hierarchical organization called a
.I "file tree
starting in a
.I directory
called the
.IR root .
File names, also called
.IR paths ,
consist of a number of
.BR / -separated
.I "path elements"
with the slashes corresponding to directories.
A path element must contain only printable
characters (those outside the control spaces of
.SM ASCII
and Latin-1).
A path element cannot contain a slash.
.PP
When a process presents a file name to Plan 9, it is
.I evaluated
by the following algorithm.
Start with a directory that depends on the first
character of the path:
.L /
means the root of the main hierarchy,
and anything else means the process's current working directory.
Then for each path element, look up the element
in the directory, advance to that directory,
do a possible translation (see below), and repeat.
The last step may yield a directory or regular file.
.SS "File I/O"
Files are opened for input or output
by
.I open
or
.I create
(see
.IR open (3)).
These calls return an integer called a
.IR "file descriptor"
which identifies the file
to subsequent I/O calls,
notably
.IR read (3)
and
.IR write .
The system allocates the numbers by selecting the lowest unused descriptor.
They are allocated dynamically; there is no visible limit to the number of file
descriptors a process may have open.
They may be reassigned using
.IR dup (3).
File descriptors are indices into a
kernel resident
.IR "file descriptor table" .
Each process has an associated file descriptor table.
In threaded programs
(see
.IR thread (3)),
the file descriptor table is shared by all the procs.
.PP
By convention,
file descriptor 0 is the standard input,
1 is the standard output,
and 2 is the standard error output.
With one exception, the operating system is unaware of these conventions;
it is permissible to close file 0,
or even to replace it by a file open only for writing,
but many programs will be confused by such chicanery.
The exception is that the system prints messages about broken processes
to file descriptor 2.
.PP
Files are normally read or written in sequential order.
The I/O position in the file is called the
.IR "file offset"
and may be set arbitrarily using the
.IR seek (3)
system call.
.PP
Directories may be opened like regular files.
Instead of reading them with
.IR read (3),
use the
.B Dir
structure-based
routines described in
.IR dirread (3).
The entry
corresponding to an arbitrary file can be retrieved by
.IR dirstat
(see
.IR stat (3))
or
.IR dirfstat ;
.I dirwstat
and
.I dirfwstat
write back entries, thus changing the properties of a file.
.PP
New files are made with
.I create
(see
.IR open (3))
and deleted with
.IR remove (3).
Directories may not directly be written;
.IR create ,
.IR remove ,
.IR wstat ,
and
.I fwstat
alter them.
.PP
.IR Pipe (3)
creates a connected pair of file descriptors,
useful for bidirectional local communication.
.SS "Process execution and control"
A new process is created
when an existing one calls
.IR fork (2).
The new (child) process starts out with
copies of the address space and most other attributes
of the old (parent) process.
In particular,
the child starts out running
the same program as the parent;
.IR exec (3)
will bring in a different one.
.PP
Each process has a unique integer process id;
a set of open files, indexed by file descriptor;
and a current working directory
(changed by
.IR chdir (2)).
.PP
Each process has a set of attributes \(em memory, open files,
name space, etc. \(em that may be shared or unique.
Flags to
.IR rfork
control the sharing of these attributes.
.PP
A process terminates by calling
.IR exits (3).
A parent process may call
.IR wait (3)
to wait for some child to terminate.
A bit of status information
may be passed from
.I exits
to
.IR wait .
On Plan 9, the status information is an arbitrary text string,
but on Unix it is a single integer.
The Plan 9 interface persists here, although the functionality does not.
Instead, empty strings are converted to exit status 0 and non-empty strings to 1.
.PP
A process can go to sleep for a specified time by calling
.IR sleep (3).
.PP
There is a
.I notification
mechanism for telling a process about events such as address faults,
floating point faults, and messages from other processes.
A process uses
.IR notify (3)
to register the function to be called (the
.IR "notification handler" )
when such events occur.
.SS Multithreading
Where possible according to the ANSI C standard,
the main C library works properly in multiprocess programs;
.IR malloc ,
.IR print ,
and the other routines use locks (see
.IR lock (3))
to synchronize access to their data structures.
The graphics library defined in
.B <draw.h>
is also multi-process capable; details are in
.IR graphics (3).
In general, though, multiprocess programs should use some form of synchronization
to protect shared data.
.PP
The thread library, defined in
.BR <thread.h> ,
provides support for multiprocess programs.
It includes a data structure called a
.B Channel
that can be used to send messages between processes,
and coroutine-like
.IR threads ,
which enable multiple threads of control within a single process.
The threads within a process are scheduled by the library, but there is
no pre-emptive scheduling within a process; thread switching occurs
only at communication or synchronization points.
.PP
Most programs using the thread library
comprise multiple processes
communicating over channels, and within some processes,
multiple threads. Since I/O calls may block, a system
call may block all the threads in a process.
Therefore, a program that shouldn't block unexpectedly will use a process
to serve the I/O request, passing the result to the main processes
over a channel when the request completes.
For examples of this design, see
.IR ioproc (3)
or
.IR mouse (3).
.SH SEE ALSO
.IR nm (1),
.IR 9c (1)
.SH DIAGNOSTICS
Math functions in
.I libc
return
special values when the function is undefined for the
given arguments or when the value is not representable
(see
.IR nan (3)).
.PP
Some of the functions in
.I libc
are system calls and many others employ system calls in their implementation.
All system calls return integers,
with \-1 indicating that an error occurred;
.IR errstr (3)
recovers a string describing the error.
Some user-level library functions also use the
.I errstr
mechanism to report errors.
Functions that may affect the value of the error string are said to ``set
.IR errstr '';
it is understood that the error string is altered only if an error occurs.

View file

@ -109,13 +109,13 @@ and
.B Fid
structures are allocated one-to-one with uncompleted
requests and active fids, and are described in
.IR 9pfid (3).
.IR 9p-fid (3).
.PP
The behavior of
.I srv
depends on whether there is a file tree
(see
.IR 9pfile (3))
.IR 9p-file (3))
associated with the server, that is,
whether the
.B tree
@ -717,8 +717,8 @@ accept the
option to increment
.BR chatty9p .
.SH EXAMPLES
\*9/src/lib9p/ramfs.c
is an example of simple single-threaded file servers.
.B \*9/src/lib9p/ramfs.c
is an example of a simple single-threaded file server.
On Plan 9, see
.IR archfs ,
.IR cdfs ,
@ -744,6 +744,6 @@ or is maintained elsewhere.
.SH SOURCE
.B \*9/src/lib9p
.SH SEE ALSO
.IR 9pfid (3),
.IR 9pfile (3),
.IR 9p-fid (3),
.IR 9p-file (3),
.IR intro (9p)

View file

@ -9,8 +9,8 @@ CFid, CFsys, fsinit, fsmount, fsroot, fssetroot, fsunmount, nsmount, fsversion,
.B #include <fcall.h>
.PP
.B #include <9pclient.h>
.ta +\w'\fLCFsys* 'u
.PP
.ta +'\fLCFsys* 'u
.B
CFsys* fsmount(int fd, char *aname)
.PP
@ -214,7 +214,7 @@ The path is parsed as a slash-separated sequence of path elements,
as on Unix and Plan 9.
Elements that are empty or
dot
.B ( . )
.RB ( . )
are ignored.
.PP
Once opened, these fids can be read and written using

View file

@ -1,3 +1,48 @@
0intro 0intro.3
intro 0intro.3
9p-cmdbuf 9p-cmdbuf.3
Cmdbuf 9p-cmdbuf.3
lookupcmd 9p-cmdbuf.3
parsecmd 9p-cmdbuf.3
respondcmderror 9p-cmdbuf.3
9p-fid 9p-fid.3
Fid 9p-fid.3
Fidpool 9p-fid.3
Req 9p-fid.3
Reqpool 9p-fid.3
allocfid 9p-fid.3
allocfidpool 9p-fid.3
allocreq 9p-fid.3
allocreqpool 9p-fid.3
closefid 9p-fid.3
closereq 9p-fid.3
freefidpool 9p-fid.3
freereqpool 9p-fid.3
lookupfid 9p-fid.3
lookupreq 9p-fid.3
removefid 9p-fid.3
removereq 9p-fid.3
9p-file 9p-file.3
File 9p-file.3
Tree 9p-file.3
alloctree 9p-file.3
closedirfile 9p-file.3
closefile 9p-file.3
createfile 9p-file.3
freetree 9p-file.3
hasperm 9p-file.3
opendirfile 9p-file.3
readdirfile 9p-file.3
removefile 9p-file.3
walkfile 9p-file.3
9p-intmap 9p-intmap.3
Intmap 9p-intmap.3
allocmap 9p-intmap.3
caninsertkey 9p-intmap.3
deletekey 9p-intmap.3
freemap 9p-intmap.3
insertkey 9p-intmap.3
lookupkey 9p-intmap.3
9p 9p.3
Srv 9p.3
dirread9p 9p.3
@ -39,41 +84,6 @@ fsunmount 9pclient.3
fsversion 9pclient.3
fswrite 9pclient.3
nsmount 9pclient.3
9pcmdbuf 9pcmdbuf.3
Cmdbuf 9pcmdbuf.3
lookupcmd 9pcmdbuf.3
parsecmd 9pcmdbuf.3
respondcmderror 9pcmdbuf.3
9pfid 9pfid.3
Fid 9pfid.3
Fidpool 9pfid.3
Req 9pfid.3
Reqpool 9pfid.3
allocfid 9pfid.3
allocfidpool 9pfid.3
allocreq 9pfid.3
allocreqpool 9pfid.3
closefid 9pfid.3
closereq 9pfid.3
freefidpool 9pfid.3
freereqpool 9pfid.3
lookupfid 9pfid.3
lookupreq 9pfid.3
removefid 9pfid.3
removereq 9pfid.3
9pfile 9pfile.3
File 9pfile.3
Tree 9pfile.3
alloctree 9pfile.3
closedirfile 9pfile.3
closefile 9pfile.3
createfile 9pfile.3
freetree 9pfile.3
hasperm 9pfile.3
opendirfile 9pfile.3
readdirfile 9pfile.3
removefile 9pfile.3
walkfile 9pfile.3
Dx addpt.3
Dy addpt.3
Pt addpt.3
@ -233,15 +243,11 @@ accept dial.3
announce dial.3
dial dial.3
dialparse dial.3
hangup dial.3
listen dial.3
netmkaddr dial.3
reject dial.3
dirread dirread.3
dirreadall dirread.3
Disk disk.3
disk disk.3
opendisk disk.3
ARROW draw.3
Image draw.3
_string draw.3
@ -473,14 +479,6 @@ targetid html.3
targetname html.3
toStr html.3
validitems html.3
Intmap intmap.3
allocmap intmap.3
caninsertkey intmap.3
deletekey intmap.3
freemap intmap.3
insertkey intmap.3
intmap intmap.3
lookupkey intmap.3
closeioproc ioproc.3
iocall ioproc.3
ioclose ioproc.3
@ -927,9 +925,6 @@ pwrite read.3
read read.3
readn read.3
write read.3
RGB readcolmap.3
readcolmap readcolmap.3
writecolmap readcolmap.3
regcomp regexp.3
regcomplit regexp.3
regcompnl regexp.3
@ -939,15 +934,6 @@ regexp regexp.3
regsub regexp.3
rregexec regexp.3
rregsub regexp.3
regcomp regexp9.3
regcomplit regexp9.3
regcompnl regexp9.3
regerror regexp9.3
regexec regexp9.3
regexp9 regexp9.3
regsub regexp9.3
rregexec regexp9.3
rregsub regexp9.3
rfork rfork.3
X509dump rsa.3
@ -993,11 +979,6 @@ runestrncmp runestrcat.3
runestrncpy runestrcat.3
runestrrchr runestrcat.3
runestrstr runestrcat.3
openscsi scsi.3
scsi scsi.3
scsicmd scsi.3
scsierror scsi.3
scsiready scsi.3
hmac_md5 sechash.3
hmac_sha1 sechash.3
md4 sechash.3
@ -1125,7 +1106,6 @@ threadint thread.3
threadintgrp thread.3
threadkill thread.3
threadkillgrp thread.3
threadlinklibrary thread.3
threadmain thread.3
threadnotify thread.3
threadpid thread.3

View file

@ -144,3 +144,35 @@ and
.I atol
accept octal and hexadecimal numbers in the style of C,
contrary to the ANSI specification.
.PP
.IR Atof ,
.IR strtod ,
.IR strtol ,
.IR strtoul ,
.IR strtoll ,
and
.IR strtoull
are not provided:
they are expected to be provided by the underlying system.
.PP
Because they are implemented in the fmt library,
.I charstod
and
.I strtod
are preprocessor macros defined as
.I fmtcharstod
and
.IR fmtstrtod .
.PP
To avoid name conflicts with the underlying system,
.IR atoi ,
.IR atol ,
and
.I atoll
are preprocessor macros defined as
.IR p9atoi ,
.IR p9atol ,
and
.IR p9atoll ;
see
.IR intro (3).

View file

@ -20,7 +20,7 @@ void *binalloc(Bin **bp, ulong size, int clr);
void *bingrow(Bin **bp, void *op, ulong osize,
.br
.B
ulong size, int clr);
ulong size, int clr);
.PP
.B
void binfree(Bin **bp);

View file

@ -2,7 +2,7 @@
.SH NAME
Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered \- buffered input/output
.SH SYNOPSIS
.ta \w'Biobuf* 'u
.ta \w'\fLBiobuf* 'u
.B #include <u.h>
.br
.B #include <libc.h>

View file

@ -13,12 +13,12 @@ complete, freecompletion \- file name completion
.ta \w' 'u +\w' 'u +\w' 'u +\w' 'u +\w' 'u
typedef struct Completion Completion;
struct Completion{
uchar advance; /* whether forward progress has been made */
uchar complete; /* whether the completion now represents a file or directory */
char *string; /* the string to advance, suffixed " " or "/" for file or directory */
int nmatch; /* number of files that matched */
int nfile; /* number of files returned */
char **filename; /* their names */
uchar advance;
uchar complete;
char *string;
int nmatch;
int nfile;
char **filename;
};
.fi

View file

@ -90,9 +90,26 @@ is not
.SH BUGS
The return values point to static data
whose content is overwritten by each call.
.br
.PP
Daylight Savings Time is ``normal'' in the Southern hemisphere.
.br
.PP
These routines are not equipped to handle non-\c
.SM ASCII
text, and are provincial anyway.
.PP
To avoid name conflicts with the underlying system,
.IR ctime ,
.IR localtime ,
.IR gmtime ,
.IR asctime ,
and
.I tm2sec
are preprocessor macros defined as
.IR p9ctime ,
.IR p9localtime ,
.IR p9gmtime ,
.IR p9asctime ,
and
.IR p9tm2sec ;
see
.IR intro (3).

View file

@ -1,6 +1,6 @@
.TH DIAL 3
.SH NAME
dial, hangup, announce, listen, accept, reject, netmkaddr, dialparse \- make and break network connections
dial, announce, listen, accept, reject, netmkaddr, dialparse \- make and break network connections
.SH SYNOPSIS
.B #include <u.h>
.br
@ -34,7 +34,10 @@ char* netmkaddr(char *addr, char *defnet, char *defservice)
.\" void freenetconninfo(NetConnINfo*)
.PP
.B
int dialparse(char *addr, char **net, char **unix, u32int *host, int *port)
int dialparse(char *addr, char **net, char **unix,
.br
.B
u32int *host, int *port)
.SH DESCRIPTION
For these routines,
.I addr
@ -310,3 +313,17 @@ bekremvax(void)
and
.I listen
return \-1 if they fail.
.SH BUGS
To avoid name conflicts with the underlying system,
.IR dial ,
.IR announce ,
.IR listen ,
.IR netmkaddr ,
and
.I reject
are preprocessor macros defined as
.IR p9dial ,
.IR p9announce ,
and so on;
see
.IR intro (3).

View file

@ -31,8 +31,9 @@ for the new file descriptor
Sets
.IR errstr .
.SH BUGS
.I Dup
is a macro for
.I p9dup
to avoid name conflicts with the Unix function; see
To avoid name conflicts with the underlying system,
.I dup
is a preprocessor macro defined as
.IR p9dup ;
see
.IR intro (3).

View file

@ -382,3 +382,8 @@ is nil, it restores the image to the default arrow.
.IR plumb (3),
.\" .IR cons (3),
.IR draw (3)
.SH BUGS
.I Etimer
and
.I estart
are unimplemented.

View file

@ -128,3 +128,14 @@ use the user's current path to locate
This is a clumsy way to deal with Unix's lack of
a union directory for
.BR /bin .
.PP
To avoid name conflicts with the underlying system,
.I exec
and
.I execl
are preprocessor macros defined as
.I p9exec
and
.IR p9execl ;
see
.IR intro (3).

View file

@ -93,3 +93,14 @@ non-empty messages.
Exit codes 97 through 99 are used by the thread library to signal
internal synchronization errors between the main program
and a proxy process that implements backgrounding.
.PP
To avoid name conflicts with the underlying system,
.I atexit
and
.I atexitdont
are preprocessor macros defined as
.I p9atexit
and
.IR p9atexitdont ;
see
.IR intro (3).

View file

@ -8,7 +8,7 @@ deflateinit, deflate, deflatezlib, deflateblock, deflatezlibblock, inflateinit,
.br
.B #include <flate.h>
.PP
.ta \w'ulongmm'u
.ta \w'\fLulongmm'u +\w'\fL 'u
.PP
.B
int deflateinit(void)
@ -17,37 +17,37 @@ int deflateinit(void)
int deflate(void *wr, int (*w)(void*,void*,int),
.br
.B
void *rr, int (*r)(void*,void*,int),
void *rr, int (*r)(void*,void*,int),
.br
.B
int level, int debug)
int level, int debug)
.PP
.B
int deflatezlib(void *wr, int (*w)(void*,void*,int),
.br
.B
void *rr, int (*r)(void*,void*,int),
void *rr, int (*r)(void*,void*,int),
.br
.B
int level, int debug)
int level, int debug)
.PP
.B
int deflateblock(uchar *dst, int dsize,
.br
.B
uchar *src, int ssize,
uchar *src, int ssize,
.br
.B
int level, int debug)
int level, int debug)
.PP
.B
int deflatezlibblock(uchar *dst, int dsize,
.br
.B
uchar *src, int ssize,
uchar *src, int ssize,
.br
.B
int level, int debug)
int level, int debug)
.PP
.B
int inflateinit(void)
@ -56,25 +56,25 @@ int inflateinit(void)
int inflate(void *wr, int (*w)(void*, void*, int),
.br
.B
void *getr, int (*get)(void*))
void *getr, int (*get)(void*))
.PP
.B
int inflatezlib(void *wr, int (*w)(void*, void*, int),
.br
.B
void *getr, int (*get)(void*))
void *getr, int (*get)(void*))
.PP
.B
int inflateblock(uchar *dst, int dsize,
.br
.B
uchar *src, int ssize)
uchar *src, int ssize)
.PP
.B
int inflatezlibblock(uchar *dst, int dsize,
.br
.B
uchar *src, int ssize)
uchar *src, int ssize)
.PP
.B
char *flateerr(int error)

View file

@ -370,4 +370,3 @@ main(...)
.SH DIAGNOSTICS
These routines return negative numbers or nil for errors and set
.IR errstr .
.SH BUGS

View file

@ -75,7 +75,7 @@ This library supports
of editable text in a single font on raster displays, such as in
.IR sam (1)
and
.IR rio (1).
.IR 9term (1).
Frames may hold any character except NUL (0).
Long lines are folded and tabs are at fixed intervals.
.PP

View file

@ -22,8 +22,10 @@ very least, unguessable numbers.
.I Genrandom
fills a buffer with bytes from the X9.17 pseudo-random
number generator. The X9.17 generator is seeded by 24
truly random bytes read from
.BR /dev/random .
truly random bytes read via
.I truerand
(see
.IR rand (3)).
.PP
.I Prng
uses the native

View file

@ -35,8 +35,13 @@ to
Sets
.IR errstr .
.SH BUGS
Defined as macros for
To avoid name conflicts with the underlying system,
.I getenv
and
.I putenv
are preprocessor macros defined as
.I p9getenv
and
.I p9putenv
to avoid name conflicts with Unix library calls.
.IR p9putenv ;
see
.IR intro (3).

View file

@ -23,8 +23,15 @@ bytes in the buffer provided.
.SH SOURCE
.B \*9/src/lib9/getwd.c
.SH "SEE ALSO"
.IR pwd (1),
.IR pwd (1)
.SH DIAGNOSTICS
On error, zero is returned.
.IR Errstr (3)
may be consulted for more information.
.SH BUGS
To avoid name conflicts with the underlying system,
.I getwd
is a preprocessor macro defined as
.IR p9getwd ;
see
.IR intro (3).

View file

@ -615,7 +615,7 @@ if(gengetwindow(display, "/tmp/winname",
\&...
.EE
.SH FILES
.BR /lib/font/bit " directory of fonts
.BR \*9/font/bit " directory of fonts
.SH SOURCE
.B \*9/src/libdraw
.SH "SEE ALSO"
@ -649,3 +649,7 @@ and might be more appropriately called
.B white
and
.BR black .
.PP
These manual pages contain many references to
the now-fictitious
.BR /dev/draw .

View file

@ -168,3 +168,18 @@ When
and
.I free
detect such corruption, they abort.
.PP
To avoid name conflicts with the system versions of these functions,
.IR malloc ,
.IR realloc ,
.IR calloc ,
and
.I free
are preprocessor macros defined as
.IR p9malloc ,
.IR p9realloc ,
.IR p9calloc ,
and
.IR p9free ;
see
.IR intro (3).

View file

@ -449,7 +449,6 @@ prints to a serial line rather than the screen, for obvious reasons.
is unusual in using a subfont rather than a font,
and in having no parameter to align the source.
.PP
.I Libmemdraw
is archived into
These functions are
archived into
.IR libdraw .

View file

@ -304,6 +304,6 @@ are in compressed image format
.IR window (3),
.IR draw (3)
.SH BUGS
.I Libmemlayer
is archived into
These functions
are archived into
.IR libdraw .

View file

@ -1,6 +1,6 @@
.TH MP 3
.SH NAME
mpsetminbits, mpnew, mpfree, mpbits, mpnorm, mpcopy, mpassign, mprand, strtomp, mpfmt,mptoa, betomp, mptobe, letomp, mptole, mptoui, uitomp, mptoi, itomp, uvtomp, mptouv, vtomp, mptov, mpdigdiv, mpadd, mpsub, mpleft, mpright, mpmul, mpexp, mpmod, mpdiv, mpcmp, mpextendedgcd, mpinvert, mpsignif, mplowbits0, mpvecdigmuladd, mpvecdigmulsub, mpvecadd, mpvecsub, mpveccmp, mpvecmul, mpmagcmp, mpmagadd, mpmagsub, crtpre, crtin, crtout, crtprefree, crtresfree, mpfactorial \- extended precision arithmetic
mpsetminbits, mpnew, mpfree, mpbits, mpnorm, mpcopy, mpassign, mprand, strtomp, mpfmt,mptoa, betomp, mptobe, letomp, mptole, mptoui, uitomp, mptoi, itomp, uvtomp, mptouv, vtomp, mptov, mpdigdiv, mpadd, mpsub, mpleft, mpright, mpmul, mpexp, mpmod, mpdiv, mpfactorial, mpcmp, mpextendedgcd, mpinvert, mpsignif, mplowbits0, mpvecdigmuladd, mpvecdigmulsub, mpvecadd, mpvecsub, mpveccmp, mpvecmul, mpmagcmp, mpmagadd, mpmagsub, crtpre, crtin, crtout, crtprefree, crtresfree \- extended precision arithmetic
.SH SYNOPSIS
.B #include <u.h>
.br
@ -108,6 +108,9 @@ void mpmod(mpint *b, mpint *m, mpint *remainder)
void mpdiv(mpint *dividend, mpint *divisor, mpint *quotient, mpint *remainder)
.PP
.B
mpint* mpfactorial(ulong n)
.PP
.B
int mpcmp(mpint *b1, mpint *b2)
.PP
.B
@ -162,9 +165,6 @@ void crtprefree(CRTpre *cre)
void crtresfree(CRTres *res)
.PP
.B
mpint* mpfactorial(ulong n)
.PP
.B
mpint *mpzero, *mpone, *mptwo
.SH DESCRIPTION
.PP
@ -441,6 +441,10 @@ Otherwise,
.BR "quotient = dividend/divisor" .
.BR "remainder = dividend % divisor" .
.TP
.I mpfactorial
returns factorial of
.IR n .
.TP
.I mpcmp
returns -1, 0, or +1 as
.I b1
@ -575,9 +579,5 @@ free
and
.I CRTres
structures respectively.
.PP
.I Mpfactorial
returns the factorial of
.IR n .
.SH SOURCE
.B \*9/src/libmp

View file

@ -7,7 +7,7 @@ muldiv, umuldiv \- high-precision multiplication and division
.B #include <libc.h>
.PP
.B
long muldiv(long a, long b, long c)
long muldiv(long a, long b, long c)
.PP
.B
ulong umuldiv(ulong a, ulong b, ulong c)

View file

@ -7,6 +7,7 @@ Mux, muxinit, muxrpc, muxthreads \- protocol multiplexor
.nf
.B
.ta +4n
.ft B
struct Mux
{
uint mintag;

View file

@ -207,7 +207,7 @@ is a common set that includes:
.PP
.RS 3n
.nf
.ta \w'\fLsys: write on closed pipe \fP'u \w'system call address argument out of range 'u
.ta \w'\fLsys: segmentation violation \fP'u +\w'process requested to exit 'u
\fINote\fP \fIMeaning\fP \fIUnix signal\fP
\fLinterrupt\fP user interrupt (DEL key) SIGINTR
\fLhangup\fP I/O connection closed SIGHUP
@ -217,6 +217,8 @@ is a common set that includes:
\fLsys: kill\fP process forced to exit SIGKILL
\fLsys: bus error\fP bus error SIGBUS
\fLsys: segmentation violation\fP segmentation violation SIGSEGV
\fLsys: write on closed pipe\fP write on closed pipe SIGPIPE
\fLsys: child\fP child wait status change SIGCHLD
.fi
.RE
.PP

View file

@ -1,18 +1,10 @@
.TH PRINT 3
.de EX
.nf
.ft B
..
.de EE
.fi
.ft R
..
.SH NAME
print, fprint, sprint, snprint, seprint, smprint, runesprint, runesnprint, runeseprint, runesmprint, vfprint, vsnprint, vseprint, vsmprint, runevsnprint, runevseprint, runevsmprint \- print formatted output
.SH SYNOPSIS
.B #include <utf.h>
.B #include <u.h>
.PP
.B #include <fmt.h>
.B #include <libc.h>
.PP
.ta \w'\fLchar* 'u
.B
@ -72,7 +64,10 @@ Rune* runevsmprint(Rune *format, va_list v)
writes text to the standard output.
.I Fprint
writes to the named output
file descriptor.
file descriptor:
a buffered form
is described in
.IR bio (3).
.I Sprint
places text
followed by the NUL character
@ -96,7 +91,7 @@ but will not place more than
bytes in
.IR s .
Its result is always NUL-terminated and holds the maximal
number of characters that can fit.
number of complete UTF-8 characters that can fit.
.I Seprint
is like
.IR snprint ,
@ -191,27 +186,26 @@ described below.
.PP
The numeric verbs
.BR d ,
.BR i ,
.BR u ,
.BR o ,
.BR b ,
.BR x ,
and
.B X
format their arguments in decimal, decimal,
unsigned decimal, octal, binary, hexadecimal, and upper case hexadecimal.
format their arguments in decimal,
octal, binary, hexadecimal, and upper case hexadecimal.
Each interprets the flags
.BR 0 ,
.BR h ,
.BR hh ,
.BR l ,
.BR u ,
.BR + ,
.BR - ,
.BR , ,
and
.B #
to mean pad with zeros,
short, byte, long, always print a sign, left justified, commas every three digits,
short, byte, long, unsigned, always print a sign, left justified, commas every three digits,
and alternate format.
Also, a space character in the flag
position is like
@ -221,12 +215,9 @@ If neither
short nor long is specified,
then the argument is an
.BR int .
If an unsigned verb is specified,
If unsigned is specified,
then the argument is interpreted as a
positive number and no sign is output;
space and
.B +
flags are ignored for unsigned verbs.
positive number and no sign is output.
If two
.B l
flags are given,
@ -249,8 +240,8 @@ for
.B o
conversion, the number is preceded by a
.B 0
if it doesn't already begin with one.
For non-zero numbers and
if it doesn't already begin with one;
for
.B x
conversion, the number is preceded by
.BR 0x ;
@ -345,7 +336,7 @@ conversions, trailing zeros are not removed.
.PP
The
.B s
verb copies a string
verb copies a NUL-terminated string
(pointer to
.BR char )
to the output.
@ -397,9 +388,7 @@ but that will change if pointers and integers are different sizes.
The
.B r
verb takes no arguments; it copies the error string returned by a call to
.IR strerror (3)
with an argument of
.IR errno.
.IR errstr (3).
.PP
Custom verbs may be installed using
.IR fmtinstall (3).
@ -414,12 +403,12 @@ void fatal(char *msg, ...)
char buf[1024], *out;
va_list arg;
out = vseprint(buf, buf+sizeof buf, "Fatal error: ");
out = seprint(buf, buf+sizeof buf, "Fatal error: ");
va_start(arg, msg);
out = vseprint(out, buf+sizeof buf, msg, arg);
va_end(arg);
write(2, buf, out-buf);
exit(1);
exits("fatal error");
}
.EE
.SH SEE ALSO
@ -438,9 +427,9 @@ the main difference is that
.B b
and
.B r
are not in ANSI and some
.B C9X
verbs are missing.
are not in ANSI and
.B u
is a flag here instead of a verb.
Also, and distinctly not a bug,
.I print
and friends generate
@ -449,8 +438,8 @@ rather than
.SM ASCII.
.PP
There is no
.BR runeprint ,
.BR runefprint ,
.IR runeprint ,
.IR runefprint ,
etc. because runes are byte-order dependent and should not be written directly to a file; use the
UTF output of
.I print

View file

@ -26,7 +26,7 @@ int tlsServer(int fd, TLSconn *conn)
uchar *readcert(char *filename, int *pcertlen)
.PP
.B
PEMchain *readcertchain(char *filename)
PEMchain *readcertchain(char *filename)
.PP
.B
Thumbprint* initThumbprints(char *ok, char *crl)

View file

@ -165,3 +165,10 @@ format strings.
.IR malloc (3),
.IR print (3),
.IR strcat (3)
.SH BUGS
Because it is provided by the format library,
.I doquote
is a preprocessor macro defined as
.IR fmtdoquote ;
see
.IR intro (3).

View file

@ -156,9 +156,9 @@ to return a uniform
.IR x ,
.RI 0 x < val 2\u\s732\s10\d-1.
.SH SOURCE
.B \*9/src/lib9/
.B \*9/src/lib9
.br
.B \*9/src/libsec/port/
.B \*9/src/libsec/port
.SH "SEE ALSO
.\" .IR cons (3),
.IR mp (3)
@ -167,3 +167,18 @@ to return a uniform
and
.I ntruerand
maintain a static file descriptor.
.PP
To avoid name conflicts with the underlying system,
.IR rand ,
.IR lrand ,
.IR frand ,
.IR nrand ,
.IR lnrand ,
and
.I srand
are preprocessor macros defined as
.IR p9rand ,
.IR p9lrand ,
and so on;
see
.IR intro (3).

View file

@ -113,22 +113,22 @@ typedef struct {
union {
char *sp;
Rune *rsp;
};
} s;
union {
char *ep;
Rune *rep;
};
} e;
} Resub;
.EE
.LP
If
.B match[0].sp
.B match[0].s.sp
is nonzero on entry,
.I regexec
starts matching at that point within
.IR string .
If
.B match[0].ep
.B match[0].e.ep
is nonzero on entry,
the last character matched is the one
preceding that point.

View file

@ -13,50 +13,51 @@ md4, md5, sha1, hmac_md5, hmac_sha1, md5pickle, md5unpickle, sha1pickle, sha1unp
.B
DigestState* md4(uchar *data, ulong dlen, uchar *digest,
.B
DigestState *state)
DigestState *state)
.PP
.B
DigestState* md5(uchar *data, ulong dlen, uchar *digest,
.B
DigestState *state)
DigestState *state)
.PP
.B
char* md5pickle(MD5state *state)
.PP
.B
MD5state* md5unpickle(char *p);
MD5state* md5unpickle(char *p);
.PP
.B
DigestState* sha1(uchar *data, ulong dlen, uchar *digest,
.B
DigestState *state)
DigestState *state)
.PP
.B
char* sha1pickle(MD5state *state)
.PP
.B
MD5state* sha1unpickle(char *p);
MD5state* sha1unpickle(char *p);
.PP
.B
DigestState* hmac_md5(uchar *data, ulong dlen,
.br
.B
uchar *key, ulong klen,
uchar *key, ulong klen,
.br
.B
uchar *digest, DigestState *state)
uchar *digest, DigestState *state)
.PP
.B
DigestState* hmac_sha1(uchar *data, ulong dlen,
.br
.B
uchar *key, ulong klen,
uchar *key, ulong klen,
.br
.B
uchar *digest, DigestState *state)
uchar *digest, DigestState *state)
.SH DESCRIPTION
.PP
We support several secure hash functions. The output of the
These functions implement
the cryptographic hash functions MD4, MD5, and SHA1. The output of the
hash is called a
.IR digest .
A hash is secure if, given the hashed data and the digest,

View file

@ -44,3 +44,10 @@ Seeking in a pipe is a no-op.
.SH DIAGNOSTICS
Sets
.IR errstr .
.SH BUGS
To avoid name conflicts with the underlying system,
.I seek
is a preprocessor macro defined as
.IR p9seek ;
see
.IR intro (3).

View file

@ -55,36 +55,6 @@ argument should be the first argument passed to the note handler.
and
.I longjmp
can also be used to switch stacks.
Defined in
.B </$objtype/u.h>
are several macros that can be used to build
.B jmp_bufs
by hand. The following code establishes a
.B jmp_buf
.i label
that may be called by
.I longjmp
to begin execution in a function
.BR f
with 1024 bytes of stack:
.IP
.EX
#include <u.h>
#include <libc.h>
jmp_buf label;
#define NSTACK 1024
char stack[NSTACK];
void
setlabel(void)
{
label[JMPBUFPC] = ((ulong)f+JMPBUFDPC);
/* -2 leaves room for old pc and new pc in frame */
label[JMPBUFSP =
(ulong)(&stack[NSTACK-2*sizeof(ulong*)]);
}
.EE
.SH SOURCE
.B \*9/src/lib9/jmp.c
.SH SEE ALSO
@ -94,3 +64,24 @@ setlabel(void)
.I Notejmp
cannot recover from an address trap or bus error (page fault) on the 680x0
architectures.
.PP
To avoid name conflicts with the underlying system,
.IR setjmp ,
.IR longjmp ,
.IR notejmp ,
and
.I jmp_buf
are preprocessor macros defined as
.IR p9setjmp ,
.IR p9longjmp ,
.IR p9notejmp ,
and
.IR p9jmp_buf ;
see
.IR intro (3).
.PP
.I P9setjmp
is implemented as a preprocessor macro that calls
.I sigsetjmp
(see
Unix's \fIsetjmp\fR(3)).

View file

@ -43,3 +43,14 @@ the alarm clock.
.SH DIAGNOSTICS
These functions set
.IR errstr .
.SH BUGS
To avoid name conflicts with the underlying system,
.I sleep
and
.I alarm
are preprocessor macros defined as
.I p9sleep
and
.IR p9alarm ;
see
.IR intro (3).

View file

@ -117,7 +117,7 @@ is used when code needs a reference to the character array.
Using
.B s->base
directly is frowned upon since it exposes too much of the implementation.
.SS "allocation and freeing
.SS "Allocation and freeing
.PP
A string must be allocated before it can be used.
One normally does this using

View file

@ -104,7 +104,7 @@ it should be zeroed before calling
A number of subfonts are kept in external files.
The convention for naming subfont files is:
.IP
.B /lib/font/bit/\fIname\fP/\fIclass\fP.\fIsize\fP.\fIdepth
.B \*9/font/\fIname\fP/\fIclass\fP.\fIsize\fP.\fIdepth
.PD
.PP
where
@ -217,9 +217,9 @@ into the
to
.IB min + s ->n-1\f1.
.SH FILES
.TF /lib/font/bit
.TF \*9/font
.TP
.B /lib/font/bit
.B \*9/font
bitmap font file tree
.SH SOURCE
.B \*9/src/libdraw

View file

@ -33,7 +33,6 @@ threadint,
threadintgrp,
threadkill,
threadkillgrp,
threadlinklibrary,
threadmain,
threadnotify,
threadid,
@ -46,14 +45,6 @@ threadwaitchan,
yield \- thread and proc management
.SH SYNOPSIS
.PP
.de EX
.nf
.ft B
..
.de EE
.fi
.ft R
..
.EX
.ta 4n +4n +4n +4n +4n +4n +4n
#include <u.h>
@ -88,8 +79,6 @@ struct Alt {
void threadmain(int argc, char *argv[])
int mainstacksize
int proccreate(void (*fn)(void*), void *arg, uint stacksize)
int procrfork(void (*fn)(void*), void *arg, uint stacksize,
int rforkflag)
int threadcreate(void (*fn)(void*), void *arg, uint stacksize)
void threadexits(char *status)
void threadexitsall(char *status)
@ -393,6 +382,7 @@ fd[0] = 0;
fd[1] = 1;
fd[2] = 2;
.EE
.LP
to use the current standard files. The correct code is
.IP
.EX
@ -656,20 +646,6 @@ contains some example programs.
.IR intro (3),
.IR ioproc (3)
.SH BUGS
A program that intends to use the thread library
but does not call any of its functions will not cause Unix linkers
to link the thread library, resulting in the unintelligible error:
.IP
.EX
\*9/lib/lib9.a(main.o)(.text+0x17): In function `main':
\*9/src/lib9/main.c:10: undefined reference to `p9main'
.EE
.LP
or similar. To force the thread library to be linked properly in such cases,
insert a call to the no-op function
.I threadlinklibrary
somewhere in your program.
.PP
To avoid name conflicts,
.IR alt ,
.IR nbrecv ,
@ -689,10 +665,11 @@ are defined as macros that expand to
.IR chanalt ,
.IR channbrecv ,
and so on.
Similarly,
.I yield
.I Yield
is defined as a macro that expands to
.IR threadyield .
See
.IR intro (3).
.PP
The implementation of
.I threadnotify

View file

@ -31,3 +31,14 @@ is also set to the answer.
.SH DIAGNOSTICS
These functions set
.IR errstr .
.SH BUGS
To avoid name conflicts with the underlying system,
.I time
and
.I nsec
are preprocessor macros defined as
.I p9time
and
.IR p9nsec ;
see
.IR intro (3).

View file

@ -144,3 +144,16 @@ returns
.SH DIAGNOSTICS
These routines set
.IR errstr .
.SH BUGS
To avoid name conflicts with the underlying system,
.IR wait ,
.IR waitpid ,
and
.I waitfor
are preprocessor macros defined as
.IR p9wait ,
.IR p9waitpid ,
and
.IR p9waitfor ;
see
.IR intro (3).