libwine: Avoid using wine_get/set_fs().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-04-03 10:47:33 +02:00
parent f82a5b610f
commit a698750630
2 changed files with 11 additions and 7 deletions

View File

@ -382,7 +382,7 @@ unsigned short wine_ldt_alloc_fs(void)
int ret;
/* the preloader may have allocated it already */
global_fs_sel = wine_get_fs();
__asm__( "mov %%fs,%0" : "=r" (global_fs_sel) );
if (global_fs_sel && is_gdt_sel(global_fs_sel)) return global_fs_sel;
memset( &ldt_info, 0, sizeof(ldt_info) );
@ -431,7 +431,7 @@ void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry )
{
internal_set_entry( sel, entry );
}
wine_set_fs( sel );
__asm__( "mov %0,%%fs" :: "r" (sel) );
}
@ -442,11 +442,14 @@ void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry )
*/
void wine_ldt_free_fs( unsigned short sel )
{
WORD fs;
if (is_gdt_sel(sel)) return; /* nothing to do */
if (!((wine_get_fs() ^ sel) & ~3))
__asm__( "mov %%fs,%0" : "=r" (fs) );
if (!((fs ^ sel) & ~3))
{
/* FIXME: if freeing current %fs we cannot acquire locks */
wine_set_fs( 0 );
__asm__( "mov %0,%%fs" :: "r" (0) );
internal_set_entry( sel, &null_entry );
wine_ldt_copy.flags[sel >> 3] = 0;
}

View File

@ -923,10 +923,11 @@ static jstring wine_init_jni( JNIEnv *env, jobject obj, jobjectArray cmdline, jo
#ifdef __i386__
{
unsigned short java_fs = wine_get_fs();
wine_set_fs( 0 );
unsigned short java_fs;
__asm__( "mov %%fs,%0" : "=r" (java_fs) );
__asm__( "mov %0,%%fs" :: "r" (0) );
wine_init( argc, argv, error, sizeof(error) );
wine_set_fs( java_fs );
__asm__( "mov %0,%%fs" :: "r" (java_fs) );
}
#else
wine_init( argc, argv, error, sizeof(error) );