[MPlayer-cvslog] r30541 - in trunk: configure loader/ldt_keeper.c loader/module.c

komh subversion at mplayerhq.hu
Fri Feb 12 02:38:14 CET 2010


Author: komh
Date: Fri Feb 12 02:38:14 2010
New Revision: 30541

Log:
Add win32 loader support for OS/2

Modified:
   trunk/configure
   trunk/loader/ldt_keeper.c
   trunk/loader/module.c

Modified: trunk/configure
==============================================================================
--- trunk/configure	Fri Feb 12 00:59:08 2010	(r30540)
+++ trunk/configure	Fri Feb 12 02:38:14 2010	(r30541)
@@ -7129,7 +7129,7 @@ if test "$_real" = auto ; then
   _real=no
   _res_comment="dynamic loader support needed"
   if test "$_dl" = yes || test "$_win32dll" = yes &&
-     (linux || freebsd || netbsd || openbsd || dragonfly || darwin || win32) ; then
+     (linux || freebsd || netbsd || openbsd || dragonfly || darwin || win32 || os2) ; then
     _real=yes
   fi
 fi

Modified: trunk/loader/ldt_keeper.c
==============================================================================
--- trunk/loader/ldt_keeper.c	Fri Feb 12 00:59:08 2010	(r30540)
+++ trunk/loader/ldt_keeper.c	Fri Feb 12 02:38:14 2010	(r30541)
@@ -255,6 +255,9 @@ ldt_fs_t* Setup_LDT_Keeper(void)
 	    printf("Couldn't install fs segment, expect segfault\n");
 	}
     }
+#elif defined(__OS2__)
+    /* convert flat addr to sel idx for LDT_SEL() */
+    fs_ldt = (uintptr_t)fs_seg >> 16;
 #endif
 
     Setup_FS_Segment();

Modified: trunk/loader/module.c
==============================================================================
--- trunk/loader/module.c	Fri Feb 12 00:59:08 2010	(r30540)
+++ trunk/loader/module.c	Fri Feb 12 02:38:14 2010	(r30541)
@@ -744,6 +744,31 @@ static int dump_component(char* name, in
 
 #ifdef EMU_QTX_API
 
+#ifdef __OS2__
+uint32_t _System DosQueryMem(void *, uint32_t *, uint32_t *);
+#endif
+
+static int is_invalid_ptr_handle(void *p)
+{
+#ifdef __OS2__
+    uint32_t cb = 1;
+    uint32_t fl;
+
+    if(DosQueryMem(p, &cb, &fl))
+        return 1;
+
+    // Occasionally, ptr with 'EXEC' attr is passed.
+    // On OS/2, however, malloc() never sets 'EXEC' attr.
+    // So ptr with 'EXEC' attr is invalid.
+    if(fl & 0x04)
+        return 1;
+
+    return 0;
+#else
+    return (uint32_t)p >= 0x60000000;
+#endif
+}
+
 static uint32_t ret_array[4096];
 static int ret_i=0;
 
@@ -844,10 +869,10 @@ static int report_func(void *stack_base,
 #endif
       return 1;
   case 0x15002f: //DisposePtr
-      if(((uint32_t *)stack_base)[1]>=0x60000000)
+      if(is_invalid_ptr_handle(((void **)stack_base)[1]))
           printf("WARNING! Invalid Ptr handle!\n");
       else
-          free((void *)((uint32_t *)stack_base)[1]);
+          free(((void **)stack_base)[1]);
       reg->eax=0;
 #ifdef DEBUG_QTX_API
       printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);


More information about the MPlayer-cvslog mailing list