diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | MakeTAGS | 3 | ||||
-rw-r--r-- | Makeconfig | 4 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | Makerules | 42 | ||||
-rw-r--r-- | Rules | 17 | ||||
-rw-r--r-- | sunrpc/Makefile | 8 | ||||
-rw-r--r-- | sunrpc/thrsvc.c | 89 |
8 files changed, 155 insertions, 20 deletions
@@ -1,3 +1,13 @@ +2002-04-20 Ulrich Drepper <drepper@redhat.com> + + * Makefile: Add handling of xtests and xcheck targets. + * MakeTAGS: Likewise. + * Makeconfig: Likewise. + * Makerules: Likewise. + * Rules: Likewise. + * sunrpc/Makefile (xtests): Add thrsvc if thread library available. + * sunrpc/thrsvc.c: New file. By Zack Weinberg. + 2002-04-11 Zack Weinberg <zack@codesourcery.com> * include/rpc/rpc.h (struct rpc_thread_variables): Remove @@ -88,7 +88,8 @@ sources += $(foreach lib,$(extra-libs),$($(lib)-routines:=.c)) # sysdep directories, so don't bother searching them. sysdep-sources := $(filter-out $(wildcard $(sources)), $(sources)) all-sources = $(wildcard $(sort $(sources) $(sources:.c=.S) $(sources:.c=.s) \ - $(others:=.c) $(tests:=.c) $(test-srcs:=.c))) \ + $(others:=.c) $(tests:=.c) $(xtests:=.c) \ + $(test-srcs:=.c))) \ $(foreach dir,$(all-dirs),\ $(wildcard \ $(addprefix $(dir)/,\ @@ -943,3 +943,7 @@ endif endif # Makeconfig not yet included + +# Local Variables: +# mode: makefile +# End: @@ -56,7 +56,7 @@ configure: configure.in aclocal.m4; $(autoconf-it) # These are the targets that are made by making them in each subdirectory. +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \ subdir_clean subdir_distclean subdir_realclean \ - tests subdir_lint.out \ + tests xtests subdir_lint.out \ subdir_distinfo \ subdir_echo-headers subdir_echo-distinfo \ subdir_install \ @@ -599,7 +599,7 @@ endif +depfiles := $(sources:.c=.d) \ $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \ - $(addsuffix .d,$(tests) $(test-srcs)) + $(addsuffix .d,$(tests) $(xtests) $(test-srcs)) ifeq ($(build-programs),yes) +depfiles += $(addsuffix .d,$(others) $(sysdep-others)) endif @@ -1035,12 +1035,21 @@ ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) -include $(..)config.h # Support the GNU standard name for this target. .PHONY: check check: tests +# Special target to run tests which cannot be run unconditionally. +# Maintainers should use this target. +.PHONY: xcheck +xcheck: xtests ifneq (,$(tests)) cpp-srcs-left = $(tests) lib := tests include $(patsubst %,$(..)cppflags-iterator.mk,$(tests)) endif +ifneq (,$(xtests)) +cpp-srcs-left = $(xtests) +lib := tests +include $(patsubst %,$(..)cppflags-iterator.mk,$(xtests)) +endif .PHONY: TAGS TAGS: $(objpfx)distinfo $(..)MakeTAGS @@ -1063,19 +1072,24 @@ clean: common-clean mostlyclean: common-mostlyclean do-tests-clean: - -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(test-srcs)) \ - $(addsuffix -bp.out,$(tests) $(test-srcs))) + -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \ + $(test-srcs)) \ + $(addsuffix -bp.out,$(tests) $(xtests) \ + $(test-srcs))) # Remove the object files. common-mostlyclean: - -rm -f $(addprefix $(objpfx),$(tests) $(test-srcs) $(others) \ - $(sysdep-others) stubs \ - $(addsuffix .o,$(tests) $(test-srcs) \ - $(others) \ + -rm -f $(addprefix $(objpfx),$(tests) $(xtests) $(test-srcs) \ + $(others) $(sysdep-others) stubs \ + $(addsuffix .o,$(tests) $(xtests) \ + $(test-srcs) $(others) \ $(sysdep-others)) \ - $(addsuffix -bp,$(tests) $(test-srcs)) \ - $(addsuffix .out,$(tests) $(test-srcs)) \ - $(addsuffix -bp.out,$(tests) $(test-srcs))) + $(addsuffix -bp,$(tests) $(xtests) \ + $(test-srcs)) \ + $(addsuffix .out,$(tests) $(xtests) \ + $(test-srcs)) \ + $(addsuffix -bp.out,$(tests) $(xtests) \ + $(test-srcs))) -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \ $(install-lib.so) \ $(install-lib.so:%.so=%_pic.a)) @@ -1141,8 +1155,8 @@ rm -f $@.new echo > $@.new 'subdir := $(subdir)' $(foreach var,subdir-dirs sources elided-routines sysdep_routines \ headers sysdep_headers distribute dont_distribute generated \ - others tests test-srcs extra-libs $(extra-libs:%=%-routines) \ - versioned \ + others tests xtests test-srcs extra-libs versioned \ + $(extra-libs:%=%-routines) \ $(addprefix install-,lib lib.so data bin bin-script sbin others), echo >> $@.new '$(subdir)-$(var) := $($(var))' echo >> $@.new '$(var) = $$($(subdir)-$(var))') @@ -1161,3 +1175,7 @@ ifeq ($(with-cvs),yes) endif endif endif + +# Local Variables: +# mode: makefile +# End: @@ -1,4 +1,4 @@ -# Copyright (C) 1991,92,93,94,95,96,97,98,99,2000 Free Software Foundation, Inc. +# Copyright (C) 1991-2000, 2002 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -89,18 +89,21 @@ others: $(addprefix $(objpfx),$(extra-objs)) endif ifeq ($(cross-compiling),yes) tests: $(addprefix $(objpfx),$(tests) $(test-srcs)) +xtests: tests else ifeq ($(build-bounded),yes) tests-bp.out = $(tests:%=$(objpfx)%-bp.out) +xtests-bp.out = $(tests:%=$(objpfx)%-bp.out) $(xtests:%=$(objpfx)%-bp.out) endif tests: $(tests:%=$(objpfx)%.out) $(tests-bp.out) +xtests: $(tests:%=$(objpfx)%.out) $(xtests:%=$(objpfx)%.out) $(xtests-bp.out) endif ifeq ($(build-programs),yes) -binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs) +binaries-all = $(others) $(sysdep-others) $(tests) $(xtests) $(test-srcs) binaries-static = $(others-static) $(tests-static) else -binaries-all = $(tests) $(test-srcs) +binaries-all = $(tests) $(xtests) $(test-srcs) binaries-static = endif @@ -121,14 +124,14 @@ $(addprefix $(objpfx),$(binaries-static)): %: %.o \ endif ifeq ($(build-bounded),yes) -binaries-bounded = $(addsuffix -bp,$(tests) $(test-srcs)) +binaries-bounded = $(addsuffix -bp,$(tests) $(xtests) $(test-srcs)) $(addprefix $(objpfx),$(binaries-bounded)): %-bp: %.ob \ $(sort $(filter $(common-objpfx)lib%,$(link-libc-bounded))) \ $(addprefix $(csu-objpfx),start.ob) $(+preinit) $(+postinit) $(+link-bounded) endif -ifneq "$(strip $(tests) $(test-srcs))" "" +ifneq "$(strip $(tests) $(xtests) $(test-srcs))" "" # These are the implicit rules for making test outputs # from the test programs and whatever input files are present. @@ -242,3 +245,7 @@ ifndef no_deps -include $(stdio_lim:h=d) endif common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st + +# Local Variables: +# mode: makefile +# End: diff --git a/sunrpc/Makefile b/sunrpc/Makefile index b7858d6..dd21ddf 100644 --- a/sunrpc/Makefile +++ b/sunrpc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1994,95,96,97,98,99,2000,2001 Free Software Foundation, Inc. +# Copyright (C) 1994-2001, 2002 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -84,6 +84,10 @@ all: # Make this the default target; it will be defined in Rules. include ../Makeconfig +ifeq ($(have-thread-library),yes) +xtests += thrsvc +endif + ifeq (yes,$(build-static-nss)) otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \ $(resolvobjdir)/libresolv.a @@ -178,3 +182,5 @@ $(objpfx)rpc-proto.c: $(rpcsvc:%=rpcsvc/%) echo '#include <rpc/rpc.h>'; \ sed -n '/^%#include/s/%//p' $^; } > $@T mv -f $@T $@ + +$(objpfx)thrsvc: $(shared-thread-library) diff --git a/sunrpc/thrsvc.c b/sunrpc/thrsvc.c new file mode 100644 index 0000000..ac6af09 --- /dev/null +++ b/sunrpc/thrsvc.c @@ -0,0 +1,89 @@ +#include <pthread.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <rpc/rpc.h> +#include <arpa/inet.h> + +#define PROGNUM 1234 +#define VERSNUM 1 +#define PROCNUM 1 + +static int exitcode; + +static void +dispatch(struct svc_req *request, SVCXPRT *xprt) +{ + svc_sendreply(xprt, (xdrproc_t)xdr_void, 0); +} + +static void +test_one_call (CLIENT *c) +{ + struct timeval tout = { 60, 0 }; + enum clnt_stat result; + + printf ("test_one_call: "); + result = clnt_call (c, PROCNUM, + (xdrproc_t) xdr_void, 0, + (xdrproc_t) xdr_void, 0, tout); + if (result == RPC_SUCCESS) + puts ("success"); + else + { + clnt_perrno (result); + putchar ('\n'); + exitcode = 1; + } +} + +static void * +thread_wrapper (void *arg) +{ + test_one_call ((CLIENT *)arg); + return 0; +} + +int +main (void) +{ + pthread_t tid; + pid_t pid; + int err; + SVCXPRT *svx; + CLIENT *clnt; + struct sockaddr_in sin; + struct timeval wait = { 5, 0 }; + int sock = RPC_ANYSOCK; + + svx = svcudp_create (RPC_ANYSOCK); + svc_register (svx, PROGNUM, VERSNUM, dispatch, 0); + + pid = fork (); + if (pid == -1) + { + perror ("fork"); + return 1; + } + if (pid == 0) + svc_run (); + + inet_aton ("127.0.0.1", &sin.sin_addr); + sin.sin_port = htons (svx->xp_port); + sin.sin_family = AF_INET; + + clnt = clntudp_create (&sin, PROGNUM, VERSNUM, wait, &sock); + + /* Test in this thread */ + test_one_call (clnt); + + /* Test in a child thread */ + err = pthread_create (&tid, 0, thread_wrapper, (void *) clnt); + if (err) + fprintf (stderr, "pthread_create: %s\n", strerror (err)); + err = pthread_join (tid, 0); + if (err) + fprintf (stderr, "pthread_join: %s\n", strerror (err)); + + return exitcode; +} |