Date: Sat, 5 Feb 2000 15:02:10 +0100 From: Juergen Lock <nox@jelal.kn-bremen.de> To: wine-patches@winehq.com, FreeBSD-emulation@FreeBSD.ORG, alex@big.endian.de Subject: get wine working again on FreeBSD Message-ID: <20000205150209.A18658@saturn.kn-bremen.de>
next in thread | raw e-mail | index | archive | help
Changelog:
* server/context_i386.c: Juergen Lock <nox@jelal.kn-bremen.de>
context functions for FreeBSD
* server/request.c, scheduler/client.c: Juergen Lock <nox@jelal.kn-bremen.de>
don't pass bogus lengths to bind/connect so the socket
doesn't end up being called "socke"
Index: server/context_i386.c
===================================================================
RCS file: /home/wine/wine/server/context_i386.c,v
retrieving revision 1.5
diff -u -u -r1.5 context_i386.c
--- server/context_i386.c 2000/01/30 22:22:23 1.5
+++ server/context_i386.c 2000/02/05 13:28:46
@@ -13,9 +13,10 @@
#ifdef HAVE_SYS_REG_H
#include <sys/reg.h>
#endif
+#include <unistd.h>
#include <sys/ptrace.h>
+#include <sys/param.h>
#include <sys/user.h>
-#include <unistd.h>
#include "winbase.h"
@@ -35,6 +36,12 @@
#ifndef PTRACE_GETFPREGS
#define PTRACE_GETFPREGS PT_GETFPREGS
#endif
+#ifndef PTRACE_SETREGS
+#define PTRACE_SETREGS PT_SETREGS
+#endif
+#ifndef PTRACE_SETFPREGS
+#define PTRACE_SETFPREGS PT_SETFPREGS
+#endif
#ifdef linux
@@ -287,10 +294,118 @@
error:
file_set_error();
}
+
+#elif defined(__FreeBSD__)
+#include <machine/reg.h>
+
+/* retrieve a thread context */
+static void get_thread_context( struct thread *thread, unsigned int flags, CONTEXT *context )
+{
+ int pid = thread->unix_pid;
+ if (flags & CONTEXT_FULL)
+ {
+ struct reg regs;
+ if (ptrace( PTRACE_GETREGS, pid, 0, (int) ®s ) == -1) goto error;
+ if (flags & CONTEXT_INTEGER)
+ {
+ context->Eax = regs.r_eax;
+ context->Ebx = regs.r_ebx;
+ context->Ecx = regs.r_ecx;
+ context->Edx = regs.r_edx;
+ context->Esi = regs.r_esi;
+ context->Edi = regs.r_edi;
+ }
+ if (flags & CONTEXT_CONTROL)
+ {
+ context->Ebp = regs.r_ebp;
+ context->Esp = regs.r_esp;
+ context->Eip = regs.r_eip;
+ context->SegCs = regs.r_cs & 0xffff;
+ context->SegSs = regs.r_ss & 0xffff;
+ context->EFlags = regs.r_eflags;
+ }
+ if (flags & CONTEXT_SEGMENTS)
+ {
+ context->SegDs = regs.r_ds & 0xffff;
+ context->SegEs = regs.r_es & 0xffff;
+ context->SegFs = regs.r_fs & 0xffff;
+ context->SegGs = regs.r_gs & 0xffff;
+ }
+ }
+ if (flags & CONTEXT_DEBUG_REGISTERS)
+ {
+ /* FIXME: How is this done on FreeBSD? */
+ }
+ if (flags & CONTEXT_FLOATING_POINT)
+ {
+ /* we can use context->FloatSave directly as it is using the */
+ /* correct structure (the same as fsave/frstor) */
+ if (ptrace( PTRACE_GETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error;
+ context->FloatSave.Cr0NpxState = 0; /* FIXME */
+ }
+ return;
+ error:
+ file_set_error();
+}
+
+
+/* set a thread context */
+static void set_thread_context( struct thread *thread, unsigned int flags, CONTEXT *context )
+{
+ int pid = thread->unix_pid;
+ if (flags & CONTEXT_FULL)
+ {
+ struct reg regs;
+ if ((flags & CONTEXT_FULL) != CONTEXT_FULL) /* need to preserve some registers */
+ {
+ if (ptrace( PTRACE_GETREGS, pid, 0, (int) ®s ) == -1) goto error;
+ }
+ if (flags & CONTEXT_INTEGER)
+ {
+ regs.r_eax = context->Eax;
+ regs.r_ebx = context->Ebx;
+ regs.r_ecx = context->Ecx;
+ regs.r_edx = context->Edx;
+ regs.r_esi = context->Esi;
+ regs.r_edi = context->Edi;
+ }
+ if (flags & CONTEXT_CONTROL)
+ {
+ regs.r_ebp = context->Ebp;
+ regs.r_esp = context->Esp;
+ regs.r_eip = context->Eip;
+ regs.r_cs = context->SegCs;
+ regs.r_ss = context->SegSs;
+ regs.r_eflags = context->EFlags;
+ }
+ if (flags & CONTEXT_SEGMENTS)
+ {
+ regs.r_ds = context->SegDs;
+ regs.r_es = context->SegEs;
+ regs.r_fs = context->SegFs;
+ regs.r_gs = context->SegGs;
+ }
+ if (ptrace( PTRACE_SETREGS, pid, 0, (int) ®s ) == -1) goto error;
+ }
+ if (flags & CONTEXT_DEBUG_REGISTERS)
+ {
+ /* FIXME: How is this done on FreeBSD? */
+ }
+ if (flags & CONTEXT_FLOATING_POINT)
+ {
+ /* we can use context->FloatSave directly as it is using the */
+ /* correct structure (the same as fsave/frstor) */
+ if (ptrace( PTRACE_SETFPREGS, pid, 0, (int) &context->FloatSave ) == -1) goto error;
+ context->FloatSave.Cr0NpxState = 0; /* FIXME */
+ }
+ return;
+ error:
+ file_set_error();
+}
-#else /* linux || __sun__ */
+#else /* linux || __sun__ || __FreeBSD__ */
#error You must implement get/set_thread_context for your platform
-#endif /* linux || __sun__*/
+#endif /* linux || __sun__ || __FreeBSD__ */
/* copy a context structure according to the flags */
Index: server/request.c
===================================================================
RCS file: /home/wine/wine/server/request.c,v
retrieving revision 1.26
diff -u -u -r1.26 request.c
--- server/request.c 2000/01/25 01:40:27 1.26
+++ server/request.c 2000/02/05 13:28:46
@@ -350,8 +350,9 @@
create_server_dir();
if ((fd = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" );
addr.sun_family = AF_UNIX;
- strcpy( addr.sun_path, "socket" );
- if (bind( fd, &addr, sizeof(addr.sun_family) + strlen(addr.sun_path) ) == -1)
+ strcpy( addr.sun_path, SOCKETNAME );
+ addr.sun_len = sizeof(addr);
+ if (bind( fd, (struct sockaddr *)&addr, sizeof(addr) ) == -1)
{
if ((errno == EEXIST) || (errno == EADDRINUSE))
fatal_error( "another server is already running\n" );
@@ -360,7 +361,7 @@
}
atexit( socket_cleanup );
- chmod( "socket", 0600 ); /* make sure no other user can connect */
+ chmod( SOCKETNAME, 0600 ); /* make sure no other user can connect */
if (listen( fd, 5 ) == -1) fatal_perror( "listen" );
if (!(master_socket = alloc_object( &master_socket_ops, fd )))
Index: scheduler/client.c
===================================================================
RCS file: /home/wine/wine/scheduler/client.c,v
retrieving revision 1.36
diff -u -u -r1.36 client.c
--- scheduler/client.c 2000/01/25 21:19:58 1.36
+++ scheduler/client.c 2000/02/05 13:28:45
@@ -366,7 +366,8 @@
if ((s = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" );
addr.sun_family = AF_UNIX;
strcpy( addr.sun_path, SOCKETNAME );
- if (connect( s, &addr, sizeof(addr.sun_family) + strlen(addr.sun_path) ) == -1)
+ addr.sun_len = sizeof(addr);
+ if (connect( s, (struct sockaddr *)&addr, sizeof(addr) ) == -1)
{
close( s );
return -2;
--
Juergen Lock <nox.foo@jelal.kn-bremen.de>
(remove dot foo from address to reply)
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-emulation" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000205150209.A18658>
