[uClibc-cvs] svn commit: branches/uClibc-nptl: include ldso/include ldso/ldso ldso/libd etc...

sjhill at uclibc.org sjhill at uclibc.org
Tue Aug 9 05:45:40 UTC 2005


Author: sjhill
Date: 2005-08-08 23:45:37 -0600 (Mon, 08 Aug 2005)
New Revision: 11075

Log:
Changes made to the dynamic loader for TLS/NPTL support. Additional changes made to libpthread and libc for remaining support.


Added:
   branches/uClibc-nptl/libpthread/nptl/sysdeps/alpha/dl-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/dl-minimal.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/powerpc/
   branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/powerpc/libc-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sh/
   branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sh/libc-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sparc/
   branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sparc/libc-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/i386/dl-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/i386/libc-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/mips/dl-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/powerpc/dl-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/sh/dl-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/sparc/dl-tls.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/x86_64/dl-tls.c

Modified:
   branches/uClibc-nptl/include/link.h
   branches/uClibc-nptl/ldso/include/dl-string.h
   branches/uClibc-nptl/ldso/include/ldsodefs.h
   branches/uClibc-nptl/ldso/ldso/Makefile
   branches/uClibc-nptl/ldso/ldso/dl-debug.c
   branches/uClibc-nptl/ldso/ldso/ldso.c
   branches/uClibc-nptl/ldso/libdl/Makefile
   branches/uClibc-nptl/libc/sysdeps/linux/alpha/Makefile
   branches/uClibc-nptl/libc/sysdeps/linux/common/Makefile
   branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/dl-tls.c


Changeset:
Modified: branches/uClibc-nptl/include/link.h
===================================================================
--- branches/uClibc-nptl/include/link.h	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/include/link.h	2005-08-09 05:45:37 UTC (rev 11075)
@@ -25,7 +25,7 @@
 #include <elf.h>
 #include <dlfcn.h>
 #include <sys/types.h>
-#ifdef IS_IN_libpthread
+#if defined(IS_IN_libpthread) || defined(IS_IN_rtld)
 #include <tls.h>		/* Defines USE_TLS.  */
 #endif
 

Modified: branches/uClibc-nptl/ldso/include/dl-string.h
===================================================================
--- branches/uClibc-nptl/ldso/include/dl-string.h	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/ldso/include/dl-string.h	2005-08-09 05:45:37 UTC (rev 11075)
@@ -13,6 +13,7 @@
 static char *_dl_strrchr(const char *str, int c);
 static char *_dl_strstr(const char *s1, const char *s2);
 static void * _dl_memcpy(void * dst, const void * src, size_t len);
+static void * _dl_mempcpy(void * dst, const void * src, size_t len);
 static int _dl_memcmp(const void * s1,const void * s2,size_t len);
 static void *_dl_memset(void * str,int c,size_t len);
 static char *_dl_get_last_path_component(char *path);
@@ -146,6 +147,12 @@
 	return dst;
 }
 
