Removed remaining define-foreign. Network code is cig-less now.

This commit is contained in:
mainzelm 2001-08-08 11:54:04 +00:00
parent c9d6b41e58
commit fa78232f3d
5 changed files with 76 additions and 133 deletions

View File

@ -122,7 +122,7 @@ SCSHOBJS = \
scsh/machine/time_dep1.o \ scsh/machine/time_dep1.o \
scsh/signals1.o \ scsh/signals1.o \
scsh/machine/libansi.o \ scsh/machine/libansi.o \
scsh/network.o scsh/network1.o \ scsh/network1.o \
scsh/putenv.o \ scsh/putenv.o \
scsh/rx/re1.o \ scsh/rx/re1.o \
scsh/select.o scsh/select1.o \ scsh/select.o scsh/select1.o \
@ -136,7 +136,7 @@ SCSHOBJS = \
scsh/regexp/libregex.a scsh/regexp/libregex.a
SCSH_INITIALIZERS = s48_init_syslog s48_init_userinfo s48_init_sighandlers \ SCSH_INITIALIZERS = s48_init_syslog s48_init_userinfo s48_init_sighandlers \
s48_init_re_low s48_init_syscalls2 s48_init_re_low s48_init_syscalls2 s48_init_network
UNIX_OBJS = c/unix/misc.o c/unix/io.o c/unix/fd-io.o c/unix/event.o UNIX_OBJS = c/unix/misc.o c/unix/io.o c/unix/fd-io.o c/unix/event.o
@ -161,7 +161,7 @@ enough: $(VM) $(IMAGE) go $(LIBCIG) scsh $(LIBSCSH) $(LIBSCSHVM)
# Files generated by cig need their init functions called. # Files generated by cig need their init functions called.
CIGGEDINIT = s48_init_flock s48_init_network s48_init_select \ CIGGEDINIT = s48_init_flock s48_init_select \
s48_init_syscalls s48_init_tty s48_init_time s48_init_syscalls s48_init_tty s48_init_time
# -------------------- # --------------------
@ -224,10 +224,10 @@ ADDITIONAL_INITIALIZER = s48_init_additional_inits
scsh/dirstuff1.o: scsh/dirstuff1.h scsh/dirstuff1.o: scsh/dirstuff1.h
scsh/userinfo1.o: scsh/userinfo1.h scsh/userinfo1.o: scsh/userinfo1.h
scsh/network1o: scsh/network1.h
scsh/fdports1.o scsh/fdports.o: scsh/fdports1.h scsh/fdports1.o scsh/fdports.o: scsh/fdports1.h
scsh/flock1.o scsh/flock.o: scsh/flock1.h scsh/flock1.o scsh/flock.o: scsh/flock1.h
scsh/network1.o scsh/network.o: scsh/network1.h
scsh/select1.o scsh/select.o: scsh/select1.h scsh/select1.o scsh/select.o: scsh/select1.h
scsh/syscalls1.o scsh/syscalls.o: scsh/syscalls1.h scsh/syscalls1.o scsh/syscalls.o: scsh/syscalls1.h
scsh/time1.o scsh/time.o: scsh/time1.h scsh/time1.o scsh/time.o: scsh/time1.h
@ -420,7 +420,7 @@ clean-cig:
-rm -f cig/*.o $(CIG) $(CIG).image $(LIBCIG) -rm -f cig/*.o $(CIG) $(CIG).image $(LIBCIG)
clean-scm2c: clean-scm2c:
rm -f scsh/flock.c scsh/network.c \ rm -f scsh/flock.c \
scsh/select.c scsh/syscalls.c scsh/tty.c scsh/time.c scsh/select.c scsh/syscalls.c scsh/tty.c scsh/time.c
distclean: clean distclean: clean
@ -788,7 +788,6 @@ SCHEME =scsh/awk.scm \
cig/libcig.c: cig/libcig.scm cig/libcig.c: cig/libcig.scm
scsh/flock.c: scsh/flock.scm scsh/flock.c: scsh/flock.scm
scsh/jcontrol2.c: scsh/jcontrol2.scm scsh/jcontrol2.c: scsh/jcontrol2.scm
scsh/network.c: scsh/network.scm
scsh/select.c: scsh/select.scm scsh/select.c: scsh/select.scm
scsh/syscalls.c: scsh/syscalls.scm scsh/syscalls.c: scsh/syscalls.scm
scsh/tty.c: scsh/tty.scm scsh/tty.c: scsh/tty.scm

View File

@ -1,98 +0,0 @@
/* This is an Scheme48/C interface file,
** automatically generated by a hacked version of cig 3.0.
step 4
*/
#include <stdio.h>
#include <stdlib.h> /* For malloc. */
#include "libcig.h"
#include <sys/types.h>
#include <sys/socket.h>
/* Make sure foreign-function stubs interface to the C funs correctly: */
#include "network1.h"
extern int errno;
extern int h_errno;
#define errno_on_zero_or_false(x) ((x) ? S48_FALSE : s48_enter_fixnum(errno))
#define errno_or_false(x) (((x) == -1) ? s48_enter_fixnum(errno) : S48_FALSE)
#define False_on_zero(x) ((x) ? s48_enter_fixnum(x) : S48_FALSE)
s48_value df_socket(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
{
extern int socket(int , int , int );
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(2);
int r1;
S48_GC_PROTECT_2(mv_vec,ret1);
r1 = socket(s48_extract_fixnum(g1), s48_extract_fixnum(g2), s48_extract_fixnum(g3));
ret1 = errno_or_false(r1);
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_listen(s48_value g1, s48_value g2)
{
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = listen(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
s48_value df_shutdown(s48_value g1, s48_value g2)
{
extern int shutdown(int , int );
s48_value ret1 = S48_FALSE;
S48_DECLARE_GC_PROTECT(1);
int r1;
S48_GC_PROTECT_1(ret1);
r1 = shutdown(s48_extract_fixnum(g1), s48_extract_fixnum(g2));
ret1 = errno_or_false(r1);
S48_GC_UNPROTECT();
return ret1;
}
void s48_init_network(void)
{
S48_EXPORT_FUNCTION(df_socket);
S48_EXPORT_FUNCTION(scheme_bind);
S48_EXPORT_FUNCTION(scheme_connect);
S48_EXPORT_FUNCTION(df_listen);
S48_EXPORT_FUNCTION(scheme_accept);
S48_EXPORT_FUNCTION(scheme_peer_name);
S48_EXPORT_FUNCTION(scheme_socket_name);
S48_EXPORT_FUNCTION(df_shutdown);
S48_EXPORT_FUNCTION(scheme_socket_pair);
S48_EXPORT_FUNCTION(recv_substring);
S48_EXPORT_FUNCTION(send_substring);
S48_EXPORT_FUNCTION(scheme_getsockopt);
S48_EXPORT_FUNCTION(scheme_getsockopt_linger);
S48_EXPORT_FUNCTION(scheme_getsockopt_timeout);
S48_EXPORT_FUNCTION(scheme_setsockopt);
S48_EXPORT_FUNCTION(scheme_setsockopt_linger);
S48_EXPORT_FUNCTION(scheme_setsockopt_timeout);
S48_EXPORT_FUNCTION(scheme_host_address2host_info);
S48_EXPORT_FUNCTION(scheme_host_name2host_info);
S48_EXPORT_FUNCTION(scheme_net_address2net_info);
S48_EXPORT_FUNCTION(scheme_net_name2net_info);
S48_EXPORT_FUNCTION(scheme_serv_port2serv_info);
S48_EXPORT_FUNCTION(scheme_serv_name2serv_info);
S48_EXPORT_FUNCTION(scheme_proto_num2proto_info);
S48_EXPORT_FUNCTION(scheme_proto_name2proto_info);
}

View File

@ -197,15 +197,9 @@
(dup->outport port)))) (dup->outport port))))
(make-socket pf in out))) (make-socket pf in out)))
(define-foreign %socket/errno (define-stubless-foreign %socket/eintr (pf type protocol) "scsh_socket")
(socket (fixnum pf)
(fixnum type)
(fixnum protocol))
(multi-rep (to-scheme fixnum errno_or_false)
fixnum))
(define-errno-syscall (%socket pf type protocol) %socket/errno (define-retrying-syscall %socket %socket/eintr)
sockfd)
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;;; close syscall ;;; close syscall
@ -284,13 +278,8 @@
(else (else
(%listen (socket->fdes sock) backlog)))) (%listen (socket->fdes sock) backlog))))
(define-foreign %listen/errno (define-stubless-foreign %listen/eintr (sockfd backlog) "scsh_listen")
(listen (fixnum sockfd) ; socket fdes (define-retrying-syscall %listen %listen/eintr)
(fixnum backlog)) ; backlog
no-declare ; for Linux
(to-scheme fixnum errno_or_false))
(define-errno-syscall (%listen sockfd backlog) %listen/errno)
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;;; accept syscall ;;; accept syscall
@ -357,13 +346,8 @@
(else (else
(%shutdown (socket->fdes sock) how)))) (%shutdown (socket->fdes sock) how))))
(define-foreign %shutdown/errno (define-stubless-foreign %shutdown/eintr (sockfd how) "scsh_shutdown")
(shutdown (fixnum sockfd) (define-retrying-syscall %shutdown %shutdown/eintr)
(fixnum how))
(to-scheme fixnum errno_or_false))
(define-errno-syscall
(%shutdown sock how) %shutdown/errno)
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;;; socketpair syscall ;;; socketpair syscall

