-/*
- * Copyright (c) 2005,2007 Thiemo Seufer <ths@networkno.de>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#include "../all_aligned_atomic_load_store.h"
-#include "../acquire_release_volatile.h"
-#include "../test_and_set_t_is_ao_t.h"
-#include "../standard_ao_double_t.h"
-
-/* Data dependence does not imply read ordering. */
-#define AO_NO_DD_ORDERING
-
-AO_INLINE void
-AO_nop_full()
-{
- __asm__ __volatile__(
- " .set push \n"
- " .set mips2 \n"
- " .set noreorder \n"
- " .set nomacro \n"
- " sync \n"
- " .set pop "
- : : : "memory");
-}
-
-#define AO_HAVE_nop_full
-
-AO_INLINE int
-AO_compare_and_swap(volatile AO_t *addr, AO_t old, AO_t new_val)
-{
- register int was_equal = 0;
- register int temp;
-
- __asm__ __volatile__(
- " .set push \n"
- " .set mips2 \n"
- " .set noreorder \n"
- " .set nomacro \n"
- "1: ll %0, %1 \n"
- " bne %0, %4, 2f \n"
- " move %0, %3 \n"
- " sc %0, %1 \n"
- " .set pop \n"
- " beqz %0, 1b \n"
- " li %2, 1 \n"
- "2: "
- : "=&r" (temp), "+R" (*addr), "+r" (was_equal)
- : "r" (new_val), "r" (old)
- : "memory");
- return was_equal;
-}
-
-#define AO_HAVE_compare_and_swap
-
-AO_INLINE int
-AO_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val) {
- int result = AO_compare_and_swap(addr, old, new_val);
- AO_nop_full();
- return result;
-}
-
-#define AO_HAVE_compare_and_swap_acquire
-
-AO_INLINE int
-AO_compare_and_swap_release(volatile AO_t *addr, AO_t old, AO_t new_val) {
- AO_nop_full();
- return AO_compare_and_swap(addr, old, new_val);
-}
-
-#define AO_HAVE_compare_and_swap_release
-
-AO_INLINE int
-AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) {
- AO_t result;
- AO_nop_full();
- result = AO_compare_and_swap(addr, old, new_val);
- AO_nop_full();
- return result;
-}
-
-#define AO_HAVE_compare_and_swap_full
-
-/*
- * FIXME: We should also implement fetch_and_add and or primitives
- * directly.
- */
-
-#include "../ao_t_is_int.h"
+/* \r
+ * Copyright (c) 2005,2007 Thiemo Seufer <ths@networkno.de>\r
+ *\r
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED\r
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.\r
+ *\r
+ * Permission is hereby granted to use or copy this program\r
+ * for any purpose, provided the above notices are retained on all copies.\r
+ * Permission to modify the code and to distribute modified code is granted,\r
+ * provided the above notices are retained, and a notice that the code was\r
+ * modified is included with the above copyright notice.\r
+ */\r
+\r
+/*\r
+ * FIXME: This should probably make finer distinctions. SGI MIPS is\r
+ * much more strongly ordered, and in fact closer to sequentially\r
+ * consistent. This is really aimed at modern embedded implementations.\r
+ * It looks to me like this assumes a 32-bit ABI. -HB\r
+ */\r
+\r
+#include "../all_aligned_atomic_load_store.h"\r
+#include "../acquire_release_volatile.h"\r
+#include "../test_and_set_t_is_ao_t.h"\r
+#include "../standard_ao_double_t.h"\r
+\r
+/* Data dependence does not imply read ordering. */\r
+#define AO_NO_DD_ORDERING\r
+\r
+AO_INLINE void\r
+AO_nop_full(void)\r
+{\r
+ __asm__ __volatile__(\r
+ " .set push \n"\r
+ " .set mips2 \n"\r
+ " .set noreorder \n"\r
+ " .set nomacro \n"\r
+ " sync \n"\r
+ " .set pop "\r
+ : : : "memory");\r
+}\r
+\r
+#define AO_HAVE_nop_full\r
+\r
+AO_INLINE int\r
+AO_compare_and_swap(volatile AO_t *addr, AO_t old, AO_t new_val)\r
+{\r
+ register int was_equal = 0;\r
+ register int temp;\r
+\r
+ __asm__ __volatile__(\r
+ " .set push \n"\r
+ " .set mips2 \n"\r
+ " .set noreorder \n"\r
+ " .set nomacro \n"\r
+ "1: ll %0, %1 \n"\r
+ " bne %0, %4, 2f \n"\r
+ " move %0, %3 \n"\r
+ " sc %0, %1 \n"\r
+ " .set pop \n"\r
+ " beqz %0, 1b \n"\r
+ " li %2, 1 \n"\r
+ "2: "\r
+ : "=&r" (temp), "+R" (*addr), "+r" (was_equal)\r
+ : "r" (new_val), "r" (old)\r
+ : "memory");\r
+ return was_equal;\r
+}\r
+\r
+#define AO_HAVE_compare_and_swap\r
+\r
+/* FIXME: I think the implementations below should be automatically */\r
+/* generated if we omit them. - HB */\r
+\r
+AO_INLINE int\r
+AO_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val) {\r
+ int result = AO_compare_and_swap(addr, old, new_val);\r
+ AO_nop_full();\r
+ return result;\r
+}\r
+\r
+#define AO_HAVE_compare_and_swap_acquire\r
+\r
+AO_INLINE int\r
+AO_compare_and_swap_release(volatile AO_t *addr, AO_t old, AO_t new_val) {\r
+ AO_nop_full();\r
+ return AO_compare_and_swap(addr, old, new_val);\r
+}\r
+\r
+#define AO_HAVE_compare_and_swap_release\r
+\r
+AO_INLINE int\r
+AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) {\r
+ AO_t result;\r
+ AO_nop_full();\r
+ result = AO_compare_and_swap(addr, old, new_val);\r
+ AO_nop_full();\r
+ return result;\r
+}\r
+\r
+#define AO_HAVE_compare_and_swap_full\r
+\r
+/*\r
+ * FIXME: We should also implement fetch_and_add and or primitives\r
+ * directly.\r
+ */\r
+\r
+#include "../ao_t_is_int.h"\r