From 8ecb47a6083983eb6fe38aa18adba0c0a80c8d63 Mon Sep 17 00:00:00 2001 From: leitner Date: Mon, 15 Oct 2001 14:34:02 +0000 Subject: [PATCH] bsd and macosx compatibility --- CHANGES | 6 ++++++ mmap.h | 4 ++-- mmap/mmap_shared.c | 2 +- socket/socket_accept4.c | 1 + socket/socket_accept6.c | 2 +- socket/socket_bind4.c | 1 + socket/socket_bind4_reuse.c | 1 + socket/socket_bind6.c | 2 +- socket/socket_bind6_reuse.c | 1 + socket/socket_connect6.c | 3 +-- socket/socket_connected.c | 1 + socket/socket_listen.c | 1 + socket/socket_local6.c | 1 - socket/socket_mcjoin6.c | 2 +- socket/socket_mcleave6.c | 2 +- socket/socket_recv6.c | 2 +- socket/socket_remote6.c | 1 - socket/socket_send6.c | 4 ++-- socket/socket_tryreservein.c | 1 + uint16.h | 4 ++++ uint32.h | 4 ++++ 21 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 4b20fc6..366d527 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +0.8: + BSD compatibility. + fix mmap_shared. + ranlib. + s/EPROTO/EPROTONOSUPPORT/. + 0.7: add buffer_putspace fix b0read prototype in buffer/buffer_0* diff --git a/mmap.h b/mmap.h index 0a9a0e2..e0174d4 100644 --- a/mmap.h +++ b/mmap.h @@ -8,10 +8,10 @@ extern char* mmap_read(const char *filename,unsigned long* filesize); /* open file for writing, mmap whole file privately (copy on write), * close file, write length of map in filesize and return pointer to * map. */ -extern int mmap_write(const char *filename,unsigned long* filesize); +extern char* mmap_write(const char *filename,unsigned long* filesize); /* open file for writing, mmap whole file shared, close file, write * length of map in filesize and return pointer to map. */ -extern int mmap_shared(const char *filename,unsigned long* filesize); +extern char* mmap_shared(const char *filename,unsigned long* filesize); #endif diff --git a/mmap/mmap_shared.c b/mmap/mmap_shared.c index 25365dd..d402c76 100644 --- a/mmap/mmap_shared.c +++ b/mmap/mmap_shared.c @@ -4,7 +4,7 @@ #include "open.h" #include "mmap.h" -extern char* mmap_private(const char* filename,unsigned long* filesize) { +extern char* mmap_shared(const char* filename,unsigned long* filesize) { int fd=open_read(filename); char *map; if (fd>=0) { diff --git a/socket/socket_accept4.c b/socket/socket_accept4.c index ff1189a..b59625f 100644 --- a/socket/socket_accept4.c +++ b/socket/socket_accept4.c @@ -1,3 +1,4 @@ +#include #include #include #include "socket.h" diff --git a/socket/socket_accept6.c b/socket/socket_accept6.c index 48a0b6d..d2f7258 100644 --- a/socket/socket_accept6.c +++ b/socket/socket_accept6.c @@ -1,11 +1,11 @@ #include +#include #include #include #include "byte.h" #include "socket.h" #include "ip6.h" #include "haveip6.h" -#include "error.h" int socket_accept6(int s,char ip[16],uint16 *port,uint32 *scope_id) { diff --git a/socket/socket_bind4.c b/socket/socket_bind4.c index 38f7160..3f43e49 100644 --- a/socket/socket_bind4.c +++ b/socket/socket_bind4.c @@ -1,3 +1,4 @@ +#include #include #include #include "byte.h" diff --git a/socket/socket_bind4_reuse.c b/socket/socket_bind4_reuse.c index 927a635..056a491 100644 --- a/socket/socket_bind4_reuse.c +++ b/socket/socket_bind4_reuse.c @@ -1,3 +1,4 @@ +#include #include #include "socket.h" diff --git a/socket/socket_bind6.c b/socket/socket_bind6.c index e54eb22..f252819 100644 --- a/socket/socket_bind6.c +++ b/socket/socket_bind6.c @@ -26,7 +26,7 @@ int socket_bind6(int s,const char ip[16],uint16 port,uint32 scope_id) return bind(s,(struct sockaddr *) &sa,sizeof sa); #else - errno=EPROTO; + errno=EPROTONOSUPPORT; return -1; #endif } diff --git a/socket/socket_bind6_reuse.c b/socket/socket_bind6_reuse.c index 61fc6e6..d529631 100644 --- a/socket/socket_bind6_reuse.c +++ b/socket/socket_bind6_reuse.c @@ -1,3 +1,4 @@ +#include #include #include "socket.h" diff --git a/socket/socket_connect6.c b/socket/socket_connect6.c index bea5358..0ad886d 100644 --- a/socket/socket_connect6.c +++ b/socket/socket_connect6.c @@ -7,7 +7,6 @@ #include "socket.h" #include "ip6.h" #include "haveip6.h" -#include "error.h" #include "uint32.h" #include "ip4.h" @@ -33,7 +32,7 @@ int socket_connect6(int s,const char ip[16],uint16 port,uint32 scope_id) return connect(s,(struct sockaddr *) &sa,sizeof sa); #else - errno=EPROTO; + errno=EPROTONOSUPPORT; return -1; #endif } diff --git a/socket/socket_connected.c b/socket/socket_connected.c index 4539f2c..5290686 100644 --- a/socket/socket_connected.c +++ b/socket/socket_connected.c @@ -1,3 +1,4 @@ +#include #include #include #include "socket.h" diff --git a/socket/socket_listen.c b/socket/socket_listen.c index 7bca292..5018ff0 100644 --- a/socket/socket_listen.c +++ b/socket/socket_listen.c @@ -1,3 +1,4 @@ +#include #include int socket_listen(int s,unsigned int backlog) { diff --git a/socket/socket_local6.c b/socket/socket_local6.c index ba1e01f..e0de221 100644 --- a/socket/socket_local6.c +++ b/socket/socket_local6.c @@ -6,7 +6,6 @@ #include "socket.h" #include "ip6.h" #include "haveip6.h" -#include "error.h" #include "uint32.h" int socket_local6(int s,char ip[16],uint16 *port,uint32 *scope_id) diff --git a/socket/socket_mcjoin6.c b/socket/socket_mcjoin6.c index e7a59db..135b059 100644 --- a/socket/socket_mcjoin6.c +++ b/socket/socket_mcjoin6.c @@ -28,7 +28,7 @@ int socket_mcjoin6(int s,const char ip[16],int interface) opt.ipv6mr_interface=interface; return setsockopt(s,IPPROTO_IPV6,IPV6_ADD_MEMBERSHIP,&opt,sizeof opt); #else - errno=EPROTO; + errno=EPROTONOSUPPORT; return -1; #endif } diff --git a/socket/socket_mcleave6.c b/socket/socket_mcleave6.c index a5ce240..d842044 100644 --- a/socket/socket_mcleave6.c +++ b/socket/socket_mcleave6.c @@ -28,7 +28,7 @@ int socket_mcleave6(int s,const char ip[16]) opt.ipv6mr_interface=0; return setsockopt(s,IPPROTO_IPV6,IPV6_DROP_MEMBERSHIP,&opt,sizeof opt); #else - errno=EPROTO; + errno=EPROTONOSUPPORT; return -1; #endif } diff --git a/socket/socket_recv6.c b/socket/socket_recv6.c index 2901596..826939c 100644 --- a/socket/socket_recv6.c +++ b/socket/socket_recv6.c @@ -1,11 +1,11 @@ #include +#include #include #include #include "byte.h" #include "socket.h" #include "ip6.h" #include "haveip6.h" -#include "error.h" int socket_recv6(int s,char *buf,unsigned int len,char ip[16],uint16 *port,uint32 *scope_id) { diff --git a/socket/socket_remote6.c b/socket/socket_remote6.c index 6d80aff..f8c16e1 100644 --- a/socket/socket_remote6.c +++ b/socket/socket_remote6.c @@ -6,7 +6,6 @@ #include "socket.h" #include "ip6.h" #include "haveip6.h" -#include "error.h" #include "uint32.h" int socket_remote6(int s,char ip[16],uint16 *port,uint32 *scope_id) diff --git a/socket/socket_send6.c b/socket/socket_send6.c index 5634686..977397c 100644 --- a/socket/socket_send6.c +++ b/socket/socket_send6.c @@ -26,7 +26,7 @@ int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 if (byte_equal(ip,16,V6loopback)) return socket_send4(s,buf,len,ip4loopback,port); #ifdef LIBC_HAS_IP6 - errno=EPROTO; + errno=EPROTONOSUPPORT; return -1; } si.sin6_family = AF_INET6; @@ -34,7 +34,7 @@ int socket_send6(int s,const char *buf,unsigned int len,const char ip[16],uint16 byte_copy((char *) &si.sin6_addr,16,ip); return sendto(s,buf,len,0,(struct sockaddr *) &si,sizeof si); #else - errno=EPROTO; + errno=EPROTONOSUPPORT; return -1; #endif } diff --git a/socket/socket_tryreservein.c b/socket/socket_tryreservein.c index 4093019..a481c20 100644 --- a/socket/socket_tryreservein.c +++ b/socket/socket_tryreservein.c @@ -1,3 +1,4 @@ +#include #include #include "socket.h" diff --git a/uint16.h b/uint16.h index 53ba710..42d4597 100644 --- a/uint16.h +++ b/uint16.h @@ -5,6 +5,10 @@ typedef unsigned short uint16; +#ifndef __linux__ +#define NO_UINT16_MACROS +#endif + #ifdef NO_UINT16_MACROS extern void uint16_pack(char *out,uint16 in); extern void uint16_pack_big(char *out,uint16 in); diff --git a/uint32.h b/uint32.h index d0073ea..609eeef 100644 --- a/uint32.h +++ b/uint32.h @@ -3,6 +3,10 @@ typedef unsigned int uint32; +#ifndef __linux__ +#define NO_UINT32_MACROS +#endif + #ifdef NO_UINT32_MACROS extern void uint32_pack(char *out,uint32 in); extern void uint32_pack_big(char *out,uint32 in);