View File

@ -21,6 +21,17 @@
#include "network1.h" #include "network1.h"
#include "scheme48.h" #include "scheme48.h"
s48_value scsh_socket (s48_value sch_pf, s48_value sch_type,
s48_value sch_protocol)
{
int retval = socket (s48_extract_integer (sch_pf),
s48_extract_integer (sch_type),
s48_extract_integer (sch_protocol));
if (retval == -1)
s48_raise_os_error_3 (errno, sch_pf, sch_type, sch_protocol);
return s48_enter_fixnum (retval);
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
s48_value scheme_bind(s48_value sock, s48_value family, s48_value scheme_name) s48_value scheme_bind(s48_value sock, s48_value family, s48_value scheme_name)
{ {
@ -133,6 +144,15 @@ s48_value scheme_connect(s48_value sock, s48_value family, s48_value scheme_name
s48_raise_argtype_error (family); /* error unknown address family */ s48_raise_argtype_error (family); /* error unknown address family */
} }
} }
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
s48_value scsh_listen (s48_value sch_sockfd, s48_value sch_backlog)
{
int retval = listen (s48_extract_fixnum (sch_sockfd),
s48_extract_integer (sch_backlog));
if (retval == -1)
s48_raise_os_error_2(errno, sch_sockfd, sch_backlog);
return S48_UNSPECIFIC;
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
s48_value scheme_accept(s48_value sockfd_tagged, s48_value family) s48_value scheme_accept(s48_value sockfd_tagged, s48_value family)
@ -226,6 +246,15 @@ s48_value scheme_peer_name(s48_value sock, s48_value family)
s48_raise_argtype_error (family); /* error unknown address family */ s48_raise_argtype_error (family); /* error unknown address family */
} }
} }
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
s48_value scsh_shutdown (s48_value sch_sockfd, s48_value sch_how)
{
int retval = shutdown (s48_extract_fixnum (sch_sockfd),
s48_extract_integer (sch_how));
if (retval == -1)
s48_raise_os_error_2 (errno, sch_sockfd, sch_how);
return S48_UNSPECIFIC;
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
s48_value scheme_socket_name(s48_value sock, s48_value family) s48_value scheme_socket_name(s48_value sock, s48_value family)
@ -763,5 +792,31 @@ s48_value scheme_proto_name2proto_info(s48_value in_name)
return protoent2protocol_info (proto); return protoent2protocol_info (proto);
} }
void s48_init_network(void)
{
S48_EXPORT_FUNCTION(scsh_socket);
S48_EXPORT_FUNCTION(scheme_bind);
S48_EXPORT_FUNCTION(scheme_connect);
S48_EXPORT_FUNCTION(scsh_listen);
S48_EXPORT_FUNCTION(scheme_accept);
S48_EXPORT_FUNCTION(scheme_peer_name);
S48_EXPORT_FUNCTION(scheme_socket_name);
S48_EXPORT_FUNCTION(scsh_shutdown);
S48_EXPORT_FUNCTION(scheme_socket_pair);
S48_EXPORT_FUNCTION(recv_substring);
S48_EXPORT_FUNCTION(send_substring);
S48_EXPORT_FUNCTION(scheme_getsockopt);
S48_EXPORT_FUNCTION(scheme_getsockopt_linger);
S48_EXPORT_FUNCTION(scheme_getsockopt_timeout);
S48_EXPORT_FUNCTION(scheme_setsockopt);
S48_EXPORT_FUNCTION(scheme_setsockopt_linger);
S48_EXPORT_FUNCTION(scheme_setsockopt_timeout);
S48_EXPORT_FUNCTION(scheme_host_address2host_info);
S48_EXPORT_FUNCTION(scheme_host_name2host_info);
S48_EXPORT_FUNCTION(scheme_net_address2net_info);
S48_EXPORT_FUNCTION(scheme_net_name2net_info);
S48_EXPORT_FUNCTION(scheme_serv_port2serv_info);
S48_EXPORT_FUNCTION(scheme_serv_name2serv_info);
S48_EXPORT_FUNCTION(scheme_proto_num2proto_info);
S48_EXPORT_FUNCTION(scheme_proto_name2proto_info);
}

