Update of /cvsroot/sbcl/sbcl/src/runtime
In directory sc8-pr-cvs1:/tmp/cvs-serv14687/src/runtime
Modified Files:
Tag: dan_native_threads_branch
linux-os.c
Log Message:
0.7.9.54.thread.1
_Experimental_ branch for Linux native thread support.
From time to time the code checked in on this branch may compile,
and possibly even run. This is by no means guaranteed
------
New files threads.txt and TODO.dan indicate general approach and
outstanding short-term goals to get there
SYMBOL primitive object gains a tls-offset slot
LDT hackery code at os_init time (x86 linux only) sets up a
thread-local storage area using a segment selector, and makes
%gs point to it
symbol-value vop checks thread-local storage area at tls-offset
before referring to global value slot
Index: linux-os.c
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/runtime/linux-os.c,v
retrieving revision 1.17
retrieving revision 1.17.4.1
diff -u -d -r1.17 -r1.17.4.1
--- linux-os.c 6 Aug 2002 11:46:33 -0000 1.17
+++ linux-os.c 24 Nov 2002 02:36:43 -0000 1.17.4.1
@@ -41,6 +41,20 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <asm/ldt.h>
+#include <linux/unistd.h>
+
+#include <unistd.h>
+#include <sys/mman.h>
+
+_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount );
+
+static struct modify_ldt_ldt_s ldt_entry = {
+ 1, 0, 0, /* index, address, length filled in later */
+ 1, MODIFY_LDT_CONTENTS_DATA, 0, 0, 0, 1
+};
+u32 local_ldt_copy[LDT_ENTRIES*LDT_ENTRY_SIZE/sizeof(u32)];
+
#include "validate.h"
size_t os_vm_page_size;
@@ -52,6 +66,8 @@
#endif
void os_init(void)
{
+ lispobj *tls_vector=
+ mmap(0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
/* Early versions of Linux don't support the mmap(..) functionality
* that we need. */
{
@@ -86,8 +102,52 @@
something?) Find out what this was meant to do, and reenable it
or delete it if possible. -- CSR, 2002-07-15 */
/* SET_FPU_CONTROL_WORD(0x1372|4|8|16|32); no interrupts */
+
+ printf("vector is at 0x%x\n",tls_vector);
+ {
+ /* find index of get next free ldt entry */
+ int n=__modify_ldt(0,local_ldt_copy,sizeof local_ldt_copy)
+ /LDT_ENTRY_SIZE;
+
+ ldt_entry.entry_number=n;
+ ldt_entry.base_addr=(unsigned long) tls_vector;
+ ldt_entry.limit=1000;
+ ldt_entry.limit_in_pages=1;
+ tls_vector[0]=UNBOUND_MARKER_WIDETAG;
+ tls_vector[1]=UNBOUND_MARKER_WIDETAG;
+ tls_vector[2]=2<<2;
+ if (__modify_ldt (1, &ldt_entry, sizeof (ldt_entry)) != 0)
+ lose("modify_ldt call failed: something magical is not happening");
+ __asm__ __volatile__ ("movw %w0, %%gs" : : "q"
+ ((n << 3) /* selector number */
+ + (1 << 2) /* TI set = LDT */
+ + 3)); /* privilege level */
+ printf("ldt entry is 0x%x 0x%x\n",
+ (ldt_entry.base_addr & 0xff000000) |
+ ((ldt_entry.base_addr & 0x00ff0000) >> 16) |
+ (ldt_entry.limit & 0xf0000) |
+ ((ldt_entry.read_exec_only ^ 1) << 9) |
+ (ldt_entry.contents << 10) |
+ ((ldt_entry.seg_not_present ^ 1) << 15) |
+ (ldt_entry.seg_32bit << 22) |
+ (ldt_entry.limit_in_pages << 23) |
+ 0x7000,
+
+ ((ldt_entry.base_addr & 0x0000ffff) << 16) |
+ (ldt_entry.limit & 0x0ffff));
+
+
+
+ }
#endif
}
+
+void debug_get_ldt()
+{
+ int n=__modify_ldt (0, local_ldt_copy, sizeof local_ldt_copy);
+ printf("%d bytes in ldt: print/x local_ldt_copy\n", n);
+}
+
/* In Debian CMU CL ca. 2.4.9, it was possible to get an infinite
* cascade of errors from do_mmap(..). This variable is a counter to
|