Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Allow storing and receiving the LWP private pointer via ucon...



details:   https://anonhg.NetBSD.org/src/rev/622c751b3080
branches:  trunk
changeset: 762597:622c751b3080
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Feb 24 04:28:41 2011 +0000

description:
Allow storing and receiving the LWP private pointer via ucontext_t
on all platforms except VAX and IA64. Add fast access via register for
AMD64, i386 and SH3 ports. Use this fast access in libpthread to replace
the stack based pthread_self(). Implement skeleton support for Alpha,
HPPA, PowerPC, SPARC and SPARC64, but leave it disabled.

Ports that support this feature provide __HAVE____LWP_GETPRIVATE_FAST in
machine/types.h and a corresponding __lwp_getprivate_fast in
machine/mcontext.h.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.

diffstat:

 lib/libc/arch/alpha/gen/_lwp.c              |   7 ++++-
 lib/libc/arch/arm/gen/_lwp.c                |   6 +++-
 lib/libc/arch/hppa/gen/_lwp.c               |   5 ++-
 lib/libc/arch/i386/gen/_lwp.c               |   7 +++--
 lib/libc/arch/m68k/gen/_lwp.c               |   6 +++-
 lib/libc/arch/mips/gen/_lwp.c               |   6 +++-
 lib/libc/arch/powerpc/gen/_lwp.c            |   5 ++-
 lib/libc/arch/sh3/gen/_lwp.c                |   5 ++-
 lib/libc/arch/sparc/gen/_lwp.c              |   5 ++-
 lib/libc/arch/sparc64/gen/_lwp.c            |   5 ++-
 lib/libc/arch/x86_64/gen/_lwp.c             |   7 +++--
 lib/libpthread/arch/i386/pthread_md.h       |  18 +---------------
 lib/libpthread/pthread_int.h                |  10 ++++++--
 sys/arch/alpha/alpha/machdep.c              |  12 +++-------
 sys/arch/alpha/alpha/sys_machdep.c          |   6 +++-
 sys/arch/alpha/include/mcontext.h           |  14 +++++++++++-
 sys/arch/alpha/include/types.h              |   5 +++-
 sys/arch/amd64/amd64/machdep.c              |  10 +++++++-
 sys/arch/amd64/amd64/netbsd32_machdep.c     |  14 +++++++++---
 sys/arch/amd64/include/mcontext.h           |  19 ++++++++++++++--
 sys/arch/amd64/include/types.h              |   3 +-
 sys/arch/arm/arm/sig_machdep.c              |  10 +++++++-
 sys/arch/arm/include/mcontext.h             |   7 ++++-
 sys/arch/hppa/hppa/hppa_machdep.c           |  12 ++++++----
 sys/arch/hppa/hppa/trap.S                   |  11 +++++++++-
 sys/arch/hppa/hppa/vm_machdep.c             |  15 +++++++++++-
 sys/arch/hppa/include/mcontext.h            |  12 +++++++++-
 sys/arch/hppa/include/types.h               |   7 +++++-
 sys/arch/i386/i386/machdep.c                |  10 +++++++-
 sys/arch/i386/include/mcontext.h            |  16 ++++++++++++-
 sys/arch/i386/include/types.h               |   3 +-
 sys/arch/m68k/include/mcontext.h            |   6 +++-
 sys/arch/m68k/m68k/sig_machdep.c            |  10 +++++++-
 sys/arch/mips/include/mcontext.h            |  32 +++++++++++++++++++++++-----
 sys/arch/mips/include/types.h               |   5 +++-
 sys/arch/mips/mips/cpu_subr.c               |  10 +++++++-
 sys/arch/mips/mips/netbsd32_machdep.c       |   7 ++++-
 sys/arch/powerpc/include/mcontext.h         |  11 +++++++++-
 sys/arch/powerpc/include/types.h            |   5 +++-
 sys/arch/sh3/include/mcontext.h             |  11 +++++++++-
 sys/arch/sh3/include/types.h                |   5 +++-
 sys/arch/sh3/sh3/sh3_machdep.c              |  15 +++++++++++-
 sys/arch/sparc/include/mcontext.h           |  12 +++++++++-
 sys/arch/sparc/include/types.h              |   6 ++++-
 sys/arch/sparc/sparc/machdep.c              |   6 +++-
 sys/arch/sparc/sparc/vm_machdep.c           |  15 +++++++++++-
 sys/arch/sparc64/sparc64/netbsd32_machdep.c |   6 +++-
 sys/arch/sparc64/sparc64/vm_machdep.c       |  15 +++++++++++-
 48 files changed, 339 insertions(+), 116 deletions(-)

