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
# 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
CFLAGS=-I. -pipe -Wall -O2 -pipe -fomit-frame-pointer
#CFLAGS=-I. -pipe -Wall -Os -march=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
#CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall
BYTE_OBJS=$(patsubst byte/%.c,%.o,$(wildcard byte/*.c))
FMT_OBJS=$(patsubst fmt/%.c,%.o,$(wildcard fmt/*.c))
@ -49,6 +49,7 @@ $(BUFFER_OBJS) $(MMAP_OBJS)
%.a:
ar cr $@ $^
-ranlib $@
t: t.o socket.a stralloc.a buffer.a scan.a uint.a mmap.a open.a fmt.a \
str.a byte.a
@ -56,7 +57,32 @@ str.a byte.a
.PHONY: clean tar
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/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include "haveip6.h"
#include "socket.h"
int socket_tcp6(void) {
return socket(PF_INET6,SOCK_STREAM,IPPROTO_TCP);
#ifndef EAFNOSUPPORT
#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/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include "haveip6.h"
#include "socket.h"
int socket_udp6(void) {
return socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP);
#ifndef EAFNOSUPPORT
#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")
int main(int argc,char* argv[]) {
char buf[100];
buf[fmt_ulong(buf,0)]=0;
puts(buf);
#if 0
buffer_putspace(buffer_1);
buffer_flush(buffer_1);
#if 1
buffer_putulong(buffer_1,23);
// buffer_putspace(buffer_1);
buffer_putsflush(buffer_1,"\n");
// buffer_flush(buffer_1);
#endif
#if 0
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