Subject: WINE
To: None <port-i386@NetBSD.ORG>
From: Charles M. Hannum <mycroft@gnu.ai.mit.edu>
List: current-users
Date: 11/01/1994 15:51:55
Well, I grabbed Wine 941030 and made it work with GCC 2.4.5 under
NetBSD.  It turns out that the main problem has to do with structure
packing; GCC 2.6.0 uses `__attribute__((packed))' on individual
structure members to indicate that they should be packed tightly
against the previous elements, but GCC 2.4.5 ignores that attribute.

I added appropriate `#pragma pack' directives to get the same effect.

While getting WINE to run, I made the following changes.  Someone who
actually cares more about it than I do should decide what to do with
them.

BTW, I've noticed that Browser boxes don't work right, About boxes
crash the emulator, and Help menus generally fork another WINE process
which spins in an apparently infinite loop (after fixing a kernel bug
that caused forking with a local LDT to crash the machine, anyway).

-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----
diff -rc2 t/wine941030/controls/edit.c wine941030/controls/edit.c
*** t/wine941030/controls/edit.c	Sun Oct 30 11:26:21 1994
--- wine941030/controls/edit.c	Tue Nov  1 00:22:01 1994
***************
*** 585,589 ****
      /* set up text cursor for edit class */
      CLASS_FindClassByName("EDIT", &classPtr);
!     classPtr->wc.hCursor = LoadCursor(0, IDC_IBEAM);
  
      /* paint background on first WM_PAINT */
--- 585,589 ----
      /* set up text cursor for edit class */
      CLASS_FindClassByName("EDIT", &classPtr);
!     classPtr->wc.hCursor = LoadCursor((HANDLE)NULL, IDC_IBEAM);
  
      /* paint background on first WM_PAINT */
diff -rc2 t/wine941030/controls/widgets.c wine941030/controls/widgets.c
*** t/wine941030/controls/widgets.c	Sun Oct 16 09:53:33 1994
--- wine941030/controls/widgets.c	Tue Nov  1 00:22:08 1994
***************
*** 63,67 ****
      for (i = 0; i < NB_BUILTIN_CLASSES; i++, class++)
      {
! 	class->hCursor = LoadCursor( 0, IDC_ARROW );
  	if (!RegisterClass( class )) return FALSE;
      }
--- 63,67 ----
      for (i = 0; i < NB_BUILTIN_CLASSES; i++, class++)
      {
! 	class->hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
  	if (!RegisterClass( class )) return FALSE;
      }
diff -rc2 t/wine941030/include/class.h wine941030/include/class.h
*** t/wine941030/include/class.h	Tue Feb 22 23:49:51 1994
--- wine941030/include/class.h	Tue Nov  1 00:45:49 1994
***************
*** 12,15 ****
--- 12,17 ----
  #define CLASS_MAGIC   0x4b4e      /* 'NK' */
  
+ #pragma pack(1)
+ 
    /* !! Don't change this structure (see GetClassLong()) */
  typedef struct tagCLASS
***************
*** 23,26 ****
--- 25,30 ----
      WORD         wExtra[1];     /* Class extra bytes */
  } CLASS;
+ 
+ #pragma pack(4)
  
  
diff -rc2 t/wine941030/include/dialog.h wine941030/include/dialog.h
*** t/wine941030/include/dialog.h	Sun Oct 16 14:34:13 1994
--- wine941030/include/dialog.h	Tue Nov  1 00:45:52 1994
***************
*** 10,13 ****
--- 10,14 ----
  #include "windows.h"
  
+ #pragma pack(1)
  
    /* Dialog info structure.
***************
*** 65,68 ****
--- 66,70 ----
  } DLGTEMPLATE;
  
+ #pragma pack(4)
  
  #endif  /* DIALOG_H */
diff -rc2 t/wine941030/include/gdi.h wine941030/include/gdi.h
*** t/wine941030/include/gdi.h	Sun Oct 30 11:26:30 1994
--- wine941030/include/gdi.h	Tue Nov  1 00:45:55 1994
***************
*** 28,31 ****
--- 28,32 ----
  #define METAFILE_DC_MAGIC     0x4f51
  
