kernel32: fix cpu detection on NetBSD
I submitted OpenBSD's patch for CPU detection a while back (http://www.winehq.org/pipermail/wine-patches/2009-January/067002.html). Francois sent a 'more correct' one (http://www.winehq.org/pipermail/wine-patches/2009-January/067382.html), but that one is broken on NetBSD/OpenBSD (http://bugs.winehq.org/show_bug.cgi?id=16927). With the below changes, it works again, but I'm not sure it's correct. Comments appreciated: diff --git a/dlls/kernel32/cpu.c b/dlls/kernel32/cpu.c index 95ac469..5bd3a38 100644 --- a/dlls/kernel32/cpu.c +++ b/dlls/kernel32/cpu.c @@ -547,7 +547,7 @@ VOID WINAPI GetSystemInfo( #elif defined (__NetBSD__) { int mib[2]; - int value; + int value[2]; size_t val_len; char model[256]; char *cpuclass; @@ -578,7 +579,7 @@ VOID WINAPI GetSystemInfo( mib[1] = HW_NCPU; val_len = sizeof(value); if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0) - if (value > cachedsi.dwNumberOfProcessors) + if (value[0] > cachedsi.dwNumberOfProcessors) cachedsi.dwNumberOfProcessors = value[0]; mib[1] = HW_MODEL; val_len = sizeof(model)-1; -- -Austin
On Fri, 16 Jan 2009, Austin English wrote:
I submitted OpenBSD's patch for CPU detection a while back (http://www.winehq.org/pipermail/wine-patches/2009-January/067002.html). Francois sent a 'more correct' one (http://www.winehq.org/pipermail/wine-patches/2009-January/067382.html), but that one is broken on NetBSD/OpenBSD (http://bugs.winehq.org/show_bug.cgi?id=16927).
Argh! Sorry. I missed some places where value is used so my patch was not quite right.
With the below changes, it works again, but I'm not sure it's correct. Comments appreciated: [...] - int value; + int value[2]; [...] if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
If you change value to an array, then &value will be an int**. AFAIU that's not what you for this sysctl. I think the attached patch would be better. Could you confirm? -- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ Hiroshima '45 - Czernobyl '86 - Windows '95
On Fri, Jan 16, 2009 at 5:35 PM, Francois Gouget <fgouget(a)free.fr> wrote:
On Fri, 16 Jan 2009, Austin English wrote:
I submitted OpenBSD's patch for CPU detection a while back (http://www.winehq.org/pipermail/wine-patches/2009-January/067002.html). Francois sent a 'more correct' one (http://www.winehq.org/pipermail/wine-patches/2009-January/067382.html), but that one is broken on NetBSD/OpenBSD (http://bugs.winehq.org/show_bug.cgi?id=16927).
Argh! Sorry. I missed some places where value is used so my patch was not quite right.
With the below changes, it works again, but I'm not sure it's correct. Comments appreciated: [...] - int value; + int value[2]; [...] if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0)
If you change value to an array, then &value will be an int**. AFAIU that's not what you for this sysctl.
I think the attached patch would be better. Could you confirm?
-- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ Hiroshima '45 - Czernobyl '86 - Windows '95
$ make ccache gcc -c -I. -I. -I../../include -I../../include -D__WINESRC__ -D_KERNEL32_ -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/freetype2 -I/usr/X11R6/include -O2 -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/freetype2 -I/usr/X11R6/include -o cpu.o cpu.c cpu.c: In function 'GetSystemInfo': cpu.c:573: error: subscripted value is neither array nor pointer *** Error code 1 Seems you forgot another one ;-). Your patch, plus this: @@ -570,7 +570,7 @@ VOID WINAPI GetSystemInfo( #endif #ifdef CPU_SSE2 mib[1] = CPU_SSE2; /* this should imply MMX */ - value[1] = sizeof(value); + val_len = sizeof(value); if (sysctl(mib, 2, &value, &val_len, NULL, 0) >= 0) if (value) PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE; #endif Gets it working again on NetBSD (I suspect OpenBSD will as well, but I won't be able to test until probably tomorrow). -- -Austin
On Fri, 16 Jan 2009, Austin English wrote: [...]
Gets it working again on NetBSD (I suspect OpenBSD will as well, but I won't be able to test until probably tomorrow).
Good, I'll update my patch and submit it. Do the results look good (SSE, etc)? -- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ Broadcast message : fin du monde dans cinq minutes, repentez vous !
On Fri, Jan 16, 2009 at 5:59 PM, Francois Gouget <fgouget(a)free.fr> wrote:
On Fri, 16 Jan 2009, Austin English wrote: [...]
Gets it working again on NetBSD (I suspect OpenBSD will as well, but I won't be able to test until probably tomorrow).
Good, I'll update my patch and submit it. Do the results look good (SSE, etc)?
-- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ Broadcast message : fin du monde dans cinq minutes, repentez vous !
Haven't been able to test real apps yet :-). I'm assuming you want me to test using, e.g., cpu-z? -- -Austin
On Fri, 16 Jan 2009, Austin English wrote: [...]
Haven't been able to test real apps yet :-).
I'm assuming you want me to test using, e.g., cpu-z?
I was thinking more of checking the traces. It looks like dlls/kernerl32/tests/thread.c (and a couple of others) call GetSystemInfo(), which should be sufficient to check the +reg traces (+reg? WTH?). -- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ In theory, theory and practice are the same, but in practice they're different.
On Sat, Jan 17, 2009 at 4:05 AM, Francois Gouget <fgouget(a)free.fr> wrote:
On Fri, 16 Jan 2009, Austin English wrote: [...]
Haven't been able to test real apps yet :-).
I'm assuming you want me to test using, e.g., cpu-z?
I was thinking more of checking the traces. It looks like dlls/kernerl32/tests/thread.c (and a couple of others) call GetSystemInfo(), which should be sufficient to check the +reg traces (+reg? WTH?).
-- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ In theory, theory and practice are the same, but in practice they're different.
bash-3.2$ make thread.ok ../../../tools/runtest -q -P wine -M kernel32.dll -T ../../.. -p kernel32_test.exe.so thread.c && touch thread.ok err:process:__wine_kernel_init boot event wait timed out assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" *** Error code 1 Stop. make: stopped in /home/austin/wine-git/dlls/kernel32/tests Haven't found a fix for that one yet. They've got a patch in their port to use use wine-kthread by default, but doesn't seem to help. -- -Austin
On Sat, 17 Jan 2009, Austin English wrote: [...]
bash-3.2$ make thread.ok ../../../tools/runtest -q -P wine -M kernel32.dll -T ../../.. -p kernel32_test.exe.so thread.c && touch thread.ok err:process:__wine_kernel_init boot event wait timed out assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" *** Error code 1
Stop. make: stopped in /home/austin/wine-git/dlls/kernel32/tests
Haven't found a fix for that one yet. They've got a patch in their port to use use wine-kthread by default, but doesn't seem to help.
Ok. That looks like another issue. Does anything run at all on NetBSD? -- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ The last time religion ruled, it was called the dark ages.
On Sun, Jan 18, 2009 at 06:40:30PM +0100, Francois Gouget wrote:
On Sat, 17 Jan 2009, Austin English wrote: [...]
bash-3.2$ make thread.ok ../../../tools/runtest -q -P wine -M kernel32.dll -T ../../.. -p kernel32_test.exe.so thread.c && touch thread.ok err:process:__wine_kernel_init boot event wait timed out assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" *** Error code 1
Stop. make: stopped in /home/austin/wine-git/dlls/kernel32/tests
Haven't found a fix for that one yet. They've got a patch in their port to use use wine-kthread by default, but doesn't seem to help.
Ok. That looks like another issue. Does anything run at all on NetBSD?
A lot of things run on NetBSD :-) Which version of NetBSD are you testing on? NetBSD 4 uses an m:n thread library, so there is no guarantee which system LWP will run which user thread (it will change dynamically). (In particular when one user thread wakes another, it can be pre-empted entirely in userspace.) NetBSD 5 uses a 1:1 thread library due to intractable problems on SMP systems. David -- David Laight: david(a)l8s.co.uk
On Sun, Jan 18, 2009 at 12:19 PM, David Laight <david(a)l8s.co.uk> wrote:
On Sun, Jan 18, 2009 at 06:40:30PM +0100, Francois Gouget wrote:
On Sat, 17 Jan 2009, Austin English wrote: [...]
bash-3.2$ make thread.ok ../../../tools/runtest -q -P wine -M kernel32.dll -T ../../.. -p kernel32_test.exe.so thread.c && touch thread.ok err:process:__wine_kernel_init boot event wait timed out assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" *** Error code 1
Stop. make: stopped in /home/austin/wine-git/dlls/kernel32/tests
Haven't found a fix for that one yet. They've got a patch in their port to use use wine-kthread by default, but doesn't seem to help.
Ok. That looks like another issue. Does anything run at all on NetBSD?
A lot of things run on NetBSD :-)
Which version of NetBSD are you testing on? NetBSD 4 uses an m:n thread library, so there is no guarantee which system LWP will run which user thread (it will change dynamically). (In particular when one user thread wakes another, it can be pre-empted entirely in userspace.)
NetBSD 5 uses a 1:1 thread library due to intractable problems on SMP systems.
David
-- David Laight: david(a)l8s.co.uk
I've got NetBSD 4.0.1. I'll see if I can't get 5.0 installed somewhere and try that. -- -Austin
On Sun, Jan 18, 2009 at 11:40 AM, Francois Gouget <fgouget(a)free.fr> wrote:
On Sat, 17 Jan 2009, Austin English wrote: [...]
bash-3.2$ make thread.ok ../../../tools/runtest -q -P wine -M kernel32.dll -T ../../.. -p kernel32_test.exe.so thread.c && touch thread.ok err:process:__wine_kernel_init boot event wait timed out assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" *** Error code 1
Stop. make: stopped in /home/austin/wine-git/dlls/kernel32/tests
Haven't found a fix for that one yet. They've got a patch in their port to use use wine-kthread by default, but doesn't seem to help.
Ok. That looks like another issue. Does anything run at all on NetBSD?
-- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ The last time religion ruled, it was called the dark ages.
I've just started testing it. Notepad runs, haven't tried anything more complex yet. -- -Austin
On Sun, Jan 18, 2009 at 11:40 AM, Francois Gouget <fgouget(a)free.fr> wrote:
On Sat, 17 Jan 2009, Austin English wrote: [...]
bash-3.2$ make thread.ok ../../../tools/runtest -q -P wine -M kernel32.dll -T ../../.. -p kernel32_test.exe.so thread.c && touch thread.ok err:process:__wine_kernel_init boot event wait timed out assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" assertion "thread->pt_blockgen == thread->pt_unblockgen" failed: file "/home/builds/ab/netbsd-4-0-1-RELEASE/src/lib/libpthread/pthread_lock.c", line 195, function "pthread_spinlock" *** Error code 1
Stop. make: stopped in /home/austin/wine-git/dlls/kernel32/tests
Haven't found a fix for that one yet. They've got a patch in their port to use use wine-kthread by default, but doesn't seem to help.
Ok. That looks like another issue. Does anything run at all on NetBSD?
-- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ The last time religion ruled, it was called the dark ages.
Also works fine on OpenBSD (compile at least). Would you go ahead and submit it? It'll be a couple days before I can setup 5.0. -- -Austin
participants (3)
-
Austin English -
David Laight -
Francois Gouget