summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-25 10:43:42 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-25 10:43:42 -0700
commit1de059d0f51cd3aa003a9e0d1de4662a5f758c37 (patch)
treeb888683dd7327f5a2f3afd5b5f14b6ad46ea1fca /sysif.c
parent0b52768a15706b53e38890e1dc1ebc7f92e00166 (diff)
downloadtxr-1de059d0f51cd3aa003a9e0d1de4662a5f758c37.tar.gz
txr-1de059d0f51cd3aa003a9e0d1de4662a5f758c37.tar.bz2
txr-1de059d0f51cd3aa003a9e0d1de4662a5f758c37.zip
Reduce footprint of :fd property.
Querying the :fd stream property is equivalent to calling the stream-fd function. Streams have a C virtual function get_fd, so implementing :fd in their getprop functions is redundant functionality. The stream-getprop function can test for :fd and call stream-fd, so the stream implementations don't have to deal with the :fd property. Also, there are still places in the code base that are using stream_getprop to get the file descriptor, instead of calling stream_fd. If we fix all this, then fd_k remains referenced only in a very small number of places. * socket.c (dgram_get_prop): Don't handle :fd any more. * stream.c (unimpl_get_fd): Static function removed. (fill_stream_ops): Default the get_fd function to null_get_fd instead of unimpl_get_fd, so it doesn't throw. Even a stdio stream don't throw; when the file is closed, it returns nil. (stdio_get_prop): Don't handle :fd any more. (stream_get_prop): Handle :fd here. If the stream has a get_fd function that isn't null_get_fd, then call it. Only if the stream doesn't have a get_fd function, fall back on its get_prop function. * sysif.c (mkdir_wrap, poll_wrap, simulate_setuid_setgid): Call stream_fd instead of stream_get_prop.
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sysif.c b/sysif.c
index dcea7964..4b8f8b29 100644
--- a/sysif.c
+++ b/sysif.c
@@ -303,7 +303,7 @@ static val mkdir_wrap(val path, val mode)
#if HAVE_CHMOD || HAVE_CHOWN || HAVE_SYS_STAT || HAVE_FILE_STAMP_CHANGE
static int get_fd(val stream, val self)
{
- val fd_in = if3(integerp(stream), stream, stream_get_prop(stream, fd_k));
+ val fd_in = if3(integerp(stream), stream, stream_fd(stream));
if (stream && !fd_in)
uw_throwf(file_error_s,
@@ -1326,7 +1326,7 @@ static val poll_wrap(val poll_list, val timeout_in)
break;
case COBJ:
if (subtypep(obj->co.cls, stream_s)) {
- val fdval = stream_get_prop(obj, fd_k);
+ val fdval = stream_fd(obj);
if (!fdval) {
free(pfd);
uw_throwf(file_error_s,
@@ -1553,7 +1553,7 @@ void simulate_setuid_setgid(val open_script)
return;
{
- val fdv = stream_get_prop(open_script, fd_k);
+ val fdv = stream_fd(open_script);
if (fdv) {
struct stat stb;