Re: WineX and FreeBSD

Peter Hunnisett <[email protected]> Mon, 13 Dec 2004 12:43:10 -0500
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
Damian Gerow wrote:

>So I haven't really accomplished much at this point, but Cedega /does/
>compile *and* load up properly on FreeBSD now.  In that, you can get the
>output of 'winex --help', but there's some issues in the threading.
>
>To make this a little easier, I've just recompiled my base with -g, which
>should help with the hangs in external libraries.
>
>Patch attached.
>  
>
>------------------------------------------------------------------------
>
>diff -ru winex-orig/dlls/ntdll/cdrom.c winex/dlls/ntdll/cdrom.c
>--- winex-orig/dlls/ntdll/cdrom.c	Mon Nov 15 10:39:49 2004
>+++ winex/dlls/ntdll/cdrom.c	Fri Dec  3 00:51:18 2004
>@@ -977,27 +977,11 @@
>     }
> #elif defined(__FreeBSD__)
>     {
>-        struct ioc_read_audio   ira;
>+        off_t offset;
> 
>-        switch (raw->TrackMode)
>-        {
>-        case YellowMode2:
>-            FIXME("YellowMode2: NIY\n");
>-            return ret;
>-        case XAForm2:
>-            FIXME("XAForm2: NIY\n");
>-            return ret;
>-        case CDDA:
>-            /* 2048 = 2 ** 11 */
>-            if (raw->DiskOffset.s.HighPart & ~2047) FIXME("Unsupported value\n");
>-            ira.address.lba = ((raw->DiskOffset.s.LowPart >> 11) |
>+        offset = ((raw->DiskOffset.s.LowPart >> 11) |
>                 raw->DiskOffset.s.HighPart << (32 - 11)) - 1;
>-            ira.address_format = CD_LBA_FORMAT;
>-            ira.nframes = raw->SectorCount;
>-            ira.buffer = buffer;
>-            io = ioctl(dev, CDIOCREADAUDIO, &ira);
>-            break;
>-        }
>+        io = pread(dev, buffer, sectSize * raw->SectorCount, offset);
>     }
> #elif defined(__NetBSD__)
>     {
>
Firstly, what's wrong with the existing code? Does the ioctl not exist 
anymore or are we just missing an include?

>diff -ru winex-orig/dlls/winedos/dosvm.c winex/dlls/winedos/dosvm.c
>--- winex-orig/dlls/winedos/dosvm.c	Wed May 12 14:54:54 2004
>+++ winex/dlls/winedos/dosvm.c	Fri Dec  3 02:08:09 2004
>@@ -669,7 +669,7 @@
> /**********************************************************************
>  *	    DOSVM_Init
>  */
>-BOOL WINAPI DOSVM_Init( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
>+BOOL WINAPI DOSVM_Init( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved, CRITICAL_SECTION qcrit )
> {
>     TRACE_(module)("(0x%08x,%ld,%p)\n", hinstDLL, fdwReason, lpvReserved);
> 
>  
>

This isn't the right way to do it, but I've fixed it with what I've 
committed.

>diff -ru winex-orig/server/cdrom_eject.c winex/server/cdrom_eject.c
>--- winex-orig/server/cdrom_eject.c	Thu Nov 18 12:57:40 2004
>+++ winex/server/cdrom_eject.c	Fri Dec  3 01:58:33 2004
>@@ -568,7 +568,9 @@
>         memcpy( entry->devicename, devicepath, devicepathlen );
>         entry->devicename[devicepathlen] = 0;
>         entry->next = SERVER_STATIC_VARIABLE(cdrom_eject, cdrom_list);
>-	entry->try_poll = 0;
>+#if defined( linux )
>+        entry->try_poll = 0;
>+#endif
> 	    
>         /* Store at the list head */
>         SERVER_STATIC_VARIABLE(cdrom_eject, cdrom_list) = entry;
>diff -ru winex-orig/server/fd_server.c winex/server/fd_server.c
>--- winex-orig/server/fd_server.c	Mon Nov 15 10:36:12 2004
>+++ winex/server/fd_server.c	Fri Dec  3 02:58:14 2004
>@@ -583,6 +583,25 @@
> 
>             pthread_attr_destroy( &attr );
>         }
>+#elif defined(__FreeBSD__)
>+        {
>+            pid_t child;
>+
>+            switch (child = rfork(RFMEM | RFPROC | RFLINUXTHPN)) {
>+                case 0:
>+                    /* in child, successful */
>+                    exit(fd_server_thread(NULL));
>+                    break;
>+                case -1:
>+                    /* in parent, unsuccessful */
>+                    fatal_perror( "wineserver: rfork" );
>+                    break;
>+                default:
>+                    /* in parent, successful */
>+                    break;
>+            }
>+        }
>+
> #else
>        {
>            void* stack = malloc( stack_size );
>  
>

This isn't the right way to resolve the problem. The fundamental problem 
is that there is no single function to create a thread. We probably need 
to abstract something out and figure out how to use it in 
scheduler/sysdeps.c as well so that it can go into the port library.

>diff -ru winex-orig/server/mem_malloc.c winex/server/mem_malloc.c
>--- winex-orig/server/mem_malloc.c	Thu Jun 24 16:17:58 2004
>+++ winex/server/mem_malloc.c	Fri Dec  3 01:14:21 2004
>@@ -7,6 +7,7 @@
>   #define DEBUG      /* In case you need to turn on some more debug checks to track down a corruptor. Need to have PH_TRACE on to make sense  */
> #endif
> 
>+#include "config.h"
> #include "mem_defs.h"
> #include "mem_globals.c"
> 
>  
>
What needs config.h that I'm not spotting?

*
Ciao,
Peter
*