From 0d963613b033823a337b02a45c6c867fec54a52f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 11 Nov 2012 10:56:01 +0000 Subject: [PATCH] * winbase.h: Semi-reinstantiate to workaround lack inline assembler implementation of InterlockedCompareExchange for i686 in Mingw64 headers. * pinfo.cc (pinfo::init): Remove unused variable mapaddr. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/pinfo.cc | 11 +++-------- winsup/cygwin/winbase.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 winsup/cygwin/winbase.h diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f6c4305fb..8594dd1b1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2012-11-11 Corinna Vinschen + + * winbase.h: Semi-reinstantiate to workaround lack inline assembler + implementation of InterlockedCompareExchange for i686 in Mingw64 + headers. + * pinfo.cc (pinfo::init): Remove unused variable mapaddr. + 2012-11-08 Corinna Vinschen * sigproc.cc (proc_subproc): Delete unused variable child. diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index ecd0f6cce..7280bce54 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -242,7 +242,6 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0) return; } - void *mapaddr; int createit = flag & (PID_IN_USE | PID_EXECED); DWORD access = FILE_MAP_READ | (flag & (PID_IN_USE | PID_EXECED | PID_MAP_RW) @@ -284,13 +283,9 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0) if (exit_state) return; - switch (GetLastError ()) - { - case ERROR_INVALID_HANDLE: - api_fatal ("MapViewOfFileEx h0 %p, i %d failed, %E", h0, i); - case ERROR_INVALID_ADDRESS: - mapaddr = NULL; - } + if (GetLastError () == ERROR_INVALID_HANDLE) + api_fatal ("MapViewOfFileEx h0 %p, i %d failed, %E", h0, i); + debug_printf ("MapViewOfFileEx h0 %p, i %d failed, %E", h0, i); yield (); continue; diff --git a/winsup/cygwin/winbase.h b/winsup/cygwin/winbase.h new file mode 100644 index 000000000..ae4794cc4 --- /dev/null +++ b/winsup/cygwin/winbase.h @@ -0,0 +1,35 @@ +/* winbase.h + + Copyright 2002, 2003, 2004, 2008, 2009, 2012 Red Hat, Inc. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +#include_next "winbase.h" + +#ifndef _WINBASE2_H +#define _WINBASE2_H + +#ifndef __x86_64__ +extern __inline__ LONG +ilockcmpexch (volatile LONG *t, LONG v, LONG c) +{ + return + ({ + register LONG ret __asm ("%eax"); + __asm __volatile ("lock cmpxchgl %2, %1" + : "=a" (ret), "=m" (*t) + : "r" (v), "m" (*t), "0" (c) + : "memory"); + ret; + }); +} + +#undef InterlockedCompareExchange +#define InterlockedCompareExchange ilockcmpexch +#undef InterlockedCompareExchangePointer +#define InterlockedCompareExchangePointer(d,e,c) \ + (PVOID)InterlockedCompareExchange((LONG volatile *)(d),(LONG)(e),(LONG)(c)) +#endif /* !__x86_64 */ +#endif /*_WINBASE2_H*/