1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-14 23:46:10 +00:00
freebsd-ports/lang/modula-3-lib/files/patch-bj
John Polstra f118640d86 Fix all the paths in context diff headers and remove the Index
lines, since the WORTHLESS, BROKEN new version of patch ignores
them.
1998-01-17 21:12:15 +00:00

439 lines
11 KiB
Plaintext

New wrapper files for network related functions. These are separated so
that they can be easily overridden when SOCKS support is desired.
--- m3/m3core/src/runtime/FreeBSD2/accept.c.orig Thu Oct 24 13:11:22 1996
+++ m3/m3core/src/runtime/FreeBSD2/accept.c Thu Oct 24 12:47:29 1996
@@ -0,0 +1,16 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+m3_accept(int s, struct sockaddr *addr, int *addrlen)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(addr);
+ MAKE_WRITABLE(addrlen);
+ result = accept(s, addr, addrlen);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/bind.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/bind.c Thu Oct 24 12:48:12 1996
@@ -0,0 +1,15 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+m3_bind(int s, const struct sockaddr *name, int namelen)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = bind(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/close.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/close.c Thu Oct 24 12:48:51 1996
@@ -0,0 +1,13 @@
+#include "wrap.h"
+#include <unistd.h>
+
+int
+m3_close(int d)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ result = close(d);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/connect.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/connect.c Thu Oct 24 12:49:40 1996
@@ -0,0 +1,15 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+m3_connect(int s, const struct sockaddr *name, int namelen)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = connect(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/dup.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/dup.c Thu Oct 24 12:50:09 1996
@@ -0,0 +1,13 @@
+#include "wrap.h"
+#include <unistd.h>
+
+int
+m3_dup(int oldd)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ result = dup(oldd);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/dup2.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/dup2.c Thu Oct 24 12:50:28 1996
@@ -0,0 +1,13 @@
+#include "wrap.h"
+#include <unistd.h>
+
+int
+m3_dup2(int oldd, int newd)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ result = dup2(oldd, newd);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/gethostbyaddr.c.orig Thu Oct 24 16:07:10 1996
+++ m3/m3core/src/runtime/FreeBSD2/gethostbyaddr.c Thu Oct 24 16:10:19 1996
@@ -0,0 +1,14 @@
+#include "wrap.h"
+#include <netdb.h>
+
+struct hostent *
+m3_gethostbyaddr(const char *addr, int len, int type)
+{
+ struct hostent *result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(addr);
+ result = gethostbyaddr(addr, len, type);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/gethostbyname.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/gethostbyname.c Thu Oct 24 16:08:41 1996
@@ -0,0 +1,14 @@
+#include "wrap.h"
+#include <netdb.h>
+
+struct hostent *
+m3_gethostbyname(const char *name)
+{
+ struct hostent *result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = gethostbyname(name);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/getpeername.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/getpeername.c Thu Oct 24 12:52:25 1996
@@ -0,0 +1,16 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+m3_getpeername(int s, struct sockaddr *name, int *namelen)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ MAKE_WRITABLE(namelen);
+ result = getpeername(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/getsockname.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/getsockname.c Thu Oct 24 12:52:56 1996
@@ -0,0 +1,16 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+m3_getsockname(int s, struct sockaddr *name, int *namelen)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ MAKE_WRITABLE(namelen);
+ result = getsockname(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/listen.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/listen.c Thu Oct 24 12:53:42 1996
@@ -0,0 +1,14 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+m3_listen(int s, int backlog)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ result = listen(s, backlog);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/read.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/read.c Thu Oct 24 12:55:56 1996
@@ -0,0 +1,15 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <unistd.h>
+
+ssize_t
+m3_read(int d, void *buf, size_t nbytes)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = read(d, buf, nbytes);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/recv.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/recv.c Thu Oct 24 12:56:57 1996
@@ -0,0 +1,15 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+ssize_t
+m3_recv(int s, void *buf, size_t len, int flags)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = recv(s, buf, len, flags);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/recvfrom.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/recvfrom.c Thu Oct 24 12:58:10 1996
@@ -0,0 +1,18 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+ssize_t
+m3_recvfrom(int s, void *buf, size_t len, int flags,
+ struct sockaddr *from, int *fromlen)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ MAKE_WRITABLE(from);
+ MAKE_WRITABLE(fromlen);
+ result = recvfrom(s, buf, len, flags, from, fromlen);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/select.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/select.c Thu Oct 24 12:59:17 1996
@@ -0,0 +1,20 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+int
+m3_select(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(readfds);
+ MAKE_WRITABLE(writefds);
+ MAKE_WRITABLE(exceptfds);
+ MAKE_READABLE(timeout);
+ result = select(nfds, readfds, writefds, exceptfds, timeout);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/send.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/send.c Thu Oct 24 13:00:25 1996
@@ -0,0 +1,15 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+ssize_t
+m3_send(int s, const void *msg, size_t len, int flags)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg);
+ result = send(s, msg, len, flags);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/sendto.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/sendto.c Thu Oct 24 13:01:18 1996
@@ -0,0 +1,17 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+ssize_t
+m3_sendto(int s, const void *msg, size_t len, int flags,
+ const struct sockaddr *to, int tolen)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg);
+ MAKE_READABLE(to);
+ result = sendto(s, msg, len, flags, to, tolen);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/shutdown.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/shutdown.c Thu Oct 24 13:01:40 1996
@@ -0,0 +1,14 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+m3_shutdown(int s, int how)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ result = shutdown(s, how);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/socket.c.orig Thu Oct 24 16:11:12 1996
+++ m3/m3core/src/runtime/FreeBSD2/socket.c Thu Oct 24 16:12:22 1996
@@ -0,0 +1,14 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+m3_socket(int domain, int type, int protocol)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ result = socket(domain, type, protocol);
+ EXIT_CRITICAL;
+ return result;
+}
--- m3/m3core/src/runtime/FreeBSD2/socksconf.h.orig Fri Oct 25 14:05:03 1996
+++ m3/m3core/src/runtime/FreeBSD2/socksconf.h Fri Oct 25 14:05:28 1996
@@ -0,0 +1,6 @@
+/*
+ * Define 0 or 1 of these, to select the variety of SOCKS support you want.
+ */
+#undef HPSOCKS
+#undef SOCKS4
+#undef SOCKS5
--- m3/m3core/src/runtime/FreeBSD2/wrap.h.orig Thu Oct 24 20:50:16 1996
+++ m3/m3core/src/runtime/FreeBSD2/wrap.h Fri Oct 25 14:04:13 1996
@@ -0,0 +1,61 @@
+#include "socksconf.h"
+
+#if defined(HPSOCKS) /* { */
+ #define accept Raccept
+ #define bind Rxbind
+ #define close Rclose
+ #define connect Rconnect
+ #define dup Rdup
+ #define dup2 Rdup2
+ #define gethostbyaddr Rgethostbyaddr
+ #define gethostbyname Rgethostbyname
+ #define getpeername Rgetpeername
+ #define getsockname Rgetsockname
+ #define listen Rlisten
+ #define recv Rrecv
+ #define recvfrom Rrecvfrom
+ #define send Rsend
+ #define sendto Rsendto
+ #define shutdown Rshutdown
+ #define socket Rsocket
+#elif defined(SOCKS4) /* } { */
+ #define accept Raccept
+ #define bind Rbind
+ #define connect Rconnect
+ #define getpeername Rgetpeername
+ #define getsockname Rgetsockname
+ #define listen Rlisten
+ #define select Rselect
+#elif defined(SOCKS5) /* } { */
+ #define accept SOCKSaccept
+ #define bind SOCKSbind
+ #define close SOCKSclose
+ #define connect SOCKSconnect
+ #define dup SOCKSdup
+ #define dup2 SOCKSdup2
+ #define fclose SOCKSfclose
+ #define gethostbyname SOCKSgethostbyname
+ #define getpeername SOCKSgetpeername
+ #define getsockname SOCKSgetsockname
+ #define listen SOCKSlisten
+ #define read SOCKSread
+ #define recv SOCKSrecv
+ #define recvfrom SOCKSrecvfrom
+ #define rresvport SOCKSrresvport
+ #define select SOCKSselect
+ #define send SOCKSsend
+ #define sendto SOCKSsendto
+ #define shutdown SOCKSshutdown
+ #define write SOCKSwrite
+#endif /* } */
+
+extern int RT0u__inCritical;
+#define ENTER_CRITICAL RT0u__inCritical++
+#define EXIT_CRITICAL RT0u__inCritical--
+
+static char RTHeapDepC__c;
+#define MAKE_READABLE(x) \
+ if ((int)x) { RTHeapDepC__c = *(char*)(x); }
+
+#define MAKE_WRITABLE(x) \
+ if ((int)x) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }
--- m3/m3core/src/runtime/FreeBSD2/write.c.orig Thu Oct 24 13:11:23 1996
+++ m3/m3core/src/runtime/FreeBSD2/write.c Thu Oct 24 13:02:24 1996
@@ -0,0 +1,15 @@
+#include "wrap.h"
+#include <sys/types.h>
+#include <unistd.h>
+
+size_t
+m3_write(int fd, const void *buf, int nbytes)
+{
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(buf);
+ result = write(fd, buf, nbytes);
+ EXIT_CRITICAL;
+ return result;
+}