patch for server/context_i386.c

Pierre Beyssac pb-wine at fasterix.frmug.org
Fri Nov 8 07:58:15 CST 2002


This is a "portable" version of a recent patch by Alfred Perstein
sent to Wine by Gerald Pfeifer.

To make a long story short, due to changes in struct dbreg on FreeBSD 5,
a patch is necessary to get context_i386.c to compile, but the
(FreeBSD 4 & 5 -specific) DBREG_DRX macro has to be used carefully
so as not to break compatibility with other BSDs.

The following patch avoids such compatibility issues.

Pierre

--- context_i386.c.orig	Wed Aug 14 22:59:03 2002
+++ context_i386.c	Fri Nov  8 11:29:34 2002
@@ -373,6 +373,15 @@
 	struct dbreg dbregs;
         if (ptrace( PTRACE_GETDBREGS, pid, (caddr_t) &dbregs, 0 ) == -1)
 		goto error;
+#ifdef DBREG_DRX
+	/* needed for FreeBSD, the structure fields have changed under 5.x */
+	context->Dr0 = DBREG_DRX((&dbregs), 0);
+	context->Dr1 = DBREG_DRX((&dbregs), 1);
+	context->Dr2 = DBREG_DRX((&dbregs), 2);
+	context->Dr3 = DBREG_DRX((&dbregs), 3);
+	context->Dr6 = DBREG_DRX((&dbregs), 6);
+	context->Dr7 = DBREG_DRX((&dbregs), 7);
+#else
 	context->Dr0 = dbregs.dr0;
 	context->Dr1 = dbregs.dr1;
 	context->Dr2 = dbregs.dr2;
@@ -380,6 +389,8 @@
 	context->Dr6 = dbregs.dr6;
 	context->Dr7 = dbregs.dr7;
 #endif
+
+#endif
     }
     if (flags & CONTEXT_FLOATING_POINT)
     {
@@ -437,6 +448,17 @@
     {
 #ifdef PTRACE_SETDBREGS
 	struct dbreg dbregs;
+#ifdef DBREG_DRX
+	/* needed for FreeBSD, the structure fields have changed under 5.x */
+	DBREG_DRX((&dbregs), 0) = context->Dr0;
+	DBREG_DRX((&dbregs), 1) = context->Dr1;
+	DBREG_DRX((&dbregs), 2) = context->Dr2;
+	DBREG_DRX((&dbregs), 3) = context->Dr3;
+	DBREG_DRX((&dbregs), 4) = 0;
+	DBREG_DRX((&dbregs), 5) = 0;
+	DBREG_DRX((&dbregs), 6) = context->Dr6;
+	DBREG_DRX((&dbregs), 7) = context->Dr7;
+#else
 	dbregs.dr0 = context->Dr0;
 	dbregs.dr1 = context->Dr1;
 	dbregs.dr2 = context->Dr2;
@@ -445,6 +467,7 @@
 	dbregs.dr5 = 0;
 	dbregs.dr6 = context->Dr6;
 	dbregs.dr7 = context->Dr7;
+#endif
         if (ptrace( PTRACE_SETDBREGS, pid, (caddr_t) &dbregs, 0 ) == -1)
 		goto error;
 #endif
-- 
Pierre Beyssac	      	    pb at fasterix.frmug.org pb at fasterix.freenix.org
    Free domains: http://www.eu.org/ or mail dns-manager at EU.org



More information about the wine-patches mailing list