diff options
author | 1998-07-22 11:33:37 +0000 | |
---|---|---|
committer | 1998-07-22 11:33:37 +0000 | |
commit | 90c76a2a1a061833c6f55ae25c1f003cb9a406c4 (patch) | |
tree | 4d555fd9f4d8f06a5c08fb93a3f364b1e1e1f773 /lib/libpthread | |
parent | o removed more unused or old, left over files (diff) | |
download | wireguard-openbsd-90c76a2a1a061833c6f55ae25c1f003cb9a406c4.tar.xz wireguard-openbsd-90c76a2a1a061833c6f55ae25c1f003cb9a406c4.zip |
o for some reason fprintf.c started to conflict with the fprintf defn
in xprintf.c - removed fprintf.c from the sources list for now.
o tidied up tests/Makefile and swapped some printf's for perror's in
a couple of the tests. accept() is still generating an error, but
at least we can see the errno value :)
Diffstat (limited to 'lib/libpthread')
-rw-r--r-- | lib/libpthread/stdio/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libpthread/tests/Makefile | 204 | ||||
-rw-r--r-- | lib/libpthread/tests/test_sock_1.c | 2 | ||||
-rw-r--r-- | lib/libpthread/tests/test_sock_2.c | 18 | ||||
-rw-r--r-- | lib/libpthread/tests/test_sock_2a.c | 12 |
5 files changed, 103 insertions, 137 deletions
diff --git a/lib/libpthread/stdio/Makefile.inc b/lib/libpthread/stdio/Makefile.inc index 8f0e0a5d30a..9475a05208a 100644 --- a/lib/libpthread/stdio/Makefile.inc +++ b/lib/libpthread/stdio/Makefile.inc @@ -1,5 +1,5 @@ # from: @(#)Makefile.inc 5.7 (Berkeley) 6/27/91 -# $Id: Makefile.inc,v 1.2 1998/07/21 16:28:45 peter Exp $ +# $Id: Makefile.inc,v 1.3 1998/07/22 11:33:37 peter Exp $ .PATH: ${.CURDIR}/stdio @@ -7,7 +7,7 @@ SRCS+= clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c \ fgetline.c fgetpos.c fgets.c fileno.c findfp.c flags.c fopen.c \ - fprintf.c fpurge.c fputc.c fputs.c fread.c freopen.c fscanf.c \ + fpurge.c fputc.c fputs.c fread.c freopen.c fscanf.c \ fseek.c fsetpos.c ftell.c funopen.c fvwrite.c fwalk.c fwrite.c \ getc.c getchar.c gets.c getw.c makebuf.c perror.c putc.c \ putchar.c puts.c putw.c refill.c remove.c rewind.c rget.c scanf.c \ diff --git a/lib/libpthread/tests/Makefile b/lib/libpthread/tests/Makefile index 97f81b5d4e3..bff425a8155 100644 --- a/lib/libpthread/tests/Makefile +++ b/lib/libpthread/tests/Makefile @@ -8,10 +8,9 @@ # -Initial cut for pthreads. # -CDEBUGFLAGS = -g -O2 -Werror INCLUDES= -I/usr/include/pthread -CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) -DSRCDIR="\"${.CURDIR}\"" -LIBS = -static -lm -lgcc -L${.CURDIR}/../obj.${MACHINE}/ -lpthread +CFLAGS = -O2 -g -Werror $(INCLUDES) -DSRCDIR="\"${.CURDIR}\"" +LDFLAGS = -static -lm -lgcc -L../obj.${MACHINE}/ -lpthread # This list used to include test_select, but that test doesn't terminate. TESTS = test_create test_pthread_join test_switch test_sleep test_readdir \ @@ -23,8 +22,17 @@ TESTS = test_create test_pthread_join test_switch test_sleep test_readdir \ BENCHMARKS = p_bench_read p_bench_mutex p_bench_yield \ p_bench_getpid p_bench_pthread_create +OBJS= ${TESTS:=.o} +BOBJS= ${BENCHMARKS:=.o} + all : $(TESTS) $(BENCHMARKS) +${TESTS}: ${OBJS} + ${CC} ${CFLAGS} -o ${.TARGET} ${.TARGET:=.o} ${LDFLAGS} + +${BENCHMARKS}: ${BOBJS} + ${CC} ${CFLAGS} -o ${.TARGET} ${.TARGET:=.o} ${LDFLAGS} + check : $(TESTS) set -e ; \ for i in $(TESTS) ; do \ @@ -32,11 +40,6 @@ check : $(TESTS) ./$$i ; \ done -# More flags -ADDITIONALFLAGS = -DPTHREAD_INITIAL_PORT -################################################################################ -# - clean: rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout @@ -45,114 +48,77 @@ depend: (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp cp maketmp Makefile -install: - -realclean: clean - rm -f Makefile - -.c.o: - $(CC) $(CFLAGS) -c $< - -Makefile: Makefile.in - (cd .. ; sh config.status) - -test_create : test_create.o ../libpthread.a - $(CC) $(CFLAGS) -o test_create test_create.o $(LIBS) - -test_pthread_join : test_pthread_join.o ../libpthread.a - $(CC) $(CFLAGS) -o test_pthread_join test_pthread_join.o $(LIBS) - -test_switch : test_switch.o ../libpthread.a - $(CC) $(CFLAGS) -o test_switch test_switch.o $(LIBS) - -test_sleep : test_sleep.o ../libpthread.a - $(CC) $(CFLAGS) -o test_sleep test_sleep.o $(LIBS) - -test_readdir : test_readdir.o ../libpthread.a - $(CC) $(CFLAGS) -o test_readdir test_readdir.o $(LIBS) - -test_fork : test_fork.o ../libpthread.a - $(CC) $(CFLAGS) -o test_fork test_fork.o $(LIBS) - -test_execve : test_execve.o ../libpthread.a - $(CC) $(CFLAGS) -o test_execve test_execve.o $(LIBS) - -test_preemption : test_preemption.o ../libpthread.a - $(CC) $(CFLAGS) -o test_preemption test_preemption.o $(LIBS) - -test_preemption_float : test_preemption_float.o ../libpthread.a - $(CC) $(CFLAGS) -o test_preemption_float test_preemption_float.o $(LIBS) - -test_stdio_1 : test_stdio_1.o ../libpthread.a - $(CC) $(CFLAGS) -o test_stdio_1 test_stdio_1.o $(LIBS) - -test_sock_1 : test_sock_1.o ../libpthread.a - $(CC) $(CFLAGS) -o test_sock_1 test_sock_1.o $(LIBS) - -test_sock_2 : test_sock_2a test_sock_2.o ../libpthread.a - $(CC) $(CFLAGS) -o test_sock_2 test_sock_2.o $(LIBS) - -test_sock_2a : test_sock_2a.o ../libpthread.a - $(CC) $(CFLAGS) -o test_sock_2a test_sock_2a.o $(LIBS) - -test_pthread_mutex : test_pthread_mutex.o ../libpthread.a - $(CC) $(CFLAGS) -o test_pthread_mutex test_pthread_mutex.o $(LIBS) - -test_pthread_cond_timedwait : test_pthread_cond_timedwait.o ../libpthread.a - $(CC) $(CFLAGS) -o test_pthread_cond_timedwait test_pthread_cond_timedwait.o $(LIBS) - -test_netdb : test_netdb.o ../libpthread.a - $(CC) $(CFLAGS) -o test_netdb test_netdb.o $(LIBS) - -test_select : test_select.o ../obj/libpthread.a - $(CC) $(CFLAGS) -o test_select test_select.o $(LIBS) - -test_pw : test_pw.o ../obj/libpthread.a - $(CC) $(CFLAGS) -o test_pw test_pw.o $(LIBS) - -test_cwd : test_cwd.o ../obj/libpthread.a - $(CC) $(CFLAGS) -o test_cwd test_cwd.o $(LIBS) - -p_bench_read : p_bench_read.o ../libpthread.a - $(CC) $(CFLAGS) -o p_bench_read p_bench_read.o $(LIBS) - -p_bench_semaphore : p_bench_semaphore.o ../libpthread.a - $(CC) $(CFLAGS) -o p_bench_semaphore p_bench_semaphore.o $(LIBS) - -p_bench_mutex : p_bench_mutex.o ../libpthread.a - $(CC) $(CFLAGS) -o p_bench_mutex p_bench_mutex.o $(LIBS) - -p_bench_yield : p_bench_yield.o ../libpthread.a - $(CC) $(CFLAGS) -o p_bench_yield p_bench_yield.o $(LIBS) - -p_bench_getpid : p_bench_getpid.o ../libpthread.a - $(CC) $(CFLAGS) -o p_bench_getpid p_bench_getpid.o $(LIBS) - -p_bench_pthread_create : p_bench_pthread_create.o ../libpthread.a - $(CC) $(CFLAGS) -o p_bench_pthread_create p_bench_pthread_create.o $(LIBS) - -test_create.o : test_create.c -test_pthread_join.o : test_pthread_join.c -test_switch.o : test_switch.c -test_sleep.o : test_sleep.c -test_readdir.o : test_readdir.c -test_fork.o : test_fork.c -test_execve.o : test_execve.c -test_preemption.o : test_preemption.c -test_preemption_float.o : test_preemption_float.c -test_sock_1.o : test_sock_1.c -test_sock_2.o : test_sock_2.c -test_sock_3.o : test_sock_3.c -test_stdio_1.o : test_stdio_1.c -test_pthread_mutex.o : test_pthread_mutex.c -test_pthread_cond_timedwait.o : test_pthread_cond_timedwait.c -p_bench_read.o : p_bench_read.c -p_bench_semaphore.o : p_bench_semaphore.c -p_bench_mutex.o : p_bench_mutex.c -p_bench_yield.o : p_bench_yield.c -p_bench_getpid.o : p_bench_getpid.c -p_bench_pthread_create.o : p_bench_pthread_create.c - -################################################################################ -### Do not remove the following line. It is for depend ######################### -### Dependencies: +#test_create : test_create.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_create test_create.o $(LIBS) +# +#test_pthread_join : test_pthread_join.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_pthread_join test_pthread_join.o $(LIBS) +# +#test_switch : test_switch.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_switch test_switch.o $(LIBS) +# +#test_sleep : test_sleep.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_sleep test_sleep.o $(LIBS) +# +#test_readdir : test_readdir.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_readdir test_readdir.o $(LIBS) +# +#test_fork : test_fork.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_fork test_fork.o $(LIBS) +# +#test_execve : test_execve.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_execve test_execve.o $(LIBS) +# +#test_preemption : test_preemption.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_preemption test_preemption.o $(LIBS) +# +#test_preemption_float : test_preemption_float.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_preemption_float test_preemption_float.o $(LIBS) +# +#test_stdio_1 : test_stdio_1.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_stdio_1 test_stdio_1.o $(LIBS) +# +#test_sock_1 : test_sock_1.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_sock_1 test_sock_1.o $(LIBS) +# +#test_sock_2 : test_sock_2a test_sock_2.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_sock_2 test_sock_2.o $(LIBS) +# +#test_sock_2a : test_sock_2a.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_sock_2a test_sock_2a.o $(LIBS) +# +#test_pthread_mutex : test_pthread_mutex.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_pthread_mutex test_pthread_mutex.o $(LIBS) +# +#test_pthread_cond_timedwait : test_pthread_cond_timedwait.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_pthread_cond_timedwait test_pthread_cond_timedwait.o $(LIBS) +# +#test_netdb : test_netdb.o ../libpthread.a +# $(CC) $(CFLAGS) -o test_netdb test_netdb.o $(LIBS) +# +#test_select : test_select.o ../obj/libpthread.a +# $(CC) $(CFLAGS) -o test_select test_select.o $(LIBS) +# +#test_pw : test_pw.o ../obj/libpthread.a +# $(CC) $(CFLAGS) -o test_pw test_pw.o $(LIBS) +# +#test_cwd : test_cwd.o ../obj/libpthread.a +# $(CC) $(CFLAGS) -o test_cwd test_cwd.o $(LIBS) +# +#p_bench_read : p_bench_read.o ../libpthread.a +# $(CC) $(CFLAGS) -o p_bench_read p_bench_read.o $(LIBS) +# +#p_bench_semaphore : p_bench_semaphore.o ../libpthread.a +# $(CC) $(CFLAGS) -o p_bench_semaphore p_bench_semaphore.o $(LIBS) +# +#p_bench_mutex : p_bench_mutex.o ../libpthread.a +# $(CC) $(CFLAGS) -o p_bench_mutex p_bench_mutex.o $(LIBS) +# +#p_bench_yield : p_bench_yield.o ../libpthread.a +# $(CC) $(CFLAGS) -o p_bench_yield p_bench_yield.o $(LIBS) +# +#p_bench_getpid : p_bench_getpid.o ../libpthread.a +# $(CC) $(CFLAGS) -o p_bench_getpid p_bench_getpid.o $(LIBS) +# +#p_bench_pthread_create : p_bench_pthread_create.o ../libpthread.a +# $(CC) $(CFLAGS) -o p_bench_pthread_create p_bench_pthread_create.o $(LIBS) diff --git a/lib/libpthread/tests/test_sock_1.c b/lib/libpthread/tests/test_sock_1.c index e23755a67dc..a7fd0c0d454 100644 --- a/lib/libpthread/tests/test_sock_1.c +++ b/lib/libpthread/tests/test_sock_1.c @@ -131,7 +131,7 @@ void * sock_accept(void* arg) a_sin_size = sizeof(a_sin); printf("This should be message #1\n"); if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) { - printf("Error: sock_accept:accept()\n"); + perror("Error: sock_accept:accept()"); exit(1); } diff --git a/lib/libpthread/tests/test_sock_2.c b/lib/libpthread/tests/test_sock_2.c index 5ec82fd7499..8f60c0b66fa 100644 --- a/lib/libpthread/tests/test_sock_2.c +++ b/lib/libpthread/tests/test_sock_2.c @@ -41,7 +41,7 @@ void * sock_accept(void* arg) a_sout.sin_addr.s_addr = INADDR_ANY; if ((a_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("Error: sock_accept:socket()\n"); + perror("Error: sock_accept:socket()"); exit(1); } @@ -50,19 +50,19 @@ void * sock_accept(void* arg) a_sout.sin_port = htons((++port)); continue; } - printf("Error: sock_accept:bind()\n"); + perror("Error: sock_accept:bind()"); exit(1); } if (listen(a_fd, 2)) { - printf("Error: sock_accept:listen()\n"); + perror("Error: sock_accept:listen()"); exit(1); } a_sin_size = sizeof(a_sin); printf("This should be message #1\n"); if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) { - printf("Error: sock_accept:accept()\n"); + perror("Error: sock_accept:accept()"); exit(1); } close(fd); @@ -72,18 +72,18 @@ void * sock_accept(void* arg) memset(&a_sin, 0, sizeof(a_sin)); printf("This should be message #4\n"); if ((fd = accept(a_fd, &a_sin, &a_sin_size)) < 0) { - printf("Error: sock_accept:accept()\n"); + perror("Error: sock_accept:accept()"); exit(1); } /* Setup a write thread */ if (pthread_create(&thread, NULL, sock_write, &fd)) { - printf("Error: sock_accept:pthread_create(sock_write)\n"); + perror("Error: sock_accept:pthread_create(sock_write)"); exit(1); } if ((tmp = read(fd, buf, 1024)) <= 0) { tmp = read(fd, buf, 1024); - printf("Error: sock_accept:read() == %d\n", tmp); + printf("Error: sock_accept:read() == %d %s\n", tmp, strerror(errno)); exit(1); } printf("%s\n", buf); @@ -97,7 +97,7 @@ main() switch(fork()) { case -1: - printf("Error: main:fork()\n"); + perror("Error: main:fork()"); break; case 0: execl("test_sock_2a", "test_sock_2a", "fork okay", NULL); @@ -109,7 +109,7 @@ main() setbuf(stderr, NULL); if (pthread_create(&thread, NULL, sock_accept, (void *)0xdeadbeaf)) { - printf("Error: main:pthread_create(sock_accept)\n"); + perror("Error: main:pthread_create(sock_accept)"); exit(1); } pthread_exit(NULL); diff --git a/lib/libpthread/tests/test_sock_2a.c b/lib/libpthread/tests/test_sock_2a.c index 9f767b7c675..7ff73bcfc76 100644 --- a/lib/libpthread/tests/test_sock_2a.c +++ b/lib/libpthread/tests/test_sock_2a.c @@ -31,33 +31,33 @@ void * sock_connect(void* arg) a_sout.sin_addr.s_addr = htonl(0x7f000001); /* loopback */ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("Error: sock_connect:socket()\n"); + perror("Error: sock_connect:socket()"); exit(1); } printf("This should be message #2\n"); if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) { - printf("Error: sock_connect:connect()\n"); + perror("Error: sock_connect:connect()"); exit(1); } close(fd); if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("Error: sock_connect:socket()\n"); + perror("Error: sock_connect:socket()"); exit(1); } printf("This should be message #3\n"); if (connect(fd, (struct sockaddr *) &a_sout, sizeof(a_sout)) < 0) { - printf("Error: sock_connect:connect()\n"); + perror("Error: sock_connect:connect()"); exit(1); } /* Ensure sock_read runs again */ if ((tmp = read(fd, buf, 1024)) <= 0) { - printf("Error: sock_connect:read() == %d\n", tmp); + printf("Error: sock_connect:read() == %d %s\n", tmp, strerror(errno)); exit(1); } write(fd, MESSAGE6, sizeof(MESSAGE6)); @@ -76,7 +76,7 @@ main(int argc, char **argv) setbuf(stderr, NULL); if (pthread_create(&thread, NULL, sock_connect, (void *)0xdeadbeaf)) { - printf("Error: main:pthread_create(sock_connect)\n"); + perror("Error: main:pthread_create(sock_connect)"); exit(1); } pthread_exit(NULL); |