linux-atomic.c (EBUSY): Define if not _LP64.
authorHelge Deller <deller@gmx.de>
Sun, 23 Nov 2008 21:14:59 +0000 (21:14 +0000)
committerJohn David Anglin <danglin@gcc.gnu.org>
Sun, 23 Nov 2008 21:14:59 +0000 (21:14 +0000)
* pa/linux-atomic.c (EBUSY): Define if not _LP64.
(__kernel_cmpxchg): Return -EBUSY if the kernel LWS call
succeeded and lws_ret is not equal to oldval.

From-SVN: r142141

gcc/ChangeLog
gcc/config/pa/linux-atomic.c

index a7b3f9f93a38888f1ff82b484b16f9a10a1ba95a..1a5ab353a4f8924f221c4dc1a1b2248d8f3bbb6a 100644 (file)
@@ -1,3 +1,9 @@
+2008-11-23  Helge Deller  <deller@gmx.de>
+
+       * pa/linux-atomic.c (EBUSY): Define if not _LP64.
+       (__kernel_cmpxchg): Return -EBUSY if the kernel LWS call
+       succeeded and lws_ret is not equal to oldval.
+
 2008-11-23  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        * config/sh/sh.md (consttable_4): Call mark_symbol_refs_as_used.
index 4f9780feaa9ba4416073e2a7ee98a427b25c8437..ca33ea6d9d6b44c114a11d1d813f63d2dc10e901 100644 (file)
@@ -33,8 +33,9 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #ifndef _LP64
 #include <errno.h>
 #else 
+#define EFAULT  14 
+#define EBUSY   16
 #define ENOSYS 251 
-#define EFAULT 14 
 #endif 
 
 /* All PA-RISC implementations supported by linux have strongly
@@ -74,6 +75,13 @@ __kernel_cmpxchg (int oldval, int newval, int *mem)
   );
   if (__builtin_expect (lws_errno == -EFAULT || lws_errno == -ENOSYS, 0))
     ABORT_INSTRUCTION;
+
+  /* If the kernel LWS call succeeded (lws_errno == 0), lws_ret contains
+     the old value from memory.  If this value is equal to OLDVAL, the
+     new value was written to memory.  If not, return -EBUSY.  */
+  if (!lws_errno && lws_ret != oldval)
+    lws_errno = -EBUSY;
+
   return lws_errno;
 }