+ #pragma pack(1)
  
  typedef struct tagREGION
***************
*** 82,85 ****
--- 83,88 ----
      REGION      region;
  } RGNOBJ;
+ 
+ #pragma pack(4)
  
  typedef struct
diff -rc2 t/wine941030/include/registers.h wine941030/include/registers.h
*** t/wine941030/include/registers.h	Mon Aug 15 17:54:44 1994
--- wine941030/include/registers.h	Mon Oct 31 19:21:06 1994
***************
*** 34,38 ****
--- 34,42 ----
  #define SI context->sc_esi
  #define SP context->sc_esp
+ #ifndef __FreeBSD__
+ #define EFL context->sc_eflags
+ #else
  #define EFL context->sc_efl
+ #endif
  #define EIP context->sc_eip
  
diff -rc2 t/wine941030/include/windows.h wine941030/include/windows.h
*** t/wine941030/include/windows.h	Sun Oct 30 11:26:33 1994
--- wine941030/include/windows.h	Tue Nov  1 00:45:41 1994
***************
*** 123,126 ****
--- 123,128 ----
  #endif
  
+ #pragma pack(1)
+ 
    /* Window classes */
  
***************
*** 2341,2344 ****
--- 2343,2348 ----
  #define META_CREATEBITMAP            0x06FE
  #define META_CREATEREGION            0x06FF
+ 
+ #pragma pack(4)
  
  
diff -rc2 t/wine941030/include/wine.h wine941030/include/wine.h
*** t/wine941030/include/wine.h	Wed Jun  8 00:11:14 1994
--- wine941030/include/wine.h	Mon Oct 31 19:20:39 1994
***************
*** 26,30 ****
  	unsigned long sc_eip;
  	unsigned short sc_cs, __csh;
! 	unsigned long sc_efl;
  	unsigned long esp_at_signal;
  	unsigned short sc_ss, __ssh;
--- 26,30 ----
  	unsigned long sc_eip;
  	unsigned short sc_cs, __csh;
! 	unsigned long sc_eflags;
  	unsigned long esp_at_signal;
  	unsigned short sc_ss, __ssh;
diff -rc2 t/wine941030/loader/signal.c wine941030/loader/signal.c
*** t/wine941030/loader/signal.c	Sun Oct 30 11:26:38 1994
--- wine941030/loader/signal.c	Mon Oct 31 16:08:21 1994
***************
*** 309,313 ****
--- 309,317 ----
  	ret = TRUE;
      }
+ #ifdef linux
      wine_sigaction(SIGSEGV, &old_act, NULL);
+ #else
+     sigaction(SIGSEGV, &old_act, NULL);
+ #endif
      return ret;
  }
diff -rc2 t/wine941030/misc/dos_fs.c wine941030/misc/dos_fs.c
*** t/wine941030/misc/dos_fs.c	Sun Oct 30 11:26:44 1994
--- wine941030/misc/dos_fs.c	Mon Oct 31 15:37:51 1994
***************
*** 22,26 ****
  #endif
  #if defined(__NetBSD__) || defined(__FreeBSD__)
! #include <sys/types.h>
  #include <sys/mount.h>
  #endif
--- 22,26 ----
  #endif
  #if defined(__NetBSD__) || defined(__FreeBSD__)
! #include <sys/param.h>
  #include <sys/mount.h>
  #endif
diff -rc2 t/wine941030/objects/bitblt.c wine941030/objects/bitblt.c
*** t/wine941030/objects/bitblt.c	Sun Oct 30 11:26:55 1994
--- wine941030/objects/bitblt.c	Mon Oct 31 18:00:30 1994
***************
*** 381,387 ****
  		"imull %%edx\n\t"
  		"idivl %3\n\t"
! 		: "=a" (result)			/* out */
! 		: "a" (m1), "d" (m2), "g" (d)	/* in */
! 		: "ax", "dx"			/* mod */
  	);
  	return result;
