diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:26 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:26 -0800 |
commit | deda2c0fd8689349fea2a900199a76ff7ecb319e (patch) | |
tree | c9726d54a0806a9b0c75e6c82db8692aea0053cf /socket.c | |
parent | 3278b75942bdbe706f7a0fba87729bb1e935b68b (diff) | |
download | scm-deda2c0fd8689349fea2a900199a76ff7ecb319e.tar.gz scm-deda2c0fd8689349fea2a900199a76ff7ecb319e.zip |
Import Upstream version 5d6upstream/5d6
Diffstat (limited to 'socket.c')
-rw-r--r-- | socket.c | 36 |
1 files changed, 21 insertions, 15 deletions
@@ -15,26 +15,26 @@ * the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111, USA. * * As a special exception, the Free Software Foundation gives permission - * for additional uses of the text contained in its release of GUILE. + * for additional uses of the text contained in its release of SCM. * - * The exception is that, if you link the GUILE library with other files + * The exception is that, if you link the SCM library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public License. * Your use of that executable is in no way restricted on account of - * linking the GUILE library code into it. + * linking the SCM library code into it. * * This exception does not however invalidate any other reasons why * the executable file might be covered by the GNU General Public License. * * This exception applies only to the code released by the - * Free Software Foundation under the name GUILE. If you copy + * Free Software Foundation under the name SCM. If you copy * code from other Free Software Foundation releases into a copy of - * GUILE, as the General Public License permits, the exception does + * SCM, as the General Public License permits, the exception does * not apply to the code that you add in this way. To avoid misleading * anyone as to the status of such modified files, you must delete * this exception notice from them. * - * If you write modifications of your own for GUILE, it is your choice + * If you write modifications of your own for SCM, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. */ @@ -69,6 +69,9 @@ # ifdef SVR4 # include <unistd.h> # endif +# ifdef __OpenBSD__ +# include <unistd.h> +# endif #endif /* STDC_HEADERS */ static char s_inetaddr[] = "inet:string->address"; @@ -313,9 +316,8 @@ SCM l_socket(fam, proto) close(sd); wta(MAKINUM(sd), (char *)NALLOC, s_port_type); } - CAR(port) = scm_port_entry(tc_socket, BUF0); + port = scm_port_entry(f, tc_socket, BUF0); SCM_PORTDATA(port) = fam; - SETSTREAM(port, f); i_setbuf0(port); ALLOW_INTS; if (AF_INET==tp) { @@ -354,9 +356,8 @@ SCM l_socketpair(fam, proto) close(sv[1]); wta(MAKINUM(sv[1]), (char *)NALLOC, s_port_type); } - CAR(port[0]) = scm_port_entry(tc16_fport, mode_bits("r+0", (char *)0)); - CAR(port[1]) = scm_port_entry(tc16_fport, mode_bits("r+0", (char *)0)); - SETSTREAM(port[0], f[0]); SETSTREAM(port[1], f[1]); + port[0] = scm_port_entry(f[0], tc16_fport, mode_bits("r+0", (char *)0)); + CAR(port[1]) = scm_port_entry(f[1], tc16_fport, mode_bits("r+0", (char *)0)); i_setbuf0(port[0]); i_setbuf0(port[1]); ALLOW_INTS; return cons(port[0], port[1]); @@ -387,6 +388,7 @@ static char s_connect[] = "socket:connect"; SCM l_connect (sockpt, address, arg) SCM sockpt, address, arg; { + long flags; int sts; ASSERT(NIMP(sockpt) && SOCKP(sockpt), sockpt, ARG1, s_connect); switch SOCKTYP(sockpt) { @@ -419,7 +421,9 @@ SCM l_connect (sockpt, address, arg) break; } if (sts) return BOOL_F; - CAR(sockpt) = scm_port_entry(tc16_fport, mode_bits("r+0", (char *)0)); + flags = tc16_fport | mode_bits("r+0", (char *)0); + SCM_PORTFLAGS(sockpt) = flags; + SCM_SETFLAGS(sockpt, flags); SCM_PORTDATA(sockpt) = cons(address, arg); return sockpt; } @@ -464,13 +468,16 @@ static char s_listen[] = "socket:listen"; SCM l_listen(port, backlog) SCM port, backlog; { + long flags; int sts; ASSERT(NIMP(port) && SOCKP(port), port, ARG1, s_listen); ASSERT(INUMP(backlog), backlog, ARG2, s_listen); SYSCALL(sts = listen(fileno(STREAM(port)), INUM(backlog));); if (sts) return BOOL_F; DEFER_INTS; - CAR(port) = scm_port_entry(tc16_fport, mode_bits("r0", (char *)0)); + flags = tc16_fport | mode_bits("r0", (char *)0); + SCM_PORTFLAGS(port) = flags; + SCM_SETFLAGS(port, flags); ALLOW_INTS; return port; } @@ -500,8 +507,7 @@ SCM l_accept(sockpt) close(newsd); wta(MAKINUM(newsd), (char *)NALLOC, s_port_type); } - CAR(newpt) = scm_port_entry(tc16_fport, mode_bits("r+0", (char *)0)); - SETSTREAM(newpt, newfd); + newpt = scm_port_entry(newfd, tc16_fport, mode_bits("r+0", (char *)0)); i_setbuf0(newpt); ALLOW_INTS; return newpt; |