+static inline void * _dl_mempcpy(void * dst, const void * src, size_t len)
+{
+	_dl_memcpy(dst, src, len);
+	return (void *)(((char *) dst) + len);
+}
+
 static __always_inline int _dl_memcmp(const void * s1,const void * s2,size_t len)
 {
 	unsigned char *c1 = (unsigned char *)s1-1;

Modified: branches/uClibc-nptl/ldso/include/ldsodefs.h
===================================================================
--- branches/uClibc-nptl/ldso/include/ldsodefs.h	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/ldso/include/ldsodefs.h	2005-08-09 05:45:37 UTC (rev 11075)
@@ -4,11 +4,19 @@
 #include <features.h>
 #include <tls.h>
 
-/*
- * NPTL - These are supposed to be from 'sysdeps/generic/ldsodefs.h'
- *        and used with the ld.so global structure. I am not sure how
- *        this fits into uClibc yet, so they are empty.
- */
+#ifdef IS_IN_rtld
+# define EXTERN
+#else
+# define EXTERN extern
+#endif
+
+/* Non-shared code has no support for multiple namespaces.  */
+#ifdef SHARED
+# define DL_NNS 16
+#else
+# define DL_NNS 1
+#endif
+
 #define GL(x) _##x
 #define GLRO(x) _##x
 
@@ -17,7 +25,6 @@
    might use the variable which results in copy relocations on some
    platforms.  But this does not matter, ld.so can always use the local
    copy.  */
-//extern void *__libc_stack_end attribute_relro;
 extern void *__libc_stack_end;
 rtld_hidden_proto (__libc_stack_end)
 
@@ -64,11 +71,11 @@
      defined as well, so _dl_rtld_map needs to be last before this.  */
 #ifdef USE_TLS
   /* Highest dtv index currently needed.  */
-  extern size_t _dl_tls_max_dtv_idx;
+  EXTERN size_t _dl_tls_max_dtv_idx;
   /* Flag signalling whether there are gaps in the module ID allocation.  */
-  extern bool _dl_tls_dtv_gaps;
+  EXTERN bool _dl_tls_dtv_gaps;
   /* Information about the dtv slots.  */
-  extern struct dtv_slotinfo_list
+  EXTERN struct dtv_slotinfo_list
   {
     size_t len;
     struct dtv_slotinfo_list *next;
@@ -80,13 +87,13 @@
     } slotinfo[0];
   } *_dl_tls_dtv_slotinfo_list;
   /* Number of modules in the static TLS block.  */
-  extern size_t _dl_tls_static_nelem;
+  EXTERN size_t _dl_tls_static_nelem;
   /* Size of the static TLS block.  */
-  extern size_t _dl_tls_static_size;
+  EXTERN size_t _dl_tls_static_size;
   /* Size actually allocated in the static TLS block.  */
-  extern size_t _dl_tls_static_used;
+  EXTERN size_t _dl_tls_static_used;
   /* Alignment requirement of the static TLS block.  */
-  extern size_t _dl_tls_static_align;
+  EXTERN size_t _dl_tls_static_align;
 
 /* Number of additional entries in the slotinfo array of each slotinfo
    list element.  A large number makes it almost certain take we never
@@ -97,11 +104,11 @@
 # define DTV_SURPLUS	(14)
 
   /* Initial dtv of the main thread, not allocated with normal malloc.  */
-  extern void *_dl_initial_dtv;
+  EXTERN void *_dl_initial_dtv;
   /* Generation counter for the dtv.  */
-  extern size_t _dl_tls_generation;
+  EXTERN size_t _dl_tls_generation;
 
-  extern void (*_dl_init_static_tls) (struct link_map *);
+  EXTERN void (*_dl_init_static_tls) (struct link_map *);
 #endif
 
 #endif

Modified: branches/uClibc-nptl/ldso/ldso/Makefile
===================================================================
--- branches/uClibc-nptl/ldso/ldso/Makefile	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/ldso/ldso/Makefile	2005-08-09 05:45:37 UTC (rev 11075)
@@ -43,7 +43,7 @@
 ifeq ($(PTHREADS_NATIVE),y)
 XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) $(PICFLAG) \
 	-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
-	-fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I. -I$(TOPDIR)include $(PTINC)
+	-fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I. -I$(TOPDIR)include $(PTINC) -DSHARED -DIS_IN_rtld
 else
 XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) $(PICFLAG) \
 	-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
@@ -59,7 +59,7 @@
 	LDFLAGS+=-z relro
 endif
 