--- 381,387 ----
  		"imull %%edx\n\t"
  		"idivl %3\n\t"
! 		: "=&a" (result)		/* out */
! 		: "0" (m1), "d" (m2), "g" (d)	/* in */
! 		: "%edx"			/* mod */
  	);
  	return result;
diff -rc2 t/wine941030/rc/Imakefile wine941030/rc/Imakefile
*** t/wine941030/rc/Imakefile	Sun Oct 30 11:27:00 1994
--- wine941030/rc/Imakefile	Mon Oct 31 15:54:36 1994
***************
*** 7,11 ****
  	echo WINDOWS_H_ENDS_HERE >>$*.rct
  	cat $< >>$*.rct
! 	gcc -E -x c $(CFLAGS) $*.rct | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | winerc -v -p $* >$@
  	$(RM) $*.rct
  
--- 7,11 ----
  	echo WINDOWS_H_ENDS_HERE >>$*.rct
  	cat $< >>$*.rct
! 	gcc -E -x c $(CFLAGS) $*.rct | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | ./winerc -v -p $* >$@
  	$(RM) $*.rct
  
***************
*** 27,31 ****
  	winerc.c
  
! OBJS = $(SRCS:.c=.o)
  
  depend:: rc.tab.c rc.tab.h lex.yy.c
--- 27,31 ----
  	winerc.c
  
! OBJS = $(SRCS:.c=.o) /usr/lib/libl.a
  
  depend:: rc.tab.c rc.tab.h lex.yy.c
diff -rc2 t/wine941030/rc/rc.y wine941030/rc/rc.y
*** t/wine941030/rc/rc.y	Sun Oct 30 11:27:03 1994
--- wine941030/rc/rc.y	Mon Oct 31 15:50:06 1994
***************
*** 36,40 ****
  %%
  
! resource_file: resources {create_output($1)}
  
  /*resources are put into a linked list*/
--- 36,40 ----
  %%
  
! resource_file: resources {create_output($1);}
  
  /*resources are put into a linked list*/
diff -rc2 t/wine941030/rc/winerc.c wine941030/rc/winerc.c
*** t/wine941030/rc/winerc.c	Sun Oct 30 11:27:05 1994
--- wine941030/rc/winerc.c	Mon Oct 31 15:51:28 1994
***************
*** 30,34 ****
--- 30,38 ----
  	int optc,lose;
  	lose=0;
+ #ifdef __NetBSD__
+ 	while((optc=getopt(argc,argv,"dp:v"))!=-1)
+ #else
  	while((optc=getopt(argc,argv,"dp:v",0))!=EOF)
