about summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-10-05 08:25:34 +0000
committerJakub Jelinek <jakub@redhat.com>2004-10-05 08:25:34 +0000
commitfd63f7c6ce353ccfdbba58a37e8ef5465fcedfe4 (patch)
treed68e6563180c849e8c5a37b646903b82c4302c1e /nscd
parent85148842d401edf64f9edee7e5819a947c289ed2 (diff)
downloadglibc-fd63f7c6ce353ccfdbba58a37e8ef5465fcedfe4.tar.gz
glibc-fd63f7c6ce353ccfdbba58a37e8ef5465fcedfe4.tar.xz
glibc-fd63f7c6ce353ccfdbba58a37e8ef5465fcedfe4.zip
Updated to fedora-glibc-20041005T0745
Diffstat (limited to 'nscd')
-rw-r--r--nscd/Makefile9
-rw-r--r--nscd/connections.c37
-rw-r--r--nscd/gai.c25
-rw-r--r--nscd/nscd.c13
4 files changed, 65 insertions, 19 deletions
diff --git a/nscd/Makefile b/nscd/Makefile
index b0ef3cd5f2..b197b3fc6b 100644
--- a/nscd/Makefile
+++ b/nscd/Makefile
@@ -32,7 +32,7 @@ vpath %.c ../locale/programs
 nscd-modules := nscd connections pwdcache getpwnam_r getpwuid_r grpcache \
 		getgrnam_r getgrgid_r hstcache gethstbyad_r gethstbynm2_r \
 		dbg_log nscd_conf nscd_stat cache mem nscd_setup_thread \
-		xmalloc xstrdup aicache initgrcache
+		xmalloc xstrdup aicache initgrcache gai
 
 ifeq ($(have-thread-library),yes)
 
@@ -96,11 +96,16 @@ CFLAGS-nscd_setup_thread.c += $(nscd-cflags)
 CFLAGS-aicache.c += $(nscd-cflags)
 CFLAGS-selinux.c += $(nscd-cflags)
 CFLAGS-initgrcache.c += $(nscd-cflags)
+CFLAGS-gai.c += $(nscd-cflags)
 
 ifeq (yesyes,$(have-fpie)$(build-shared))
+ifeq (yes,$(have-z-relro))
+relro-LDFLAGS += -Wl,-z,now
+endif
+
 $(objpfx)nscd: $(addprefix $(objpfx),$(nscd-modules:=.o))
 	$(LINK.o) -pie -Wl,-O1 \
-	  $(sysdep-LDFLAGS) $(config-LDFLAGS) \
+	  $(sysdep-LDFLAGS) $(config-LDFLAGS) $(relro-LDFLAGS) \
 	  $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
 	  $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
 	  $(LDFLAGS) $(LDFLAGS-$(@F)) \
diff --git a/nscd/connections.c b/nscd/connections.c
index 2bd3bec5b0..d9c11f5425 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -21,6 +21,7 @@
 #include <alloca.h>
 #include <assert.h>
 #include <atomic.h>
+#include <dlfcn.h>
 #include <error.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -42,6 +43,7 @@
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/un.h>
+#include <gnu/lib-names.h>
 
 #include "nscd.h"
 #include "dbg_log.h"
@@ -1455,12 +1457,39 @@ start_threads (void)
   pthread_condattr_t condattr;
   pthread_condattr_init (&condattr);
 
-#if _POSIX_CLOCK_SELECTION >= 0 && _POSIX_MONOTONIC_CLOCK >= 0
+#if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
   /* Determine whether the monotonous clock is available.  */
   struct timespec dummy;
-  if (clock_getres (CLOCK_MONOTONIC, &dummy) == 0
-      && pthread_condattr_setclock (&condattr, CLOCK_MONOTONIC) == 0)
-    timeout_clock = CLOCK_MONOTONIC;
+# if _POSIX_MONOTONIC_CLOCK == 0
+  if (sysconf (_SC_MONOTONIC_CLOCK) > 0)
+# endif
+    {
+# if defined _POSIX_CLOCK_SELECTION && _POSIX_CLOCK_SELECTION >= 0
+#  if _POSIX_CLOCK_SELECTION == 0
+      if (sysconf (_SC_CLOCK_SELECTION) > 0)
+#  endif
+        if (clock_getres (CLOCK_MONOTONIC, &dummy) == 0
+            && pthread_condattr_setclock (&condattr, CLOCK_MONOTONIC) == 0)
+          timeout_clock = CLOCK_MONOTONIC;
+# elif _POSIX_THREADS > 0
+      if (sysconf (_SC_CLOCK_SELECTION) > 0)
+        {
+          void *h = __libc_dlopen (LIBPTHREAD_SO);
+          int (*condattr_setclock) (pthread_condattr_t *, __clockid_t) = NULL;
+
+          if (h != NULL)
+            condattr_setclock = __libc_dlsym (h, "pthread_condattr_setclock");
+
+          if (condattr_setclock
+              && clock_getres (CLOCK_MONOTONIC, &dummy) == 0
+              && condattr_setclock (&condattr, CLOCK_MONOTONIC) == 0)
+            timeout_clock = CLOCK_MONOTONIC;
+
+          if (h != NULL)
+            __libc_dlclose (h);
+        }
+# endif
+    }
 #endif
 
   pthread_cond_init (&readylist_cond, &condattr);
diff --git a/nscd/gai.c b/nscd/gai.c
new file mode 100644
index 0000000000..722c7e415d
--- /dev/null
+++ b/nscd/gai.c
@@ -0,0 +1,25 @@
+/* This file uses the getaddrinfo code but it compiles it without NSCD
+   support.  We just need a few symbol renames.  */
+#define __getservbyname_r getservbyname_r
+#define __inet_aton inet_aton
+#define __getsockname getsockname
+#define __socket socket
+#define __recvmsg recvmsg
+#define __bind bind
+#define __sendto sendto
+#define __strchrnul strchrnul
+
+#include <getaddrinfo.c>
+
+/* Support code.  */
+#include <check_pf.c>
+#ifdef HAVE_LIBIDN
+# include <libidn/idn-stub.c>
+#endif
+
+/* Some variables normally defined in libc.  */
+service_user *__nss_hosts_database;
+
+#if defined NEED_NETLINK && __ASSUME_NETLINK_SUPPORT == 0
+int __no_netlink_support attribute_hidden;
+#endif
diff --git a/nscd/nscd.c b/nscd/nscd.c
index 15a7ea2530..5cca127f91 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -510,16 +510,3 @@ write_pid (const char *file)
 
   return 0;
 }
-
-
-/* This is an ugly hack which prevents getaddrinfo from being dragged
-   into nscd.  There currently is no special getaddrinfo version for
-   use in nscd.  In case it should be necessary such a version must be
-   created and this dummy version should be removed.  */
-extern void getaddrinfo (void) __attribute ((visibility ("hidden")));
-
-void
-getaddrinfo (void)
-{
-  abort ();
-}