diffs (truncated from 1497 to 300 lines):

diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/alpha/gen/_lwp.c
--- a/lib/libc/arch/alpha/gen/_lwp.c    Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/alpha/gen/_lwp.c    Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:55 martin Exp $  */
+/*     $NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:41 joerg Exp $   */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:55 martin Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:41 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -60,4 +60,7 @@
        gr[_REG_A0] = (unsigned long) arg;
        gr[_REG_SP] = ((unsigned long) (stack_base + stack_size)) & ~0x7;
        gr[_REG_S6] = 0;
+       gr[_REG_UNIQUE] = (unsigned long)private;
+
+       u->uc_flags |= _UC_UNIQUE;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/arm/gen/_lwp.c
--- a/lib/libc/arch/arm/gen/_lwp.c      Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/arm/gen/_lwp.c      Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:25 lukem Exp $   */
+/*     $NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:41 joerg Exp $   */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:25 lukem Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:41 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -68,4 +68,6 @@
        u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t) sp) & ~7;
        u->uc_mcontext.__gregs[_REG_LR] = (__greg_t) _lwp_exit;
        u->uc_mcontext.__gregs[_REG_PC] = (__greg_t) start;
+       u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
+       u->uc_flags |= _UC_TLSBASE;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/hppa/gen/_lwp.c
--- a/lib/libc/arch/hppa/gen/_lwp.c     Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/hppa/gen/_lwp.c     Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.4 2010/01/07 12:31:10 skrll Exp $   */
+/*     $NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:42 joerg Exp $   */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.4 2010/01/07 12:31:10 skrll Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:42 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -69,4 +69,5 @@
        gr[_REG_RP] = (__greg_t) _lwp_exit;
        gr[_REG_ARG0] = (__greg_t) arg;
        gr[_REG_SP] = (__greg_t) sp;
+       gr[_REG_CR27] = (__greg_t) private;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/i386/gen/_lwp.c
--- a/lib/libc/arch/i386/gen/_lwp.c     Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/i386/gen/_lwp.c     Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.6 2008/04/28 20:22:56 martin Exp $  */
+/*     $NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:42 joerg Exp $   */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.6 2008/04/28 20:22:56 martin Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:42 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -66,5 +66,6 @@
        /* LINTED uintptr_t is safe */
        u->uc_mcontext.__gregs[_REG_UESP] = (uintptr_t) sp;
 
-       /* LINTED private is currently unused */
+       u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
+       u->uc_flags |= _UC_TLSBASE;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/m68k/gen/_lwp.c
--- a/lib/libc/arch/m68k/gen/_lwp.c     Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/m68k/gen/_lwp.c     Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:56 martin Exp $  */
+/*     $NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:42 joerg Exp $   */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:56 martin Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:42 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -60,4 +60,6 @@
        *--sp = (void *) _lwp_exit;
 
        u->uc_mcontext.__gregs[_REG_A7] = (int) sp;
+       u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
+       u->uc_flags |= _UC_TLSBASE;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/mips/gen/_lwp.c
--- a/lib/libc/arch/mips/gen/_lwp.c     Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/mips/gen/_lwp.c     Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:56 martin Exp $  */
+/*     $NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:42 joerg Exp $   */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:56 martin Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:42 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -61,4 +61,6 @@
        gr[_REG_RA] = (unsigned long) _lwp_exit;
        gr[_REG_A0] = (unsigned long) arg;
        gr[_REG_SP] = (unsigned long) sp;
+       u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
+       u->uc_flags |= _UC_TLSBASE;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/powerpc/gen/_lwp.c
--- a/lib/libc/arch/powerpc/gen/_lwp.c  Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/powerpc/gen/_lwp.c  Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:26 lukem Exp $   */
+/*     $NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:42 joerg Exp $   */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:26 lukem Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:42 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -64,4 +64,5 @@
        u->uc_mcontext.__gregs[1] = ((int) sp) - 12;    /* stack */
        u->uc_mcontext.__gregs[33] = (int) _lwp_exit;   /* LR */
        u->uc_mcontext.__gregs[34] = (int) start;       /* PC */
+       u->uc_mcontext.__gregs[_REG_R2] = (__greg_t) private;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/sh3/gen/_lwp.c
--- a/lib/libc/arch/sh3/gen/_lwp.c      Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/sh3/gen/_lwp.c      Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:26 lukem Exp $   */
+/*     $NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:42 joerg Exp $   */
 
 /*
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.4 2005/06/12 05:21:26 lukem Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:42 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -64,4 +64,5 @@
        u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t) sp) & ~3;
        u->uc_mcontext.__gregs[_REG_PR] = (__greg_t) _lwp_exit;
        u->uc_mcontext.__gregs[_REG_PC] = (__greg_t) start;
+       u->uc_mcontext.__gregs[_REG_GBR] = (__greg_t) private;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/sparc/gen/_lwp.c
--- a/lib/libc/arch/sparc/gen/_lwp.c    Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/sparc/gen/_lwp.c    Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:57 martin Exp $  */
+/*     $NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:43 joerg Exp $   */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:57 martin Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:43 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -65,6 +65,7 @@
        gr[_REG_O0] = (ulong)arg;
        gr[_REG_O6] = (ulong)sp;
        gr[_REG_O7] = (ulong)_lwp_exit - 8;
+       gr[_REG_G7] = (ulong)private;
 
        /* XXX: uwe: why do we need this? */
        /* create loopback in the window save area on the stack? */
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/sparc64/gen/_lwp.c
--- a/lib/libc/arch/sparc64/gen/_lwp.c  Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/sparc64/gen/_lwp.c  Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:57 martin Exp $  */
+/*     $NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:43 joerg Exp $   */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.5 2008/04/28 20:22:57 martin Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.6 2011/02/24 04:28:43 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -70,4 +70,5 @@
        gr[_REG_O0] = (ulong) arg;
        gr[_REG_O6] = (ulong) sp;
        gr[_REG_O7] = (ulong)_lwp_exit - 8;
+       gr[_REG_G7] = (ulong)private;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libc/arch/x86_64/gen/_lwp.c
--- a/lib/libc/arch/x86_64/gen/_lwp.c   Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libc/arch/x86_64/gen/_lwp.c   Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.6 2009/07/02 09:57:09 joerg Exp $   */
+/*     $NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:43 joerg Exp $   */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.6 2009/07/02 09:57:09 joerg Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:43 joerg Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -66,5 +66,6 @@
        /* LINTED uintptr_t is safe */
        gr[_REG_URSP] = (uintptr_t) sp;
 
-       /* LINTED private is currently unused */
+       u->uc_mcontext._mc_tlsbase = (uintptr_t)private;
+       u->uc_flags |= _UC_TLSBASE;
 }
diff -r 9a0e3ab6b647 -r 622c751b3080 lib/libpthread/arch/i386/pthread_md.h
--- a/lib/libpthread/arch/i386/pthread_md.h     Thu Feb 24 03:37:02 2011 +0000
+++ b/lib/libpthread/arch/i386/pthread_md.h     Thu Feb 24 04:28:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_md.h,v 1.18 2011/01/25 19:12:05 christos Exp $ */
+/*     $NetBSD: pthread_md.h,v 1.19 2011/02/24 04:28:43 joerg Exp $    */
 
 /*-
  * Copyright (c) 2001, 2007, 2008 The NetBSD Foundation, Inc.
@@ -75,26 +75,10 @@
        } while (/*CONSTCOND*/0);
 
 #define        pthread__smt_pause()    __asm __volatile("rep; nop" ::: "memory")
-/*     #define PTHREAD__HAVE_THREADREG */
 
 /* Don't need additional memory barriers. */
 #define        PTHREAD__ATOMIC_IS_MEMBAR
 
-static inline pthread_t
-#ifdef __GNUC__
-__attribute__ ((__const__))
-#endif
-pthread__threadreg_get(void)
-{
-       pthread_t self;



Home | Main Index | Thread Index | Old Index