PERFORCE change 64382 for review

Peter Wemm peter at FreeBSD.org
Fri Nov 5 14:44:32 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=64382

Change 64382 by peter at peter_daintree on 2004/11/05 22:44:20

	attempt to use the amd64 sysarch syscalls that are visible to i386 binaries
	to implement the %fs/%gs stuff, rather than the ldt syscalls that do not exist.

Affected files ...

.. //depot/projects/hammer/lib/libpthread/arch/i386/i386/pthread_md.c#3 edit
.. //depot/projects/hammer/lib/libpthread/arch/i386/include/pthread_md.h#10 edit

Differences ...

==== //depot/projects/hammer/lib/libpthread/arch/i386/i386/pthread_md.c#3 (text+ko) ====

@@ -76,7 +76,9 @@
 struct kcb *
 _kcb_ctor(struct kse *kse)
 {
+#ifndef COMPAT_32BIT
 	union descriptor ldt;
+#endif
 	struct kcb *kcb;
 
 	kcb = malloc(sizeof(struct kcb));
@@ -84,6 +86,7 @@
 		bzero(kcb, sizeof(struct kcb));
 		kcb->kcb_self = kcb;
 		kcb->kcb_kse = kse;
+#ifndef COMPAT_32BIT
 		ldt.sd.sd_hibase = (unsigned int)kcb >> 24;
 		ldt.sd.sd_lobase = (unsigned int)kcb & 0xFFFFFF;
 		ldt.sd.sd_hilimit = (sizeof(struct kcb) >> 16) & 0xF;
@@ -99,6 +102,7 @@
 			free(kcb);
 			return (NULL);
 		}
+#endif
 	}
 	return (kcb);
 }
@@ -106,9 +110,11 @@
 void
 _kcb_dtor(struct kcb *kcb)
 {
+#ifndef COMPAT_32BIT
 	if (kcb->kcb_ldt >= 0) {
 		i386_set_ldt(kcb->kcb_ldt, NULL, 1);
 		kcb->kcb_ldt = -1;	/* just in case */
 	}
+#endif
 	free(kcb);
 }

==== //depot/projects/hammer/lib/libpthread/arch/i386/include/pthread_md.h#10 (text+ko) ====

@@ -32,7 +32,9 @@
 #define	_PTHREAD_MD_H_
 
 #include <stddef.h>
+#include <sys/types.h>
 #include <sys/kse.h>
+#include <machine/sysarch.h>
 #include <ucontext.h>
 
 extern int _thr_setcontext(mcontext_t *, intptr_t, intptr_t *);
@@ -150,10 +152,15 @@
 static __inline void
 _kcb_set(struct kcb *kcb)
 {
+#ifndef COMPAT_32BIT
 	int val;
 
 	val = (kcb->kcb_ldt << 3) | 7;
 	__asm __volatile("movl %0, %%gs" : : "r" (val));
+#else
+	_amd64_set_gsbase(kcb);
+#endif
+
 }
 
 /* Get the current kcb. */


More information about the p4-projects mailing list