Adding port-fileno.

This commit is contained in:
Alex Shinn 2013-08-18 17:45:23 +09:00
parent a1e22d42d4
commit a6e71e47b8
3 changed files with 14 additions and 1 deletions

9
eval.c
View file

@ -1178,6 +1178,15 @@ sexp sexp_set_port_line_op (sexp ctx, sexp self, sexp_sint_t n, sexp port, sexp
return SEXP_VOID; return SEXP_VOID;
} }
#ifndef PLAN9
sexp sexp_get_port_fileno (sexp ctx, sexp self, sexp_sint_t n, sexp port) {
sexp_assert_type(ctx, sexp_portp, SEXP_IPORT, port);
if (sexp_port_stream(port) && sexp_port_fileno(port) >= 0)
return sexp_make_fixnum(sexp_port_fileno(port));
return SEXP_FALSE;
}
#endif
#if SEXP_USE_STATIC_LIBS #if SEXP_USE_STATIC_LIBS
#ifndef PLAN9 #ifndef PLAN9
#include "clibs.c" #include "clibs.c"

View file

@ -224,6 +224,8 @@ SEXP_API sexp sexp_9p_req_fid (sexp ctx, sexp self, sexp_sint_t n, sexp req);
SEXP_API sexp sexp_9p_req_newfid (sexp ctx, sexp self, sexp_sint_t n, sexp req); SEXP_API sexp sexp_9p_req_newfid (sexp ctx, sexp self, sexp_sint_t n, sexp req);
SEXP_API sexp sexp_9p_respond (sexp ctx, sexp self, sexp_sint_t n, sexp req, sexp err); SEXP_API sexp sexp_9p_respond (sexp ctx, sexp self, sexp_sint_t n, sexp req, sexp err);
SEXP_API sexp sexp_9p_responderror (sexp ctx, sexp self, sexp_sint_t n, sexp req); SEXP_API sexp sexp_9p_responderror (sexp ctx, sexp self, sexp_sint_t n, sexp req);
#else
SEXP_API sexp sexp_get_port_fileno (sexp ctx, sexp self, sexp_sint_t n, sexp port);
#endif #endif
#if SEXP_USE_SIMPLIFY #if SEXP_USE_SIMPLIFY

View file

@ -239,8 +239,10 @@ _FN2(_I(SEXP_OPCODE), _I(SEXP_TYPE), _I(SEXP_SYMBOL), "type-slot-offset", 0, sex
_OP(SEXP_OPC_GETTER, SEXP_OP_SLOTN_REF, 3, 0, _I(SEXP_OBJECT), _I(SEXP_OBJECT), _I(SEXP_OBJECT), _I(SEXP_FIXNUM), 0, "slot-ref", 0, NULL), _OP(SEXP_OPC_GETTER, SEXP_OP_SLOTN_REF, 3, 0, _I(SEXP_OBJECT), _I(SEXP_OBJECT), _I(SEXP_OBJECT), _I(SEXP_FIXNUM), 0, "slot-ref", 0, NULL),
_OP(SEXP_OPC_SETTER, SEXP_OP_SLOTN_SET, 4, 0, SEXP_VOID, _I(SEXP_OBJECT), _I(SEXP_OBJECT), _I(SEXP_FIXNUM), 0,"slot-set!", 0, NULL), _OP(SEXP_OPC_SETTER, SEXP_OP_SLOTN_SET, 4, 0, SEXP_VOID, _I(SEXP_OBJECT), _I(SEXP_OBJECT), _I(SEXP_FIXNUM), 0,"slot-set!", 0, NULL),
#endif #endif
#if PLAN9 #ifdef PLAN9
#include "opt/plan9-opcodes.c" #include "opt/plan9-opcodes.c"
#else
_FN1(_I(SEXP_OBJECT), _I(SEXP_IPORT), "port-fileno", 0, sexp_get_port_fileno),
#endif #endif
#if SEXP_USE_MODULES #if SEXP_USE_MODULES
_FN0(_I(SEXP_ENV), "current-environment", 0, sexp_current_environment), _FN0(_I(SEXP_ENV), "current-environment", 0, sexp_current_environment),