summaryrefslogtreecommitdiff
path: root/libguile/socket.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-02-14 21:57:35 +0100
committerAndy Wingo <wingo@pobox.com>2017-02-14 22:03:21 +0100
commit69ca2bb2217303b2556b131f3995ca4f6af81234 (patch)
treea8ef7e23995f35b974db988254aabe5a37c72922 /libguile/socket.c
parent2c02bdda191eecd998c33b00c56752b8ec7378ab (diff)
Elide syscalls in fdes->port
* libguile/fports.h (scm_t_fport): Add options field. (SCM_FDES_RANDOM_P): Deprecate. (scm_i_fdes_to_port): Add options argument. * libguile/fports.c (scm_i_fdes_to_port): Add options argument. Only verify FD if SCM_FPORT_OPTION_VERIFY is there. (scm_fdes_to_port, scm_open_file_with_encoding): Adapt to scm_i_fdes_to_port changes. (fport_random_access_p): Don't try to seek if NOT_SEEKABLE option is set. * libguile/deprecated.h: * libguile/deprecated.c (SCM_FDES_RANDOM_P): Deprecate. * NEWS: Add deprecation. * libguile/filesys.c: * libguile/ioext.c: * libguile/posix.c: * libguile/read.c: * libguile/socket.c: Adapt callers.
Diffstat (limited to 'libguile/socket.c')
-rw-r--r--libguile/socket.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libguile/socket.c b/libguile/socket.c
index 37e9f523f..4f2acffd7 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -367,7 +367,12 @@ SCM_DEFINE (scm_inet_pton, "inet-pton", 2, 0, 0,
SCM_SYMBOL (sym_socket, "socket");
-#define SCM_SOCK_FD_TO_PORT(fd) scm_fdes_to_port (fd, "r+0", sym_socket)
+static SCM
+scm_socket_fd_to_port (int fd)
+{
+ return scm_i_fdes_to_port (fd, scm_mode_bits ("r+0"), sym_socket,
+ SCM_FPORT_OPTION_NOT_SEEKABLE);
+}
SCM_DEFINE (scm_socket, "socket", 3, 0, 0,
(SCM family, SCM style, SCM proto),
@@ -391,7 +396,7 @@ SCM_DEFINE (scm_socket, "socket", 3, 0, 0,
scm_to_int (proto));
if (fd == -1)
SCM_SYSERROR;
- return SCM_SOCK_FD_TO_PORT (fd);
+ return scm_socket_fd_to_port (fd);
}
#undef FUNC_NAME
@@ -413,7 +418,8 @@ SCM_DEFINE (scm_socketpair, "socketpair", 3, 0, 0,
if (socketpair (fam, scm_to_int (style), scm_to_int (proto), fd) == -1)
SCM_SYSERROR;
- return scm_cons (SCM_SOCK_FD_TO_PORT (fd[0]), SCM_SOCK_FD_TO_PORT (fd[1]));
+ return scm_cons (scm_socket_fd_to_port (fd[0]),
+ scm_socket_fd_to_port (fd[1]));
}
#undef FUNC_NAME
#endif
@@ -1269,7 +1275,7 @@ SCM_DEFINE (scm_accept, "accept", 1, 0, 0,
return SCM_BOOL_F;
SCM_SYSERROR;
}
- newsock = SCM_SOCK_FD_TO_PORT (newfd);
+ newsock = scm_socket_fd_to_port (newfd);
address = _scm_from_sockaddr (&addr, addr_size,
FUNC_NAME);