View File

@ -1,14 +1,21 @@
/* Exports from network1.c. */ /* Exports from network1.c. */
s48_value scsh_socket (s48_value sch_pf, s48_value sch_type,
s48_value sch_protocol);
s48_value scheme_bind(s48_value sockfd, s48_value family, s48_value scheme_name); s48_value scheme_bind(s48_value sockfd, s48_value family, s48_value scheme_name);
s48_value scheme_connect(s48_value sock, s48_value family, s48_value scheme_connect(s48_value sock, s48_value family,
s48_value scheme_name); s48_value scheme_name);
s48_value scsh_listen (s48_value sch_sockfd, s48_value sch_backlog);
s48_value scheme_accept(s48_value sockfd, s48_value family); s48_value scheme_accept(s48_value sockfd, s48_value family);
s48_value scheme_peer_name(s48_value sockfd, s48_value family); s48_value scheme_peer_name(s48_value sockfd, s48_value family);
s48_value scsh_shutdown (s48_value sch_sockfd, s48_value sch_how);
s48_value scheme_socket_name(s48_value sockfd, s48_value family); s48_value scheme_socket_name(s48_value sockfd, s48_value family);
s48_value scheme_socket_pair(s48_value type); s48_value scheme_socket_pair(s48_value type);
@ -57,8 +64,6 @@ s48_value scheme_net_address2net_info(s48_value net_addr);
s48_value scheme_net_name2net_info(s48_value scheme_name); s48_value scheme_net_name2net_info(s48_value scheme_name);
/* in_port should be declared u_short, but cig doesn't know about them. */
s48_value scheme_serv_port2serv_info(s48_value in_port, s48_value scheme_serv_port2serv_info(s48_value in_port,
s48_value in_proto); s48_value in_proto);
@ -69,6 +74,4 @@ s48_value scheme_proto_num2proto_info(s48_value in_proto);
s48_value scheme_proto_name2proto_info(s48_value name); s48_value scheme_proto_name2proto_info(s48_value name);
void set_longvec_carriers(s48_value svec, long const * const * cvec); void s48_init_network(void);
s48_value veclen(const long *vec);