summaryrefslogtreecommitdiffstats
path: root/loader/ldt_keeper.c
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-09-06 00:14:08 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-09-06 00:14:08 +0000
commit16816457b80ccca4bc38b8fbbca3e01d8dfc610e (patch)
treec1a830d726f3278a2cdd2e829a25914c8fb94dbe /loader/ldt_keeper.c
parent7f086bc51bfb26827cf29e5d6658af0255fbc6b8 (diff)
downloadmpv-16816457b80ccca4bc38b8fbbca3e01d8dfc610e.tar.bz2
mpv-16816457b80ccca4bc38b8fbbca3e01d8dfc610e.tar.xz
FreeBSD 5.0 (libkse/libthr) support by Dan Eischen <eischen@vigrid.com>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10822 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'loader/ldt_keeper.c')
-rw-r--r--loader/ldt_keeper.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/loader/ldt_keeper.c b/loader/ldt_keeper.c
index c4459844f7..0c8cb326ca 100644
--- a/loader/ldt_keeper.c
+++ b/loader/ldt_keeper.c
@@ -88,11 +88,16 @@ struct modify_ldt_ldt_s {
#define LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3)
/* i got this value from wine sources, it's the first free LDT entry */
+#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
+#define TEB_SEL_IDX LDT_AUTO_ALLOC
+#endif
+
#ifndef TEB_SEL_IDX
#define TEB_SEL_IDX 17
#endif
-#define TEB_SEL LDT_SEL(TEB_SEL_IDX)
+static unsigned int fs_ldt = TEB_SEL_IDX;
+
/**
* here is a small logical problem with Restore for multithreaded programs -
@@ -104,8 +109,10 @@ extern "C"
#endif
void Setup_FS_Segment(void)
{
+ unsigned int ldt_desc = LDT_SEL(fs_ldt);
+
__asm__ __volatile__(
- "movl %0,%%eax; movw %%ax, %%fs" : : "i" (TEB_SEL)
+ "movl %0,%%eax; movw %%ax, %%fs" : : "r" (ldt_desc)
);
}
@@ -211,7 +218,13 @@ ldt_fs_t* Setup_LDT_Keeper(void)
unsigned long d[2];
LDT_EntryToBytes( d, &array );
+#if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)
+ ret = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)d, 1);
+ array.entry_number = ret;
+ fs_ldt = ret;
+#else
ret = i386_set_ldt(array.entry_number, (union descriptor *)d, 1);
+#endif
if (ret < 0)
{
perror("install_fs");
@@ -224,7 +237,7 @@ ldt_fs_t* Setup_LDT_Keeper(void)
#if defined(__svr4__)
{
struct ssd ssd;
- ssd.sel = TEB_SEL;
+ ssd.sel = LDT_SEL(TEB_SEL_IDX);
ssd.bo = array.base_addr;
ssd.ls = array.limit - array.base_addr;
ssd.acc1 = ((array.read_exec_only == 0) << 1) |