r1947 - in glibc-package/branches/glibc-2.5/debian: . patches/any
Author: aurel32
Date: 2007-02-07 14:03:50 +0100 (Wed, 07 Feb 2007)
New Revision: 1947
Modified:
glibc-package/branches/glibc-2.5/debian/changelog
glibc-package/branches/glibc-2.5/debian/patches/any/local-__thread.diff
Log:
* Update any/local-__thread.diff (make glibc buildable without __thread support)
from Petr Saliner.
Modified: glibc-package/branches/glibc-2.5/debian/changelog
===================================================================
--- glibc-package/branches/glibc-2.5/debian/changelog 2007-02-07 12:56:45 UTC (rev 1946)
+++ glibc-package/branches/glibc-2.5/debian/changelog 2007-02-07 13:03:50 UTC (rev 1947)
@@ -98,6 +98,8 @@
a symlink to /usr/include for compatibility reasons.
* patches/all/local-pthread-manpages.diff: update to fix a typo in
pthread_detach(3). Closes: #98852.
+ * Update any/local-__thread.diff (make glibc buildable without __thread support)
+ from Petr Saliner.
[ Denis Barbier ]
* Remove localedata/locale-en_NZ.diff (merged upstream).
Modified: glibc-package/branches/glibc-2.5/debian/patches/any/local-__thread.diff
===================================================================
--- glibc-package/branches/glibc-2.5/debian/patches/any/local-__thread.diff 2007-02-07 12:56:45 UTC (rev 1946)
+++ glibc-package/branches/glibc-2.5/debian/patches/any/local-__thread.diff 2007-02-07 13:03:50 UTC (rev 1947)
@@ -4,6 +4,10 @@
# DP: Upstream status: Rejected
# DP: Date: 2005-08-28
+2007-02-06 Petr Salinger <petr.salinger@seznam.cz>
+
+ inet/inet_ntoa.c: Only use __thread if USE___THREAD.
+
2005-08-28 Thomas Schwinge <schwinge@nic-nac-project.de>
malloc/memusage.c: Only use __thread if USE___THREAD.
@@ -28,3 +32,104 @@
/* A few macros to make the source more readable. */
#define peak_heap peak_use[0]
+--- inet/inet_ntoa.c 2006-04-09 07:50:08.000000000 +0200
++++ inet/inet_ntoa.c 2007-02-06 22:59:37.000000000 +0100
+@@ -21,10 +21,14 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <arpa/inet.h>
++#include <tls.h>
+
+ /* The interface of this function is completely stupid, it requires a
+ static buffer. We relax this a bit in that we allow one buffer for
+ each thread. */
++
++#if USE_TLS && HAVE___THREAD
++
+ static __thread char buffer[18];
+
+
+@@ -37,3 +41,83 @@
+
+ return buffer;
+ }
++
++#else
++#include <bits/libc-lock.h>
++
++/* The interface of this function is completely stupid, it requires a
++ static buffer. We relax this a bit in that we allow at least one
++ buffer for each thread. */
++
++/* This is the key for the thread specific memory. */
++static __libc_key_t key;
++
++/* If nonzero the key allocation failed and we should better use a
++ static buffer than fail. */
++static char local_buf[18];
++static char *static_buf;
++
++/* Destructor for the thread-specific data. */
++static void init (void);
++static void free_key_mem (void *mem);
++
++
++char *
++inet_ntoa (struct in_addr in)
++{
++ __libc_once_define (static, once);
++ char *buffer;
++ unsigned char *bytes;
++
++ /* If we have not yet initialized the buffer do it now. */
++ __libc_once (once, init);
++
++ if (static_buf != NULL)
++ buffer = static_buf;
++ else
++ {
++ /* We don't use the static buffer and so we have a key. Use it
++ to get the thread-specific buffer. */
++ buffer = __libc_getspecific (key);
++ if (buffer == NULL)
++ {
++ /* No buffer allocated so far. */
++ buffer = malloc (18);
++ if (buffer == NULL)
++ /* No more memory available. We use the static buffer. */
++ buffer = local_buf;
++ else
++ __libc_setspecific (key, buffer);
++ }
++ }
++
++ bytes = (unsigned char *) ∈
++ __snprintf (buffer, 18, "%d.%d.%d.%d",
++ bytes[0], bytes[1], bytes[2], bytes[3]);
++
++ return buffer;
++}
++
++
++/* Initialize buffer. */
++static void
++init (void)
++{
++ if (__libc_key_create (&key, free_key_mem))
++ /* Creating the key failed. This means something really went
++ wrong. In any case use a static buffer which is better than
++ nothing. */
++ static_buf = local_buf;
++}
++
++
++/* Free the thread specific data, this is done if a thread terminates. */
++static void
++free_key_mem (void *mem)
++{
++ free (mem);
++ __libc_setspecific (key, NULL);
++}
++
++#endif
++
Reply to: