Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-2]: src/lib/libpthread/arch/i386 Pull up following revision(s) (r...
details: https://anonhg.NetBSD.org/src/rev/5b1872ce2b43
branches: netbsd-2
changeset: 564465:5b1872ce2b43
user: tron <tron%NetBSD.org@localhost>
date: Fri Apr 21 21:50:10 2006 +0000
description:
Pull up following revision(s) (requested by cube in ticket #10448):
lib/libpthread/arch/i386/pthread_md.h: revision 1.7
Instead of using hard-coded values for various registers, get them from the
current context. Valid values can change depending on how the kernel is
setup. i386 and amd64 happen to be setup differently.
diffstat:
lib/libpthread/arch/i386/pthread_md.h | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
diffs (58 lines):
diff -r 6547f2dbecaa -r 5b1872ce2b43 lib/libpthread/arch/i386/pthread_md.h
--- a/lib/libpthread/arch/i386/pthread_md.h Fri Apr 21 21:48:23 2006 +0000
+++ b/lib/libpthread/arch/i386/pthread_md.h Fri Apr 21 21:50:10 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_md.h,v 1.5 2004/02/11 21:04:10 nathanw Exp $ */
+/* $NetBSD: pthread_md.h,v 1.5.4.1 2006/04/21 21:50:10 tron Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
#define _LIB_PTHREAD_I386_MD_H
#include <sys/ucontext.h>
+#include <ucontext.h>
extern int (*_md_getcontext_u)(ucontext_t *);
extern int (*_md_setcontext_u)(const ucontext_t *);
@@ -75,18 +76,30 @@
/*
* Set initial, sane values for registers whose values aren't just
* "don't care".
- * 0x2b is GSEL(GUDATA_SEL, SEL_UPL), and
- * 0x23 is GSEL(GUCODE_SEL, SEL_UPL), from arch/i386/include/segments.h.
- * 0x202 is PSL_USERSET from arch/i386/include/psl.h
+ *
+ * We use the current context instead of a guessed one because we cannot
+ * assume how the GDT entries are ordered: what is true on i386 is not
+ * true anymore on amd64.
*/
#define _INITCONTEXT_U_MD(ucp) \
- (ucp)->uc_mcontext.__gregs[_REG_GS] = 0x2b, \
- (ucp)->uc_mcontext.__gregs[_REG_FS] = 0x2b, \
- (ucp)->uc_mcontext.__gregs[_REG_ES] = 0x2b, \
- (ucp)->uc_mcontext.__gregs[_REG_DS] = 0x2b, \
- (ucp)->uc_mcontext.__gregs[_REG_CS] = 0x23, \
- (ucp)->uc_mcontext.__gregs[_REG_SS] = 0x2b, \
- (ucp)->uc_mcontext.__gregs[_REG_EFL] = 0x202;
+ do { \
+ ucontext_t ucur; \
+ (void)getcontext(&ucur); \
+ (ucp)->uc_mcontext.__gregs[_REG_GS] = \
+ ucur.uc_mcontext.__gregs[_REG_GS], \
+ (ucp)->uc_mcontext.__gregs[_REG_FS] = \
+ ucur.uc_mcontext.__gregs[_REG_FS], \
+ (ucp)->uc_mcontext.__gregs[_REG_ES] = \
+ ucur.uc_mcontext.__gregs[_REG_ES], \
+ (ucp)->uc_mcontext.__gregs[_REG_DS] = \
+ ucur.uc_mcontext.__gregs[_REG_DS], \
+ (ucp)->uc_mcontext.__gregs[_REG_CS] = \
+ ucur.uc_mcontext.__gregs[_REG_CS], \
+ (ucp)->uc_mcontext.__gregs[_REG_SS] = \
+ ucur.uc_mcontext.__gregs[_REG_SS], \
+ (ucp)->uc_mcontext.__gregs[_REG_EFL] = \
+ ucur.uc_mcontext.__gregs[_REG_EFL]; \
+ } while (/*CONSTCOND*/0);
/*
* Usable stack space below the ucontext_t.
Home |
Main Index |
Thread Index |
Old Index