Merge remote branch 'origin/urcu/ht' into urcu/ht
[urcu.git] / compat_arch_x86.c
index 41c6848fae195cfbc6e24837a4445d3ddbd02f88..714201b01b78d9efbfaa110c9e27dfbb6e2a5557 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Userspace RCU library - x86 compatibility checks
  *
- * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+ * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,7 @@
 #include <pthread.h>
 #include <signal.h>
 #include <assert.h>
-#include <urcu/uatomic_arch.h>
+#include <urcu/uatomic.h>
 
 /*
  * It does not really matter if the constructor is called before using
@@ -122,10 +122,11 @@ unsigned long _compat_uatomic_set(void *addr, unsigned long _new, int len)
                 * generate an illegal instruction. Cannot catch this with
                 * linker tricks when optimizations are disabled.
                 */
+               result = 0;
                __asm__ __volatile__("ud2");
        }
        mutex_lock_signal_restore(&compat_mutex, &mask);
-       return _new;
+       return result;
 }
 
 unsigned long _compat_uatomic_xchg(void *addr, unsigned long _new, int len)
@@ -152,6 +153,7 @@ unsigned long _compat_uatomic_xchg(void *addr, unsigned long _new, int len)
                 * generate an illegal instruction. Cannot catch this with
                 * linker tricks when optimizations are disabled.
                 */
+               retval = 0;     /* silence gcc warnings */
                __asm__ __volatile__("ud2");
        }
        mutex_lock_signal_restore(&compat_mutex, &mask);
@@ -195,12 +197,63 @@ unsigned long _compat_uatomic_cmpxchg(void *addr, unsigned long old,
                 * generate an illegal instruction. Cannot catch this with
                 * linker tricks when optimizations are disabled.
                 */
+               retval = 0;     /* silence gcc warnings */
                __asm__ __volatile__("ud2");
        }
        mutex_lock_signal_restore(&compat_mutex, &mask);
        return retval;
 }
 
+void _compat_uatomic_or(void *addr, unsigned long v, int len)
+{
+       sigset_t mask;
+
+       mutex_lock_signal_save(&compat_mutex, &mask);
+       switch (len) {
+       case 1:
+               *(unsigned char *)addr |= (unsigned char)v;
+               break;
+       case 2:
+               *(unsigned short *)addr |= (unsigned short)v;
+               break;
+       case 4:
+               *(unsigned int *)addr |= (unsigned int)v;
+               break;
+       default:
+               /*
+                * generate an illegal instruction. Cannot catch this with
+                * linker tricks when optimizations are disabled.
+                */
+               __asm__ __volatile__("ud2");
+       }
+       mutex_lock_signal_restore(&compat_mutex, &mask);
+}
+
+void _compat_uatomic_and(void *addr, unsigned long v, int len)
+{
+       sigset_t mask;
+
+       mutex_lock_signal_save(&compat_mutex, &mask);
+       switch (len) {
+       case 1:
+               *(unsigned char *)addr &= (unsigned char)v;
+               break;
+       case 2:
+               *(unsigned short *)addr &= (unsigned short)v;
+               break;
+       case 4:
+               *(unsigned int *)addr &= (unsigned int)v;
+               break;
+       default:
+               /*
+                * generate an illegal instruction. Cannot catch this with
+                * linker tricks when optimizations are disabled.
+                */
+               __asm__ __volatile__("ud2");
+       }
+       mutex_lock_signal_restore(&compat_mutex, &mask);
+}
+
 unsigned long _compat_uatomic_add_return(void *addr, unsigned long v, int len)
 {
        sigset_t mask;
@@ -225,6 +278,7 @@ unsigned long _compat_uatomic_add_return(void *addr, unsigned long v, int len)
                 * generate an illegal instruction. Cannot catch this with
                 * linker tricks when optimizations are disabled.
                 */
+               result = 0;     /* silence gcc warnings */
                __asm__ __volatile__("ud2");
        }
        mutex_lock_signal_restore(&compat_mutex, &mask);
This page took 0.026946 seconds and 4 git commands to generate.