# HG changeset patch # User Francisco J Ballesteros # Date 1316099874 -7200 # Node ID 68fb1bf43de3b646f69bcfa12f3a44ec364c792e # Parent f2b04317d2acb1288f0e15ed399604b6e500a7f7 renames: zero copy syscalls renamed. I'll commit this w/o waiting to get rid of this local checkout. IIRC, there was agreement on the rename. R=nix-dev CC=nix-dev http://codereview.appspot.com/5007046 diff -r f2b04317d2ac -r 68fb1bf43de3 sys/include/libc.h --- a/sys/include/libc.h Thu Sep 15 17:02:41 2011 +0200 +++ b/sys/include/libc.h Thu Sep 15 17:17:54 2011 +0200 @@ -703,7 +703,7 @@ extern void werrstr(char*, ...); #pragma varargck argpos werrstr 1 -extern int zp(int*); +extern int ziop(int*); /* * Atomics @@ -725,11 +725,11 @@ }; /* kernel interface */ -extern void zfree(Zio io[], int nio); -extern int zpread(int fd, Zio io[], int nio, usize count, vlong offset); -extern int zcwrite(int fd, Zio io[], int nio); -extern int zcread(int fd, Zio io[], int nio, usize count); -extern int zpwrite(int fd, Zio io[], int nio, vlong offset); +extern void ziofree(Zio io[], int nio); +extern int ziopread(int fd, Zio io[], int nio, usize count, vlong offset); +extern int ziowrite(int fd, Zio io[], int nio); +extern int zioread(int fd, Zio io[], int nio, usize count); +extern int ziopwrite(int fd, Zio io[], int nio, vlong offset); /* diff -r f2b04317d2ac -r 68fb1bf43de3 sys/man/2/getcore --- a/sys/man/2/getcore Thu Sep 15 17:02:41 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -.TH GETCORE 2 -.SH NAME -getcore \- get core number and role -.SH SYNOPSIS -.B #include -.br -.B #include -.PP -.B -int getcore(int *rolep) -.SH DESCRIPTION -.I Getcore -returns the number for the core used by the process and, if -.I rlope -is not nil, fills the pointed integer with the core role, one of: -.I NIXTC -(time-sharing core), -.I NIXAC -(application core), and -.I NIXKC -(kernel core). -It uses -.I tos -and does not perform any system call or trap. -.SH SOURCE -.B /sys/src/libc/9sys/getcore.c -.SH SEE ALSO -.IR cons (3) diff -r f2b04317d2ac -r 68fb1bf43de3 sys/man/2/getcoreno --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/man/2/getcoreno Thu Sep 15 17:17:54 2011 +0200 @@ -0,0 +1,28 @@ +.TH GETCORENO 2 +.SH NAME +getcore \- get core number and role +.SH SYNOPSIS +.B #include +.br +.B #include +.PP +.B +int getcoreno(int *rolep) +.SH DESCRIPTION +.I Getcoreno +returns the number for the core used by the process and, if +.I rlope +is not nil, fills the pointed integer with the core role, one of: +.I NIXTC +(time-sharing core), +.I NIXAC +(application core), and +.I NIXKC +(kernel core). +It uses +.I tos +and does not perform any system call or trap. +.SH SOURCE +.B /sys/src/libc/9sys/getcoreno.c +.SH SEE ALSO +.IR cons (3) diff -r f2b04317d2ac -r 68fb1bf43de3 sys/man/2/ziop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/man/2/ziop Thu Sep 15 17:17:54 2011 +0200 @@ -0,0 +1,72 @@ +.TH ZIOP 2 +.SH NAME +ziop \- create a zero-copy interprocess pipe +.SH SYNOPSIS +.B #include +.br +.B #include +.PP +.B +int ziop(int fd[2]) +.SH DESCRIPTION +.I ZIOP +creates a buffered channel for zero-copy interprocess I/O communication. +Unlike conventional pipes, the buffers are supplied by the writers and +.I ziop +queues only buffer descriptors. +.PP +Two file descriptors are returned in +.IR fd . +Data written to +.B fd[1] +is available for reading from +.B fd[0] +and data written to +.B fd[0] +is available for reading from +.BR fd[1] . +.PP +After the pipe has been established, +cooperating processes +created by subsequent +.IR fork (2) +calls may pass data through the +pipe with +.I zread +and +.I zwrite +calls (also with +.I read +and +.I write +system calls). +.PP +Refer to +.IR zp (3) +for properties of the communication channel (Note, to the man page, not +to the infamous president). +.PP +When all the data has been read from a pipe and the writer has closed the pipe or exited, +.IR read (2) +will return 0 bytes. Writes to a pipe with no reader will generate a note +.BR "sys: write on closed pipe" . +.SH SOURCE +.B /sys/src/libc/9sys/ziop.c +.SH SEE ALSO +.IR intro (2), +.IR zioread (2), +.IR zp (2) +.SH DIAGNOSTICS +Sets +.IR errstr . +.SH BUGS +If a read or a write of a pipe is interrupted, some unknown +number of bytes may have been transferred. +.br +When a read from a pipe returns 0 bytes, it usually means end of file +but is indistinguishable from reading the result of an explicit +write of zero bytes. +.br +The writer is not flow-controlled, other than by the availability of +buffers. + diff -r f2b04317d2ac -r 68fb1bf43de3 sys/man/2/zioread --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/man/2/zioread Thu Sep 15 17:17:54 2011 +0200 @@ -0,0 +1,93 @@ +.TH ZIOREAD 2 +.SH NAME +zioread, ziowrite, ziopread, ziopwrite, ziofree \- zero-copy read and write +.SH SYNOPSIS +.B #include +.br +.B #include +.PP +.nf +.ft L +typedef struct Zio Zio; +struct Zio +{ + void* data; + ulong size; +}; +.fi +.PP +.B +int ziopread(int fd, Zio io[], int nio, usize count, vlong offset); +.PP +.B +int ziopwrite(int fd, Zio io[], int nio, vlong offset); +.PP +.B +int zioread(int fd, Zio io[], int nio, usize count); +.PP +.B +int ziowrite(int fd, Zio io[], int nio); +.PP +.B +void ziofree(Zio io[], int nio); +.SH DESCRIPTION +These functions supplement the standard read and write operations of +.IR read (2) +with facilities for zero-copy I/O. +The set of I/O buffers used should be allocated within ZIO segments, see +.IR segment (3), +or data will be copied during I/O. But they can refer to any other segment as well. +.PP +.B Zio +structures passed as an argument represent a series of zero-copy buffers +for the call. For +.I ziowrite +they should refer to actual data. For +.I zioread +the system fills them to reflect where the read data stands. In both cases, +.I nio +is the number of entries in the +.I io +array, and +.I fd +is the file descriptor where to perform I/O. The +.I count +argument to +.I zioread +limits the total ammount of data that may be retrieved. +The return value reflects the number of entries used in the +.I io +array. +.PP +.I Ziopread +and +.I ziopwrite +are similar to +.I zioread +and +.I ziowrite +but specify the offset where to read or write. +.PP +.I ziofree +is a convenience system call to notify buffer owners that they are no longer +in use. Using it is equivalent of locating the +.B free +files for the segments involved and then writing the +.I io +addresses there. +.SH SOURCE +.B /sys/src/libc/9sys/zioread.c +.br +.B /sys/src/libc/9sys/ziowrite.c +.br +.B /sys/src/nix/port/syszio.c +.SH SEE ALSO +.IR intro (2), +.IR read (2), +and +.IR segment (3). +.SH DIAGNOSTICS +These functions set +.IR errstr . +.SH BUGS +Experimental, just like everything else. diff -r f2b04317d2ac -r 68fb1bf43de3 sys/man/2/zp --- a/sys/man/2/zp Thu Sep 15 17:02:41 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -.TH ZP 2 -.SH NAME -zp \- create a zero-copy interprocess channel -.SH SYNOPSIS -.B #include -.br -.B #include -.PP -.B -int zp(int fd[2]) -.SH DESCRIPTION -.I ZP -creates a buffered channel for zero-copy interprocess I/O communication. -Unlike conventional pipes, the buffers are supplied by the writers and -.I zp -queues only buffer descriptors. -.PP -Two file descriptors are returned in -.IR fd . -Data written to -.B fd[1] -is available for reading from -.B fd[0] -and data written to -.B fd[0] -is available for reading from -.BR fd[1] . -.PP -After the pipe has been established, -cooperating processes -created by subsequent -.IR fork (2) -calls may pass data through the -pipe with -.I zread -and -.I zwrite -calls (also with -.I read -and -.I write -system calls). -.PP -Refer -.IR zp (3) -for properties of the communication channel. -.PP -When all the data has been read from a pipe and the writer has closed the pipe or exited, -.IR read (2) -will return 0 bytes. Writes to a pipe with no reader will generate a note -.BR "sys: write on closed pipe" . -.SH SOURCE -.B /sys/src/libc/9sys/zp.c -.SH SEE ALSO -.IR intro (2), -.IR zread (2), -.IR zp (2) -.SH DIAGNOSTICS -Sets -.IR errstr . -.SH BUGS -If a read or a write of a pipe is interrupted, some unknown -number of bytes may have been transferred. -.br -When a read from a pipe returns 0 bytes, it usually means end of file -but is indistinguishable from reading the result of an explicit -write of zero bytes. -.br -The writer is not flow-controlled, other than by the availability of -buffers. - diff -r f2b04317d2ac -r 68fb1bf43de3 sys/man/2/zread --- a/sys/man/2/zread Thu Sep 15 17:02:41 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -.TH ZREAD 2 -.SH NAME -zread, zwrite, zpread, zpwrite, zfree \- zero-copy read and write -.SH SYNOPSIS -.B #include -.br -.B #include -.PP -.nf -.ft L -typedef struct Zio Zio; -struct Zio -{ - void* data; - ulong size; -}; -.fi -.PP -.B -int zpread(int fd, Zio io[], int nio, usize count, vlong offset); -.PP -.B -int zpwrite(int fd, Zio io[], int nio, vlong offset); -.PP -.B -int zread(int fd, Zio io[], int nio, usize count); -.PP -.B -int zwrite(int fd, Zio io[], int nio); -.PP -.B -void zfree(Zio io[], int nio); -.SH DESCRIPTION -These functions supplement the standard read and write operations of -.IR read (2) -with facilities for zero-copy I/O. -The set of I/O buffers used should be allocated within ZIO segments, see -.IR segment (3), -or data will be copied during I/O. But they can refer to any other segment as well. -.PP -.B Zio -structures passed as an argument represent a series of zero-copy buffers -for the call. For -.I zwrite -they should refer to actual data. For -.I zread -the system fills them to reflect where the read data stands. In both cases, -.I nio -is the number of entries in the -.I io -array, and -.I fd -is the file descriptor where to perform I/O. The -.I count -argument to -.I zread -limits the total ammount of data that may be retrieved. -The return value reflects the number of entries used in the -.I io -array. -.PP -.I Zpread -and -.I zpwrite -are similar to -.I zread -and -.I zwrite -but specify the offset where to read or write. -.PP -.I zfree -is a convenience system call to notify buffer owners that they are no longer -in use. Using it is equivalent of locating the -.B free -files for the segments involved and then writing the -.I io -addresses there. -.SH SOURCE -.B /sys/src/libc/9sys/zread.c -.br -.B /sys/src/libc/9sys/zwrite.c -.br -.B /sys/src/nix/port/syszio.c -.SH SEE ALSO -.IR intro (2), -.IR read (2), -and -.IR segment (3). -.SH DIAGNOSTICS -These functions set -.IR errstr . -.SH BUGS -Experimental, just like everything else. diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/libc/9sys/mkfile --- a/sys/src/libc/9sys/mkfile Thu Sep 15 17:02:41 2011 +0200 +++ b/sys/src/libc/9sys/mkfile Thu Sep 15 17:17:54 2011 +0200 @@ -55,9 +55,9 @@ werrstr.$O\ write.$O\ writev.$O\ - zcread.$O\ - zcwrite.$O\ - zp.$O\ + zioread.$O\ + ziowrite.$O\ + ziop.$O\ HFILES=\ /sys/include/libc.h\ diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/libc/9sys/zcread.c --- a/sys/src/libc/9sys/zcread.c Thu Sep 15 17:02:41 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#include -#include - -int -zcread(int fd, Zio io[], int nio, usize count) -{ - return zpread(fd, io, nio, count, -1LL); -} diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/libc/9sys/zcwrite.c --- a/sys/src/libc/9sys/zcwrite.c Thu Sep 15 17:02:41 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#include -#include - -int -zcwrite(int fd, Zio io[], int nio) -{ - return zpwrite(fd, io, nio, -1LL); -} diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/libc/9sys/ziop.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/libc/9sys/ziop.c Thu Sep 15 17:17:54 2011 +0200 @@ -0,0 +1,18 @@ +#include +#include + +int +ziop(int fd[2]) +{ + if(bind("#∏", "/mnt/zp", MREPL|MCREATE) < 0) + return -1; + fd[0] = open("/mnt/zp/data", ORDWR); + if(fd[0] < 0) + return -1; + fd[1] = open("/mnt/zp/data1", ORDWR); + if(fd[1] < 0){ + close(fd[0]); + return -1; + } + return 0; +} diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/libc/9sys/zioread.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/libc/9sys/zioread.c Thu Sep 15 17:17:54 2011 +0200 @@ -0,0 +1,8 @@ +#include +#include + +int +zioread(int fd, Zio io[], int nio, usize count) +{ + return ziopread(fd, io, nio, count, -1LL); +} diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/libc/9sys/ziowrite.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/libc/9sys/ziowrite.c Thu Sep 15 17:17:54 2011 +0200 @@ -0,0 +1,8 @@ +#include +#include + +int +ziowrite(int fd, Zio io[], int nio) +{ + return ziopwrite(fd, io, nio, -1LL); +} diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/libc/9sys/zp.c --- a/sys/src/libc/9sys/zp.c Thu Sep 15 17:02:41 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -#include -#include - -int -zp(int fd[2]) -{ - if(bind("#∏", "/mnt/zp", MREPL|MCREATE) < 0) - return -1; - fd[0] = open("/mnt/zp/data", ORDWR); - if(fd[0] < 0) - return -1; - fd[1] = open("/mnt/zp/data1", ORDWR); - if(fd[1] < 0){ - close(fd[0]); - return -1; - } - return 0; -} diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/libc/9syscall/sys.h --- a/sys/src/libc/9syscall/sys.h Thu Sep 15 17:02:41 2011 +0200 +++ b/sys/src/libc/9syscall/sys.h Thu Sep 15 17:17:54 2011 +0200 @@ -53,7 +53,7 @@ #define SEMALT 54 #define EXECAC 55 #define NIXSYSCALL 56 -#define ZPREAD 57 -#define ZPWRITE 58 -#define ZFREE 59 +#define ZIOPREAD 57 +#define ZIOPWRITE 58 +#define ZIOFREE 59 diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/nix/k10/k8cpu --- a/sys/src/nix/k10/k8cpu Thu Sep 15 17:02:41 2011 +0200 +++ b/sys/src/nix/k10/k8cpu Thu Sep 15 17:17:54 2011 +0200 @@ -183,6 +183,7 @@ taslock tod syszio + syscallfmt # #dir diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/nix/port/syscallfmt.c --- a/sys/src/nix/port/syscallfmt.c Thu Sep 15 17:02:41 2011 +0200 +++ b/sys/src/nix/port/syscallfmt.c Thu Sep 15 17:17:54 2011 +0200 @@ -321,7 +321,7 @@ fmtprint(&fmt, " %lld", vl); } break; - case ZPREAD: + case ZIOPREAD: i[0] = va_arg(list, int); v = va_arg(list, void*); i[1] = va_arg(list, int); @@ -329,14 +329,14 @@ vl = va_arg(list, vlong); fmtprint(&fmt, "%d %#p %d %ld %ulld", i[0], v, i[1], ul, vl); break; - case ZPWRITE: + case ZIOPWRITE: i[0] = va_arg(list, int); v = va_arg(list, void*); i[1] = va_arg(list, int); vl = va_arg(list, vlong); fmtprint(&fmt, "%d %#p %d %ulld", i[0], v, i[1], vl); break; - case ZFREE: + case ZIOFREE: v = va_arg(list, void*); i[1] = va_arg(list, int); fmtprint(&fmt, "%#p %d", v, i[1]); diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/nix/port/systab.c --- a/sys/src/nix/port/systab.c Thu Sep 15 17:02:41 2011 +0200 +++ b/sys/src/nix/port/systab.c Thu Sep 15 17:17:54 2011 +0200 @@ -61,9 +61,9 @@ extern void syssemalt(Ar0*, va_list); extern void sysexecac(Ar0*, va_list); extern void sysnixsyscall(Ar0*, va_list); -extern void syszpread(Ar0*, va_list); -extern void syszpwrite(Ar0*, va_list); -extern void syszfree(Ar0*, va_list); +extern void sysziopread(Ar0*, va_list); +extern void sysziopwrite(Ar0*, va_list); +extern void sysziofree(Ar0*, va_list); struct { char* n; void (*f)(Ar0*, va_list); @@ -124,9 +124,9 @@ [SEMALT] { "Semalt", syssemalt, { .i = -1 } }, [EXECAC] { "Execac", sysexecac, { .v = (void*)-1 } }, [NIXSYSCALL] { "Nixsyscall", sysnixsyscall, { .i = -1 } }, - [ZPREAD] { "Zpread", syszpread, { .l = -1 } }, - [ZPWRITE] { "Zpwrite", syszpwrite, { .l = -1 } }, - [ZFREE] { "Zfree", syszfree, { .i = -1 } }, + [ZIOPREAD] { "Ziopread", sysziopread, { .l = -1 } }, + [ZIOPWRITE] { "Ziopwrite", sysziopwrite, { .l = -1 } }, + [ZIOFREE] { "Ziofree", sysziofree, { .i = -1 } }, }; int nsyscall = nelem(systab); diff -r f2b04317d2ac -r 68fb1bf43de3 sys/src/nix/port/syszio.c --- a/sys/src/nix/port/syszio.c Thu Sep 15 17:02:41 2011 +0200 +++ b/sys/src/nix/port/syszio.c Thu Sep 15 17:17:54 2011 +0200 @@ -463,7 +463,7 @@ } void -syszpread(Ar0 *ar0, va_list list) +sysziopread(Ar0 *ar0, va_list list) { int fd, nio; long count; @@ -482,7 +482,7 @@ } void -syszpwrite(Ar0 *ar0, va_list list) +sysziopwrite(Ar0 *ar0, va_list list) { int fd, nio; vlong offset; @@ -499,7 +499,7 @@ } void -syszfree(Ar0 *, va_list list) +sysziofree(Ar0 *, va_list list) { Zio *io; int nio, i;