This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
Re: [PATCH][RFC] MIPS glibc-2.5 linuxthreads with TLS
- From: Hiroki Kaminaga <kaminaga at sm dot sony dot co dot jp>
- To: drow at false dot org
- Cc: libc-ports at sourceware dot org, kaminaga at sm dot sony dot co dot jp
- Date: Fri, 02 Feb 2007 14:17:25 +0900 (JST)
- Subject: Re: [PATCH][RFC] MIPS glibc-2.5 linuxthreads with TLS
- References: <20070130142436.GA22493@nevyn.them.org> <20070131.134834.104026835.kaminaga@sm.sony.co.jp> <20070131122419.GA17098@nevyn.them.org>
Hi,
> On Wed, Jan 31, 2007 at 01:48:34PM +0900, Hiroki Kaminaga wrote:
> > With the below patch, I was able to use linuxthreads --with-tls
> > --with-__thread on MIPS board. I have just tested a few sample, and it
> > seems working (though I haven't run make check).
>
> Thanks. I don't plan to commit it, since LinuxThreads is broken on
> HEAD anyway, but it may be useful to other list readers.
The previous patch had a bug, sorry... Below is the modified patch.
make check didn't complain at linuxthreads tls test. Posted to archive
for readres. Please discard previous patch and apply this one for use.
Best Regards,
(Hiroki Kaminaga)
t
--
Index: glibc-2.5-mips-with__thraed/linuxthreads/sysdeps/mips/pt-machine.h
===================================================================
--- glibc-2.5-mips-with__thraed.orig/linuxthreads/sysdeps/mips/pt-machine.h
+++ glibc-2.5-mips-with__thraed/linuxthreads/sysdeps/mips/pt-machine.h
@@ -43,6 +43,9 @@ testandset (int *spinlock)
return _test_and_set (spinlock, 1);
}
+/* We want the OS to assign stack address */
+#define FLOATING_STACKS 1
+#define ARCH_STACK_MAX_SIZE 8*1024*1024
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
Index: glibc-2.5-mips-with__thraed/linuxthreads/sysdeps/mips/tls.h
===================================================================
--- glibc-2.5-mips-with__thraed.orig/linuxthreads/sysdeps/mips/tls.h
+++ glibc-2.5-mips-with__thraed/linuxthreads/sysdeps/mips/tls.h
@@ -155,9 +155,32 @@ typedef struct
((pthread_descr) (READ_THREAD_POINTER () \
- TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
+# undef INIT_THREAD_SELF
+# define INIT_THREAD_SELF(DESCR, NR) \
+ TLS_INIT_TP ((struct _pthread_descr_struct *)((void *) (DESCR) \
+ + TLS_PRE_TCB_SIZE), 0)
+
/* Get the thread descriptor definition. */
# include <linuxthreads/descr.h>
+/* ??? Generic bits of LinuxThreads may call these macros with
+ DESCR set to NULL. We are expected to be able to reference
+ the "current" value.
+
+ In our case, we'd really prefer to use DESCR, since lots of
+ PAL_code calls would be expensive. We can only trust that
+ the compiler does its job and unifies the multiple
+ __builtin_thread_pointer instances. */
+
+#define THREAD_GETMEM(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+
/* l_tls_offset == 0 is perfectly valid on MIPS, so we have to use some
different value to mean unset l_tls_offset. */
# define NO_TLS_OFFSET -1