+ #endif
  		switch(optc)
  		{
diff -rc2 t/wine941030/toolkit/hello.c wine941030/toolkit/hello.c
*** t/wine941030/toolkit/hello.c	Mon Jun 20 13:01:21 1994
--- wine941030/toolkit/hello.c	Tue Nov  1 00:22:12 1994
***************
*** 52,56 ****
  	class.hInstance  = inst;
  	class.hIcon      = LoadIcon (0, IDI_APPLICATION);
! 	class.hCursor    = LoadCursor (0, IDC_ARROW);
  	class.hbrBackground = GetStockObject (WHITE_BRUSH);
  	class.lpszMenuName = NULL;
--- 52,56 ----
  	class.hInstance  = inst;
  	class.hIcon      = LoadIcon (0, IDI_APPLICATION);
! 	class.hCursor    = LoadCursor ((HANDLE)NULL, IDC_ARROW);
  	class.hbrBackground = GetStockObject (WHITE_BRUSH);
  	class.lpszMenuName = NULL;
diff -rc2 t/wine941030/tools/build.c wine941030/tools/build.c
*** t/wine941030/tools/build.c	Sun Oct 30 11:27:06 1994
--- wine941030/tools/build.c	Mon Oct 31 19:20:54 1994
***************
*** 630,634 ****
--- 630,638 ----
      context_strings[i] = PUSH_EIP;
  
+ #ifndef __FreeBSD__
+     i = n_context_strings - 1 + ((int) &context - (int) &context.sc_eflags) / 4;
+ #else
      i = n_context_strings - 1 + ((int) &context - (int) &context.sc_efl) / 4;
+ #endif
      context_strings[i] = PUSH_EFL;
      pop_strings[n_context_strings - 1 - i] = POP_EFL;
diff -rc2 t/wine941030/windows/cursor.c wine941030/windows/cursor.c
*** t/wine941030/windows/cursor.c	Sun Oct 30 11:27:07 1994
--- wine941030/windows/cursor.c	Mon Oct 31 15:59:35 1994
***************
*** 310,314 ****
      CURSORALLOC	*lpcur;
  
!     if (!(lpcur = (CURSORALLOC *)GlobalLock(hCursor))) return FALSE;
      if (rootWindow != DefaultRootWindow(display))
      {
--- 310,314 ----
      CURSORALLOC	*lpcur;
  
!     if (!(lpcur = (CURSORALLOC *)GlobalLock(hCursor))) return;
      if (rootWindow != DefaultRootWindow(display))
      {
diff -rc2 t/wine941030/windows/nonclient.c wine941030/windows/nonclient.c
*** t/wine941030/windows/nonclient.c	Sun Oct 30 11:27:11 1994
--- wine941030/windows/nonclient.c	Tue Nov  1 00:22:29 1994
***************
*** 734,754 ****
      case HTLEFT:
      case HTRIGHT:
! 	return SetCursor( LoadCursor( 0, IDC_SIZEWE ) );
  
      case HTTOP:
      case HTBOTTOM:
! 	return SetCursor( LoadCursor( 0, IDC_SIZENS ) );
  
      case HTTOPLEFT:
      case HTBOTTOMRIGHT:	
! 	return SetCursor( LoadCursor( 0, IDC_SIZENWSE ) );
  
      case HTTOPRIGHT:
      case HTBOTTOMLEFT:
! 	return SetCursor( LoadCursor( 0, IDC_SIZENESW ) );
      }
  
      /* Default cursor: arrow */
!     return SetCursor( LoadCursor( 0, IDC_ARROW ) );
  }
  
--- 734,754 ----
      case HTLEFT:
      case HTRIGHT:
! 	return SetCursor( LoadCursor( (HANDLE)NULL, IDC_SIZEWE ) );
  
      case HTTOP:
      case HTBOTTOM:
! 	return SetCursor( LoadCursor( (HANDLE)NULL, IDC_SIZENS ) );
  
      case HTTOPLEFT:
      case HTBOTTOMRIGHT:	
! 	return SetCursor( LoadCursor( (HANDLE)NULL, IDC_SIZENWSE ) );
  
      case HTTOPRIGHT:
      case HTBOTTOMLEFT:
! 	return SetCursor( LoadCursor( (HANDLE)NULL, IDC_SIZENESW ) );
      }
  
      /* Default cursor: arrow */
!     return SetCursor( LoadCursor( (HANDLE)NULL, IDC_ARROW ) );
  }
  
diff -rc2 t/wine941030/windows/win.c wine941030/windows/win.c
*** t/wine941030/windows/win.c	Sun Oct 30 11:27:13 1994
--- wine941030/windows/win.c	Tue Nov  1 00:22:34 1994
***************
*** 437,441 ****
          CURSORALLOC *cursor;
          HCURSOR hCursor = classPtr->wc.hCursor;
!         if (!hCursor) hCursor = LoadCursor( 0, IDC_ARROW );
          cursor = (CURSORALLOC *) GlobalLock(hCursor);
  
--- 437,441 ----
          CURSORALLOC *cursor;
          HCURSOR hCursor = classPtr->wc.hCursor;
!         if (!hCursor) hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW );
          cursor = (CURSORALLOC *) GlobalLock(hCursor);
  
-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----snip-----8<-----