From b67171535879acf1ee66751d7ada33a99b27419e Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 6 Jul 2003 20:08:42 +0000 Subject: * syscalls.cc (gethostid): Set thread affinity so that results are predictable. --- winsup/cygwin/syscalls.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'winsup/cygwin/syscalls.cc') diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index a22f4ee06..5ef18ce7e 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -2787,6 +2787,11 @@ long gethostid(void) 0x00290012}; bool has_cpuid = false; + sigframe thisframe (mainthread); + + DWORD opmask = SetThreadAffinityMask (GetCurrentThread (), 1); + if (!opmask) + debug_printf ("SetThreadAffinityMask to 1 failed, %E"); if (!can_set_flag (0x00040000)) debug_printf ("386 processor - no cpuid"); @@ -2870,6 +2875,9 @@ long gethostid(void) for (int i=0;i<13;i++) hostid ^= ((data[i] << (i << 2)) | (data[i] >> (32 - (i << 2)))); + if (opmask && !SetThreadAffinityMask (GetCurrentThread (), opmask)) + debug_printf ("SetThreadAffinityMask to %p failed, %E", opmask); + debug_printf ("hostid: %08x", hostid); return hostid; -- cgit v1.2.3