-CSRC= ldso.c
+CSRC=ldso.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
 ASRC=$(shell ls $(TARGET_ARCH)/*.S)
 AOBJS=$(patsubst %.S,%.o, $(ASRC))
@@ -82,7 +82,14 @@
 
 all: $(LDSO_FULLNAME)
 
+ifeq ($(PTHREADS_NATIVE),y)
+dl-tls.c dl-minimal.c:
+	$(LN) -sf $(TOPDIR)libpthread/nptl/sysdeps/generic/$@ $@
+
+$(LDSO_FULLNAME): dl-tls.c dl-minimal.c $(OBJS) $(DLINK_OBJS)
+else
 $(LDSO_FULLNAME): $(OBJS) $(DLINK_OBJS)
+endif
 	$(LD) $(LDFLAGS) -soname=$(UCLIBC_LDSO) \
 		-o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC)
 	$(INSTALL) -d $(TOPDIR)lib
@@ -101,4 +108,4 @@
 	$(TARGET_ARCH)/*.h $(TARGET_ARCH)/*.c $(TOPDIR)ldso/include/*.h
 
 clean:
-	$(RM) $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~
+	$(RM) $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~ dl-tls.c dl-minimal.c

Modified: branches/uClibc-nptl/ldso/ldso/dl-debug.c
===================================================================
--- branches/uClibc-nptl/ldso/ldso/dl-debug.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/ldso/ldso/dl-debug.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -98,9 +98,14 @@
 	_dl_dprintf(_dl_debug_file, "\n");
 }
 
+#define assert(expr)														 \
+	if (!(expr))															 \
+		_dl_dprintf(_dl_debug_file, "Assert: %s(%d)\n", __FILE__, __LINE__);
+
 #else
 
 #define debug_sym(symtab, strtab, symtab_index)
 #define debug_reloc(symtab, strtab, rpnt)
+#define assert(expr)
 
 #endif /* __SUPPORT_LD_DEBUG__ */

Modified: branches/uClibc-nptl/ldso/ldso/ldso.c
===================================================================
--- branches/uClibc-nptl/ldso/ldso/ldso.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/ldso/ldso/ldso.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -69,6 +69,11 @@
 /* Forward function declarations */
 static int _dl_suid_ok(void);
 
+#ifdef __PTHREADS_NATIVE__
+#include "dl-minimal.c"
+#include "dl-tls.c"
+#endif
+
 /*
  * This stub function is used by some debuggers.  The idea is that they
  * can set an internal breakpoint on it, so that we are notified when the

Modified: branches/uClibc-nptl/ldso/libdl/Makefile
===================================================================
--- branches/uClibc-nptl/ldso/libdl/Makefile	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/ldso/libdl/Makefile	2005-08-09 05:45:37 UTC (rev 11075)
@@ -27,9 +27,15 @@
 else
 XXFLAGS+=$(OPTIMIZATION)
 endif
+ifeq ($(PTHREADS_NATIVE),y)
 XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) \
 	-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
+	-fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I. -I$(TOPDIR)include $(PTINC) -DIS_IN_rtld
+else
+XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) \
+	-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
 	-fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I. -I$(TOPDIR)include
+endif
 
 XXFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
 XXFLAGS_NOPIC:=$(XXFLAGS)
@@ -67,7 +73,7 @@
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 libdl_pic.o: libdl.c $(TOPDIR)ldso/include/*.h
-	$(CC) $(XXFLAGS) -c libdl.c -o libdl_pic.o
+	$(CC) $(XXFLAGS) -DSHARED -c libdl.c -o libdl_pic.o
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 shared: $(LIBDL_PIC)

Modified: branches/uClibc-nptl/libc/sysdeps/linux/alpha/Makefile
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/alpha/Makefile	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libc/sysdeps/linux/alpha/Makefile	2005-08-09 05:45:37 UTC (rev 11075)
@@ -32,6 +32,10 @@
 
 OBJS=$(SOBJS) $(COBJS)
 
+ifeq ($(PTHREADS_NATIVE),y)
+COBJS += $(PTDIR)sysdeps/$(TARGET_ARCH)/libc-tls.o
+endif
+
 OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH)
 
 all: $(OBJ_LIST)
@@ -76,6 +80,11 @@
 	$(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o
 endif
 
+ifeq ($(PTHREADS_NATIVE),y)
+$(PTDIR)sysdeps/$(TARGET_ARCH)/libc-tls.o:
+	$(MAKE) -C $(PTDIR)sysdeps/$(TARGET_ARCH) libc-tls.o
+endif
+
 headers:
 	$(LN) -fs ../libc/sysdeps/linux/alpha/fpu_control.h $(TOPDIR)/include/
 

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/Makefile
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/Makefile	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/Makefile	2005-08-09 05:45:37 UTC (rev 11075)
@@ -21,6 +21,10 @@
 
 SRCS  = $(wildcard *.c)
 
+ifeq ($(strip $(PTHREADS_NATIVE)),y)
+SRCS := $(filter-out fork.c,$(SRCS))
+endif
+
 ifeq ($(strip $(EXCLUDE_BRK)),y)
 SRCS := $(filter-out sbrk.c,$(SRCS))
 endif

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/alpha/dl-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/alpha/dl-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/alpha/dl-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/dl-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/dl-minimal.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/dl-minimal.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/dl-minimal.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1,129 @@
+/* Minimal replacements for basic facilities used in the dynamic linker.
+   Copyright (C) 1995-1998,2000-2002,2004 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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+//#include <errno.h>
+#include <limits.h>
+#include <string.h>
+#include <tls.h>
+//#include <unistd.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <ldsodefs.h>
+
+/* Minimal `malloc' allocator for use while loading shared libraries.
+   No block is ever freed.  */
+
+static void *alloc_ptr, *alloc_end, *alloc_last_block;
+
+/* Declarations of global functions.  */
+extern void weak_function free (void *ptr);
+extern void * weak_function realloc (void *ptr, size_t n);
+
+/* Allocate an aligned memory block.  */
+void * weak_function
+memalign (size_t align, size_t n)
+{
+#ifdef MAP_ANON
+#define	_dl_zerofd (-1)
+#else
+  extern int _dl_zerofd;
+
+  if (_dl_zerofd == -1)
+    _dl_zerofd = _dl_sysdep_open_zero_fill ();
+#define MAP_ANON 0
+#endif
+
+  if (alloc_end == 0)
+    {
+      /* Consume any unused space in the last page of our data segment.  */
+      extern int _end attribute_hidden;
+      alloc_ptr = &_end;
+      alloc_end = (void *) 0 + (((alloc_ptr - (void *) 0)
+				 + GLRO(dl_pagesize) - 1)
+				& ~(GLRO(dl_pagesize) - 1));
+    }
+
+  /* Make sure the allocation pointer is ideally aligned.  */
+  alloc_ptr = (void *) 0 + (((alloc_ptr - (void *) 0) + align - 1)
+			    & ~(align - 1));
+
+  if (alloc_ptr + n >= alloc_end)
+    {
+      /* Insufficient space left; allocate another page.  */
+      caddr_t page;
+      size_t nup = (n + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1);
+      page = _dl_mmap (0, nup, PROT_READ|PROT_WRITE,
+		     MAP_ANON|MAP_PRIVATE, _dl_zerofd, 0);
+      if (_dl_mmap_check_error(page))
+	return -1;
+      if (page != alloc_end)
+	alloc_ptr = page;
+      alloc_end = page + nup;
+    }
+
+  alloc_last_block = (void *) alloc_ptr;
+  alloc_ptr += n;
+  return alloc_last_block;
+}
+
+void * weak_function
+malloc (size_t n)
+{
+  return memalign (sizeof (double), n);
+}
+
+/* We use this function occasionally since the real implementation may
+   be optimized when it can assume the memory it returns already is
+   set to NUL.  */
+void * weak_function
+calloc (size_t nmemb, size_t size)
+{
+  /* New memory from the trivial malloc above is always already cleared.
+     (We make sure that's true in the rare occasion it might not be,
+     by clearing memory in free, below.)  */
+  return malloc (nmemb * size);
+}
+
+/* This will rarely be called.  */
+void weak_function
+free (void *ptr)
+{
+  /* We can free only the last block allocated.  */
+  if (ptr == alloc_last_block)
+    {
+      /* Since this is rare, we clear the freed block here
+	 so that calloc can presume malloc returns cleared memory.  */
+      _dl_memset (alloc_last_block, '\0', alloc_ptr - alloc_last_block);
+      alloc_ptr = alloc_last_block;
+    }
+}
+
+/* This is only called with the most recent block returned by malloc.  */
+void * weak_function
+realloc (void *ptr, size_t n)
+{
+  void *new;
+  if (ptr == NULL)
+    return malloc (n);
+  assert (ptr == alloc_last_block);
+  alloc_ptr = alloc_last_block;
+  new = malloc (n);
+  assert (new == ptr);
+  return new;
+}

Modified: branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/dl-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/dl-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/dl-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -1,4 +1,4 @@
-/* Thread-local storage handling in the ELF dynamic linker.  Generic version.
+/* tHREAD-local storage handling in the ELF dynamic linker.  Generic version.
    Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -17,21 +17,27 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <assert.h>
-#include <errno.h>
 #include <libintl.h>
 #include <signal.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/param.h>
-
 #include <tls.h>
+#include <dl-tls.h>
+#include <ldsodefs.h>
 
-/* We don't need any of this if TLS is not supported.  */
-#ifdef USE_TLS
+#ifndef IS_IN_rtld
+#include <assert.h>
+#include <link.h>
+#include <string.h>
+#include <unistd.h>
 
-# include <dl-tls.h>
-# include <ldsodefs.h>
+#define	_dl_malloc	malloc
+#define _dl_memset	memset
+#define _dl_mempcpy	mempcpy
+#define _dl_dprintf	fprintf
+#define _dl_debug_file	stderr
+#define _dl_exit	exit
+#endif
 
 /* Amount of excess space to allocate in the static TLS area
    to allow dynamic loading of modules defining IE-model TLS data.  */
@@ -47,11 +53,20 @@
 __attribute__ ((__noreturn__))
 oom (void)
 {
-  _dl_fatal_printf ("cannot allocate memory for thread-local data: ABORT\n");
+	do {
+		_dl_dprintf (_dl_debug_file,
+			"cannot allocate thread-local memory: ABORT\n");
+		_dl_exit (127);
+	} while (1);
 }
 # endif
 
 
+void *_dl_memalign(size_t alignment, size_t bytes)
+{
+	return _dl_malloc(bytes);
+}
+
 size_t
 internal_function
 _dl_next_tls_modid (void)
@@ -208,8 +223,9 @@
 # elif TLS_DTV_AT_TP
   /* The TLS blocks start right after the TCB.  */
   size_t offset = TLS_TCB_SIZE;
+  size_t cnt;
 
-  for (size_t cnt = 0; slotinfo[cnt].map != NULL; ++cnt)
+  for (cnt = 0; slotinfo[cnt].map != NULL; ++cnt)
     {
       assert (cnt < GL(dl_tls_dtv_slotinfo_list)->len);
 
@@ -346,7 +362,7 @@
 # endif
 
   /* Allocate a correctly aligned chunk of memory.  */
-  result = __libc_memalign (GL(dl_tls_static_align), size);
+  result = _dl_memalign (GL(dl_tls_static_align), size);
   if (__builtin_expect (result != NULL, 1))
     {
       /* Allocate the DTV.  */
@@ -358,14 +374,14 @@
 
       /* Clear the TCB data structure.  We can't ask the caller (i.e.
 	 libpthread) to do it, because we will initialize the DTV et al.  */
-      memset (result, '\0', TLS_TCB_SIZE);
+      _dl_memset (result, '\0', TLS_TCB_SIZE);
 # elif TLS_DTV_AT_TP
       result = (char *) result + size - GL(dl_tls_static_size);
 
       /* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it.
 	 We can't ask the caller (i.e. libpthread) to do it, because we will
 	 initialize the DTV et al.  */
-      memset ((char *) result - TLS_PRE_TCB_SIZE, '\0',
+      _dl_memset ((char *) result - TLS_PRE_TCB_SIZE, '\0',
 	      TLS_PRE_TCB_SIZE + TLS_TCB_SIZE);
 # endif
 
@@ -440,7 +456,7 @@
 	  /* Copy the initialization image and clear the BSS part.  */
 	  dtv[map->l_tls_modid].pointer.val = dest;
 	  dtv[map->l_tls_modid].pointer.is_static = true;
-	  memset (__mempcpy (dest, map->l_tls_initimage,
+	  _dl_memset (_dl_mempcpy (dest, map->l_tls_initimage,
 			     map->l_tls_initimage_size), '\0',
 		  map->l_tls_blocksize - map->l_tls_initimage_size);
 	}
@@ -476,9 +492,10 @@
 _dl_deallocate_tls (void *tcb, bool dealloc_tcb)
 {
   dtv_t *dtv = GET_DTV (tcb);
+  size_t cnt;
 
   /* We need to free the memory allocated for non-static TLS.  */
-  for (size_t cnt = 0; cnt < dtv[-1].counter; ++cnt)
+  for (cnt = 0; cnt < dtv[-1].counter; ++cnt)
     if (! dtv[1 + cnt].pointer.is_static
 	&& dtv[1 + cnt].pointer.val != TLS_DTV_UNALLOCATED)
       free (dtv[1 + cnt].pointer.val);
@@ -529,12 +546,12 @@
 {
   void *newp;
 
-  newp = __libc_memalign (map->l_tls_align, map->l_tls_blocksize);
+  newp = _dl_memalign (map->l_tls_align, map->l_tls_blocksize);
   if (newp == NULL)
     oom ();
 
   /* Initialize the memory.  */
-  memset (__mempcpy (newp, map->l_tls_initimage, map->l_tls_initimage_size),
+  _dl_memset (_dl_mempcpy (newp, map->l_tls_initimage, map->l_tls_initimage_size),
 	  '\0', map->l_tls_blocksize - map->l_tls_initimage_size);
 
   return newp;
@@ -584,7 +601,9 @@
       listp =  GL(dl_tls_dtv_slotinfo_list);
       do
 	{
-	  for (size_t cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
+	  size_t cnt;
+
+	  for (cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
 	    {
 	      size_t gen = listp->slotinfo[cnt].gen;
 
@@ -637,7 +656,7 @@
 		      newp = malloc ((2 + newsize) * sizeof (dtv_t));
 		      if (newp == NULL)
 			oom ();
-		      memcpy (newp, &dtv[-1], oldsize * sizeof (dtv_t));
+		      _dl_memcpy (newp, &dtv[-1], oldsize * sizeof (dtv_t));
 		    }
 		  else
 		    {
@@ -650,7 +669,7 @@
 		  newp[0].counter = newsize;
 
 		  /* Clear the newly allocated part.  */
-		  memset (newp + 2 + oldsize, '\0',
+		  _dl_memset (newp + 2 + oldsize, '\0',
 			  (newsize - oldsize) * sizeof (dtv_t));
 
 		  /* Point dtv to the generation counter.  */
@@ -782,13 +801,14 @@
 	     generation.  */
 	  ++GL(dl_tls_generation);
 
-	  _dl_signal_error (ENOMEM, "dlopen", NULL, N_("\
-cannot create TLS data structures"));
+	  _dl_dprintf (_dl_debug_file,
+			"cannot create TLS data structures: ABORT\n");
+	  _dl_exit (127);
 	}
 
       listp->len = TLS_SLOTINFO_SURPLUS;
       listp->next = NULL;
-      memset (listp->slotinfo, '\0',
+      _dl_memset (listp->slotinfo, '\0',
 	      TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
     }
 
@@ -796,4 +816,3 @@
   listp->slotinfo[idx].map = l;
   listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1;
 }
-#endif	/* use TLS */

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/powerpc/libc-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/powerpc/libc-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/powerpc/libc-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/libc-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sh/libc-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sh/libc-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sh/libc-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/libc-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sparc/libc-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sparc/libc-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/generic/sparc/libc-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/libc-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/i386/dl-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/i386/dl-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/i386/dl-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/dl-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/i386/libc-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/i386/libc-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/i386/libc-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/libc-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/mips/dl-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/mips/dl-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/mips/dl-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/dl-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/powerpc/dl-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/powerpc/dl-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/powerpc/dl-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/dl-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/sh/dl-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/sh/dl-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/sh/dl-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/dl-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/sparc/dl-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/sparc/dl-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/sparc/dl-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/dl-tls.c>

Added: branches/uClibc-nptl/libpthread/nptl/sysdeps/x86_64/dl-tls.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/x86_64/dl-tls.c	2005-08-09 05:20:47 UTC (rev 11074)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/x86_64/dl-tls.c	2005-08-09 05:45:37 UTC (rev 11075)
@@ -0,0 +1 @@
+#include <../generic/dl-tls.c>




More information about the uClibc-cvs mailing list