mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 06:39:17 +02:00
plan9 API updates
This commit is contained in:
parent
b1b207504c
commit
d284345157
3 changed files with 33 additions and 33 deletions
2
mkfile
2
mkfile
|
@ -4,7 +4,7 @@ BIN=/$objtype/bin
|
|||
TARG=chibi-scheme
|
||||
MODDIR=/sys/lib/chibi-scheme
|
||||
|
||||
CPPFLAGS= -Iinclude -DPLAN9 '-DSEXP_USE_STRING_STREAMS=0' '-DSEXP_USE_DEBUG=0' '-DSEXP_USE_MODULES=0'
|
||||
CPPFLAGS= -Iinclude -DPLAN9 '-DSEXP_USE_STRING_STREAMS=0' '-DSEXP_USE_DEBUG=0' '-DSEXP_USE_MODULES=0' '-DSEXP_USE_GREEN_THREADS=0'
|
||||
CFLAGS= -p $CPPFLAGS
|
||||
|
||||
OFILES=sexp.$O eval.$O main.$O
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
_FN0("random-integer", 0, sexp_rand),
|
||||
_FN1(SEXP_FIXNUM, "random-seed", 0, sexp_srand),
|
||||
_FN0("current-directory", 0, sexp_getwd),
|
||||
_FN0("current-user", 0, sexp_getuser),
|
||||
_FN0("system-name", 0, sexp_sysname),
|
||||
_FN1(SEXP_IPORT, "port-fileno", 0, sexp_fileno),
|
||||
_FN2(SEXP_FIXNUM, SEXP_STRING, "fileno->port", 0, sexp_fdopen),
|
||||
_FN0("fork", 0, sexp_fork),
|
||||
_FN2(SEXP_STRING, SEXP_PAIR, "exec", 0, sexp_exec),
|
||||
_FN1(SEXP_STRING, "exits", 0, sexp_exits),
|
||||
_FN2(SEXP_FIXNUM, SEXP_FIXNUM, "dup", 0, sexp_dup),
|
||||
_FN0("pipe", 0, sexp_pipe),
|
||||
_FN1(SEXP_FIXNUM, "sleep", 0, sexp_sleep),
|
||||
_FN1(SEXP_STRING, "getenv", 0, sexp_getenv),
|
||||
_FN1(SEXP_STRING, "change-directory", 0, sexp_chdir),
|
||||
_FN0("wait", 0, sexp_wait),
|
||||
_FN2(SEXP_FIXNUM, SEXP_STRING, "post-note", 0, sexp_postnote),
|
||||
_FN4(SEXP_PAIR, SEXP_STRING, "%postmountsrv", 0, sexp_postmountsrv),
|
||||
_FN1(SEXP_STRING, "file-exists?", 0, sexp_file_exists_p),
|
||||
_FN0(_I(SEXP_FIXNUM), "random-integer", 0, sexp_rand),
|
||||
_FN1(_I(SEXP_FIXNUM), _I(SEXP_FIXNUM), "random-seed", 0, sexp_srand),
|
||||
_FN0(_I(SEXP_STRING), "current-directory", 0, sexp_getwd),
|
||||
_FN0(_I(SEXP_STRING), "current-user", 0, sexp_getuser),
|
||||
_FN0(_I(SEXP_STRING), "system-name", 0, sexp_sysname),
|
||||
_FN1(_I(SEXP_FIXNUM), _I(SEXP_IPORT), "port-fileno", 0, sexp_fileno),
|
||||
_FN2(_I(SEXP_IPORT), _I(SEXP_FIXNUM), _I(SEXP_STRING), "fileno->port", 0, sexp_fdopen),
|
||||
_FN0(_I(SEXP_FIXNUM), "fork", 0, sexp_fork),
|
||||
_FN2(SEXP_VOID, _I(SEXP_STRING), _I(SEXP_PAIR), "exec", 0, sexp_exec),
|
||||
_FN1(SEXP_VOID, _I(SEXP_STRING), "exits", 0, sexp_exits),
|
||||
_FN2(_I(SEXP_FIXNUM), _I(SEXP_FIXNUM), _I(SEXP_FIXNUM), "dup", 0, sexp_dup),
|
||||
_FN0(_I(SEXP_PAIR), "pipe", 0, sexp_pipe),
|
||||
_FN1(_I(SEXP_FIXNUM), _I(SEXP_FIXNUM), "sleep", 0, sexp_sleep),
|
||||
_FN1(_I(SEXP_STRING), _I(SEXP_STRING), "getenv", 0, sexp_getenv),
|
||||
_FN1(_I(SEXP_FIXNUM), _I(SEXP_STRING), "change-directory", 0, sexp_chdir),
|
||||
_FN0(_I(SEXP_FIXNUM), "wait", 0, sexp_wait),
|
||||
_FN2(_I(SEXP_FIXNUM), _I(SEXP_FIXNUM), _I(SEXP_STRING), "post-note", 0, sexp_postnote),
|
||||
_FN4(_I(SEXP_FIXNUM), _I(SEXP_PAIR), _I(SEXP_STRING), "%postmountsrv", 0, sexp_postmountsrv),
|
||||
_FN1(_I(SEXP_FIXNUM), _I(SEXP_STRING), "file-exists?", 0, sexp_file_exists_p),
|
||||
|
|
26
opt/plan9.c
26
opt/plan9.c
|
@ -15,7 +15,7 @@ sexp sexp_file_exists_p (sexp ctx sexp_api_params(self, n), sexp path) {
|
|||
int res;
|
||||
uchar statbuf[STATMAX];
|
||||
if (! sexp_stringp(path))
|
||||
return sexp_type_exception(ctx, "file-exists?: not a string", path);
|
||||
return sexp_type_exception(ctx, self, SEXP_STRING, path);
|
||||
res = stat(sexp_string_data(path), statbuf, sizeof(statbuf));
|
||||
return (res < 0) ? SEXP_FALSE : SEXP_TRUE;
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ sexp sexp_file_exists_p (sexp ctx sexp_api_params(self, n), sexp path) {
|
|||
sexp sexp_fdopen (sexp ctx sexp_api_params(self, n), sexp fd, sexp mode) {
|
||||
FILE *f;
|
||||
if (! sexp_integerp(fd))
|
||||
return sexp_type_exception(ctx, "fdopen: not an integer", fd);
|
||||
return sexp_type_exception(ctx, self, SEXP_FIXNUM, fd);
|
||||
if (! sexp_stringp(mode))
|
||||
return sexp_type_exception(ctx, "fdopen: not a mode string", mode);
|
||||
return sexp_type_exception(ctx, self, SEXP_STRING, mode);
|
||||
f = fdopen(sexp_unbox_fixnum(fd), sexp_string_data(mode));
|
||||
if (! f)
|
||||
return sexp_user_exception(ctx, SEXP_FALSE, "fdopen failed", fd);
|
||||
|
@ -38,7 +38,7 @@ sexp sexp_fdopen (sexp ctx sexp_api_params(self, n), sexp fd, sexp mode) {
|
|||
|
||||
sexp sexp_fileno (sexp ctx sexp_api_params(self, n), sexp port) {
|
||||
if (! sexp_portp(port))
|
||||
return sexp_type_exception(ctx, "fileno: not a port", port);
|
||||
return sexp_type_exception(ctx, self, SEXP_IPORT, port);
|
||||
return sexp_make_fixnum(fileno(sexp_port_stream(port)));
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ sexp sexp_pipe (sexp ctx sexp_api_params(self, n)) {
|
|||
|
||||
sexp sexp_sleep (sexp ctx sexp_api_params(self, n), sexp msecs) {
|
||||
if (! sexp_integerp(msecs))
|
||||
return sexp_type_exception(ctx, "sleep: not an integer", msecs);
|
||||
return sexp_type_exception(ctx, self, SEXP_FIXNUM, msecs);
|
||||
sleep(sexp_unbox_fixnum(msecs));
|
||||
return SEXP_VOID;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ sexp sexp_sleep (sexp ctx sexp_api_params(self, n), sexp msecs) {
|
|||
sexp sexp_getenv (sexp ctx sexp_api_params(self, n), sexp name) {
|
||||
char *value;
|
||||
if (! sexp_stringp(name))
|
||||
return sexp_type_exception(ctx, "getenv: not a string", name);
|
||||
return sexp_type_exception(ctx, self, SEXP_STRING, name);
|
||||
value = getenv(sexp_string_data(name));
|
||||
return ((! value) ? SEXP_FALSE : sexp_c_string(ctx, value, -1));
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ sexp sexp_getwd (sexp ctx sexp_api_params(self, n)) {
|
|||
|
||||
sexp sexp_chdir (sexp ctx sexp_api_params(self, n), sexp path) {
|
||||
if (! sexp_stringp(path))
|
||||
return sexp_type_exception(ctx, "chdir: not a string", path);
|
||||
return sexp_type_exception(ctx, self, SEXP_STRING, path);
|
||||
chdir(sexp_string_data(path));
|
||||
return SEXP_VOID;
|
||||
}
|
||||
|
@ -122,9 +122,9 @@ sexp sexp_wait (sexp ctx sexp_api_params(self, n)) { /* just return (pid msg) */
|
|||
|
||||
sexp sexp_postnote (sexp ctx sexp_api_params(self, n), sexp pid, sexp note) {
|
||||
if (! sexp_integerp(pid))
|
||||
return sexp_type_exception(ctx, "postnote: not an integer", pid);
|
||||
return sexp_type_exception(ctx, self, SEXP_FIXNUM, pid);
|
||||
if (! sexp_stringp(note))
|
||||
return sexp_type_exception(ctx, "postnote: not a string", note);
|
||||
return sexp_type_exception(ctx, self, SEXP_STRING, note);
|
||||
postnote(PNPROC, sexp_unbox_fixnum(pid), sexp_string_data(note));
|
||||
return SEXP_VOID;
|
||||
}
|
||||
|
@ -286,13 +286,13 @@ sexp sexp_postmountsrv (sexp ctx sexp_api_params(self, n), sexp ls, sexp name, s
|
|||
Srv s;
|
||||
struct sexp_plan9_srv p9s;
|
||||
if (! sexp_listp(ctx, ls))
|
||||
return sexp_type_exception(ctx, "postmountsrv: not a list", ls);
|
||||
return sexp_type_exception(ctx, self, SEXP_PAIR, ls);
|
||||
if (! sexp_stringp(name))
|
||||
return sexp_type_exception(ctx, "postmountsrv: not a string", name);
|
||||
return sexp_type_exception(ctx, self, SEXP_STRING, name);
|
||||
if (! sexp_stringp(mtpt))
|
||||
return sexp_type_exception(ctx, "postmountsrv: not a string", mtpt);
|
||||
return sexp_type_exception(ctx, self, SEXP_STRING, mtpt);
|
||||
if (! sexp_integerp(flags))
|
||||
return sexp_type_exception(ctx, "postmountsrv: not an integer", flags);
|
||||
return sexp_type_exception(ctx, self, SEXP_FIXNUM, flags);
|
||||
sexp_build_srv(ctx, &p9s, ls);
|
||||
s.aux = &p9s;
|
||||
s.auth = &sexp_9p_auth;
|
||||
|
|
Loading…
Add table
Reference in a new issue