summaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:25 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:25 -0800
commitdb04688faa20f3576257c0fe41752ec435beab9a (patch)
tree6d638c2e1f65afd5f49d20b2d22ce35bd74705ff /socket.c
parent1edcb9b62a1a520eddae8403c19d841c9b18737f (diff)
downloadscm-fa3c5b99da02d5af2454b1e1cb7bf250c5efdaa2.tar.gz
scm-fa3c5b99da02d5af2454b1e1cb7bf250c5efdaa2.zip
Import Upstream version 5c3upstream/5c3
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/socket.c b/socket.c
index b562fd5..6296b38 100644
--- a/socket.c
+++ b/socket.c
@@ -46,6 +46,12 @@
*/
#include "scm.h"
+
+#ifdef macintosh
+#define SOCKETDEFS
+#include "macsocket.h"
+#endif
+
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -242,8 +248,9 @@ SCM l_servinfo(args)
proto = CAR(proto);
ASSERT(NIMP(proto) && STRINGP(proto), args, ARG2, s_servinfo);
DEFER_INTS;
- if (NIMP(name) && STRINGP(name))
+ if (NIMP(name) && STRINGP(name)) {
SYSCALL(entry = getservbyname(CHARS(name), CHARS(proto)););
+ }
else {
ASSERT(INUMP(proto), proto, ARG1, s_servinfo);
SYSCALL(entry = getservbyport(INUM(proto), CHARS(proto)););
@@ -310,7 +317,11 @@ SCM l_socket(fam, proto)
i_setbuf0(port);
ALLOW_INTS;
if (AF_INET==tp) {
+#ifdef macintosh
+ sd = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&j, sizeof(j));
+#else
sd = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &j, sizeof(j));
+#endif
ASSERT(!sd, port, "could not set socket option", s_socket);
}
return port;
@@ -469,11 +480,15 @@ SCM l_accept(sockpt)
NEWCELL(newpt);
ASSERT(NIMP(sockpt) && OPINPORTP(sockpt), sockpt, ARG1, s_accept);
sadlen=sizeof(sad);
- DEFER_INTS;
SYSCALL(newsd = accept(fileno(STREAM(sockpt)), &sad, &sadlen););
- if (-1==newsd)
+ if (-1==newsd) {
+#ifndef macintosh
if (EWOULDBLOCK != errno) return BOOL_F;
- else wta(sockpt, "couldn't", s_accept);
+ else
+#endif
+ wta(sockpt, "couldn't", s_accept);
+ }
+ DEFER_INTS;
SYSCALL(newfd = fdopen(newsd, "r+"););
if (!newfd) {
close(newsd);
@@ -511,7 +526,7 @@ int sknm_print(exp, port, writing)
sizet sknm_free(p)
CELLPTR p;
{
- must_free(CHARS((SCM)p));
+ must_free(CHARS((SCM)p), sizeof(struct sockaddr));
return sizeof(struct sockaddr);
}
long tc16_sknm;
@@ -558,12 +573,11 @@ SCM maksknm(sad)
{
SCM sknm;
struct sockaddr *msknm;
- NEWCELL(sknm);
DEFER_INTS;
- msknm = (struct sockaddr *)must_malloc(0L+sizeof(struct sockaddr), "sknm");
+ sknm = must_malloc_cell(0L+sizeof(struct sockaddr), "sknm");
+ msknm = (struct sockaddr *)CDR(sknm);
*msknm = *sad;
CAR(sknm) = tc16_sknm;
- SETCDR(sknm, msknm);
ALLOW_INTS;
return sknm;
}