test for ipv6 and if_name2index and socklen_t.

master
leitner 23 years ago
parent 0d591f3a9b
commit d4753c43f3

@ -2,12 +2,12 @@ all: t byte.a fmt.a scan.a str.a uint.a open.a stralloc.a unix.a socket.a buffer
VPATH=str:byte:fmt:scan:uint:open:stralloc:unix:socket:buffer:mmap VPATH=str:byte:fmt:scan:uint:open:stralloc:unix:socket:buffer:mmap
# comment out the following line if you don't want to build with the
# diet libc (http://www.fefe.de/dietlibc/).
DIET=diet -Os
CC=gcc CC=gcc
CFLAGS=-I. -pipe -Wall -O2 -pipe -fomit-frame-pointer CFLAGS=-I. -pipe -Wall -O2 -pipe -fomit-frame-pointer
#CFLAGS=-I. -pipe -Wall -Os -march=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall #CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall
#CFLAGS=-I. -I../dietlibc/include -pipe -Wall -Os -malign-functions=2 -fschedule-insns2 -g
#CFLAGS=-I../dietlibc/include -I. -pipe -Wall -Os -march=pentiumpro -mcpu=athlon -fomit-frame-pointer -fschedule-insns2 -Wall
#CFLAGS=-I../dietlibc/include -pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall
BYTE_OBJS=$(patsubst byte/%.c,%.o,$(wildcard byte/*.c)) BYTE_OBJS=$(patsubst byte/%.c,%.o,$(wildcard byte/*.c))
FMT_OBJS=$(patsubst fmt/%.c,%.o,$(wildcard fmt/*.c)) FMT_OBJS=$(patsubst fmt/%.c,%.o,$(wildcard fmt/*.c))
@ -49,14 +49,40 @@ $(BUFFER_OBJS) $(MMAP_OBJS)
%.a: %.a:
ar cr $@ $^ ar cr $@ $^
-ranlib $@
t: t.o socket.a stralloc.a buffer.a scan.a uint.a mmap.a open.a fmt.a \ t: t.o socket.a stralloc.a buffer.a scan.a uint.a mmap.a open.a fmt.a \
str.a byte.a str.a byte.a
$(DIET)$(CC) -g -o $@ $^ $(DIET) $(CC) -g -o $@ $^
.PHONY: clean tar .PHONY: clean tar
clean: clean:
rm -f *.o *.a core t rm -f *.o *.a core t haveip6.h haven2i.h
VERSION=libowfat-$(shell head -1 CHANGES|sed 's/://')
CURNAME=$(notdir $(shell pwd))
tar: clean rename
cd ..; tar cvvf $(VERSION).tar.bz2 $(VERSION) --use=bzip2 --exclude CVS
rename:
if test $(CURNAME) != $(VERSION); then cd .. && mv $(CURNAME) $(VERSION); fi
haveip6.h:
-rm -f $@
if $(DIET) $(CC) -c tryip6.c >/dev/null 2>&1; then echo "#define LIBC_HAS_IP6"; fi > $@
haven2i.h:
-rm -f $@
if $(DIET) $(CC) -o t tryn2i.c >/dev/null 2>&1; then echo "#define HAVE_N2I"; fi > $@
havesl.h:
-rm -f $@
if $(DIET) $(CC) -o t trysl.c >/dev/null 2>&1; then echo "#define HAVE_SOCKLEN_T"; fi > $@
socket_accept6.o socket_connect6.o socket_local6.o socket_mchopcount6.o \
socket_mcjoin6.o socket_mcleave6.o socket_mcloop6.o socket_recv6.o \
socket_remote6.o socket_send6.o socket_tcp6.o socket_udp6.o: haveip6.h
socket_getifidx.o socket_getifname.o: haven2i.h
tar:
cd .. && tar cf libowfat.tar.bz2 libowfat --use=bzip2 --exclude CVS

@ -1,2 +0,0 @@
#define LIBC_HAS_IP6

@ -1 +0,0 @@
#define HAVE_N2I

@ -1,9 +1,33 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <errno.h>
#include "haveip6.h"
#include "socket.h" #include "socket.h"
int socket_tcp6(void) { #ifndef EAFNOSUPPORT
return socket(PF_INET6,SOCK_STREAM,IPPROTO_TCP); #define EAFNOSUPPORT EINVAL
#endif
int socket_tcp6(void)
{
#ifdef LIBC_HAS_IP6
int s;
if (noipv6) goto compat;
s = socket(PF_INET6,SOCK_STREAM,0);
if (s == -1) {
if (errno == EINVAL || errno == EAFNOSUPPORT) {
compat:
s=socket(AF_INET,SOCK_STREAM,0);
noipv6=1;
if (s==-1) return -1;
} else
return -1;
}
return s;
#else
return socket_tcp();
#endif
} }

@ -1,9 +1,32 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <errno.h>
#include "haveip6.h"
#include "socket.h" #include "socket.h"
int socket_udp6(void) { #ifndef EAFNOSUPPORT
return socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); #define EAFNOSUPPORT EINVAL
#endif
int socket_udp6(void)
{
#ifdef LIBC_HAS_IP6
int s;
if (noipv6) goto compat;
s = socket(PF_INET6,SOCK_DGRAM,0);
if (s == -1) {
if (errno == EINVAL || errno == EAFNOSUPPORT) {
compat:
s=socket(AF_INET,SOCK_DGRAM,0);
noipv6=1;
if (s==-1) return -1;
} else
return -1;
}
return s;
#else
return socket_udp();
#endif
} }

11
t.c

@ -14,12 +14,11 @@
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
int main(int argc,char* argv[]) { int main(int argc,char* argv[]) {
char buf[100]; #if 1
buf[fmt_ulong(buf,0)]=0; buffer_putulong(buffer_1,23);
puts(buf); // buffer_putspace(buffer_1);
#if 0 buffer_putsflush(buffer_1,"\n");
buffer_putspace(buffer_1); // buffer_flush(buffer_1);
buffer_flush(buffer_1);
#endif #endif
#if 0 #if 0
long a,b,c; long a,b,c;

@ -0,0 +1,8 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
main() {
struct sockaddr_in6 sa;
sa.sin6_family = PF_INET6;
}

@ -0,0 +1,8 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
int main() {
static char ifname[IFNAMSIZ];
char *tmp=if_indextoname(0,ifname);
}

@ -0,0 +1,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
main() {
socklen_t t;
}
Loading…
Cancel
Save