* src/atomic_ops.c (AO_compare_and_swap_emulation): Remove.
* src/atomic_ops/sysdeps/emul_cas.h (AO_compare_and_swap_emulation,
AO_compare_and_swap_full, AO_HAVE_compare_and_swap_full): Likewise.
* src/atomic_ops/sysdeps/gcc/ia64.h (AO_compare_and_swap_acquire,
AO_HAVE_compare_and_swap_acquire, AO_compare_and_swap_release,
AO_HAVE_compare_and_swap_release, AO_char_compare_and_swap_acquire,
AO_HAVE_char_compare_and_swap_acquire,
AO_char_compare_and_swap_release,
AO_HAVE_char_compare_and_swap_release,
AO_short_compare_and_swap_acquire,
AO_HAVE_short_compare_and_swap_acquire,
AO_short_compare_and_swap_release,
AO_HAVE_short_compare_and_swap_release,
AO_int_compare_and_swap_acquire, AO_HAVE_int_compare_and_swap_acquire,
AO_int_compare_and_swap_release,
AO_HAVE_int_compare_and_swap_release): Likewise.
* src/atomic_ops/sysdeps/generic_pthread.h (AO_compare_and_swap_full):
Likewise.
* src/atomic_ops/sysdeps/hpc/ia64.h (AO_compare_and_swap_acquire,
AO_HAVE_compare_and_swap_acquire, AO_compare_and_swap_release,
AO_HAVE_compare_and_swap_release, AO_char_compare_and_swap_acquire,
AO_HAVE_char_compare_and_swap_acquire,
AO_char_compare_and_swap_release,
AO_HAVE_char_compare_and_swap_release,
AO_short_compare_and_swap_acquire,
AO_HAVE_short_compare_and_swap_acquire,
AO_short_compare_and_swap_release,
AO_HAVE_short_compare_and_swap_release): Likewise.
* src/atomic_ops/sysdeps/ibmc/powerpc.h (AO_compare_and_swap_acquire,
AO_HAVE_compare_and_swap_acquire, AO_compare_and_swap_release,
AO_HAVE_compare_and_swap_release, AO_compare_and_swap_full,
AO_HAVE_compare_and_swap_full): Likewise.
* src/atomic_ops/sysdeps/icc/ia64.h (AO_compare_and_swap_acquire,
AO_HAVE_compare_and_swap_acquire, AO_compare_and_swap_release,
AO_HAVE_compare_and_swap_release, AO_char_compare_and_swap_acquire,
AO_HAVE_char_compare_and_swap_acquire,
AO_char_compare_and_swap_release,
AO_HAVE_char_compare_and_swap_release,
AO_short_compare_and_swap_acquire,
AO_HAVE_short_compare_and_swap_acquire,
AO_short_compare_and_swap_release,
AO_HAVE_short_compare_and_swap_release,
AO_int_compare_and_swap_acquire, AO_HAVE_int_compare_and_swap_acquire,
AO_int_compare_and_swap_release,
AO_HAVE_int_compare_and_swap_release): Likewise.
* src/atomic_ops/sysdeps/msftc/common32_defs.h
(AO_compare_and_swap_full, AO_HAVE_compare_and_swap_full): Likewise.
* src/atomic_ops/sysdeps/msftc/x86_64.h (AO_compare_and_swap_full,
AO_HAVE_compare_and_swap_full): Likewise.
* src/atomic_ops.h: Do not include emul_cas.h if any of
AO_HAVE_fetch_compare_and_swap_... is defined.
* src/atomic_ops.h (AO_HAVE_fetch_compare_and_swap_full): Do not
define AO_GENERALIZE_TWICE if AO_HAVE_fetch_compare_and_swap_full
and AO_CAN_EMUL_CAS are both defined.
* src/atomic_ops/generalize-small.template
(AO_XSIZE_compare_and_swap_full, AO_XSIZE_compare_and_swap_acquire,
AO_XSIZE_compare_and_swap_release): New template (based on the
corresponding AO_XSIZE_fetch_compare_and_swap primitive).
* src/atomic_ops/generalize-small.template
(AO_HAVE_XSIZE_compare_and_swap_full,
AO_HAVE_XSIZE_compare_and_swap_acquire,
AO_HAVE_XSIZE_compare_and_swap_release): Define.
* src/atomic_ops/generalize.h (AO_HAVE_compare_and_swap,
AO_HAVE_compare_and_swap_full, AO_HAVE_compare_and_swap_acquire,
AO_HAVE_compare_and_swap_release): Likewise.
* src/atomic_ops/generalize-small.h: Regenerate.
* src/atomic_ops/generalize.h (AO_compare_and_swap,
AO_compare_and_swap_full, AO_compare_and_swap_acquire,
AO_compare_and_swap_release): New function implementation (based on
the corresponding AO_fetch_compare_and_swap primitive).
/*
- * Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
}
#endif /* !AO_USE_NO_SIGNALS */
-int AO_compare_and_swap_emulation(volatile AO_t *addr, AO_t old,
- AO_t new_val)
-{
- AO_TS_t *my_lock = AO_locks + AO_HASH(addr);
- int result;
-
-# ifndef AO_USE_NO_SIGNALS
- sigset_t old_sigs;
- block_all_signals(&old_sigs);
-# endif
-
- lock(my_lock);
- if (*addr == old)
- {
- *addr = new_val;
- result = 1;
- }
- else
- result = 0;
- unlock(my_lock);
-# ifndef AO_USE_NO_SIGNALS
- sigprocmask(SIG_SETMASK, &old_sigs, NULL);
-# endif
- return result;
-}
-
AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val,
AO_t new_val)
{
/*
- * Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#endif
#if defined(AO_REQUIRE_CAS) && !defined(AO_HAVE_compare_and_swap) \
+ && !defined(AO_HAVE_fetch_compare_and_swap) \
&& !defined(AO_HAVE_compare_and_swap_full) \
- && !defined(AO_HAVE_compare_and_swap_acquire)
+ && !defined(AO_HAVE_fetch_compare_and_swap_full) \
+ && !defined(AO_HAVE_compare_and_swap_acquire) \
+ && !defined(AO_HAVE_fetch_compare_and_swap_acquire)
# if defined(AO_CAN_EMUL_CAS)
# include "atomic_ops/sysdeps/emul_cas.h"
# else
/* The generalization section. */
#if !defined(AO_GENERALIZE_TWICE) && defined(AO_CAN_EMUL_CAS) \
- && !defined(AO_HAVE_compare_and_swap_full)
+ && !defined(AO_HAVE_compare_and_swap_full) \
+ && !defined(AO_HAVE_fetch_compare_and_swap_full)
# define AO_GENERALIZE_TWICE
#endif
/*
- * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
# define AO_HAVE_char_store_full
#endif
+/* AO_char_compare_and_swap */
+#if defined(AO_HAVE_char_fetch_compare_and_swap_full) \
+ && !defined(AO_HAVE_char_compare_and_swap_full)
+ AO_INLINE int
+ AO_char_compare_and_swap_full(volatile char *addr, char old_val,
+ char new_val)
+ {
+ return AO_char_fetch_compare_and_swap_full(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_char_compare_and_swap_full
+#endif
+
+#if defined(AO_HAVE_char_fetch_compare_and_swap_acquire) \
+ && !defined(AO_HAVE_char_compare_and_swap_acquire)
+ AO_INLINE int
+ AO_char_compare_and_swap_acquire(volatile char *addr, char old_val,
+ char new_val)
+ {
+ return AO_char_fetch_compare_and_swap_acquire(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_char_compare_and_swap_acquire
+#endif
+
+#if defined(AO_HAVE_char_fetch_compare_and_swap_release) \
+ && !defined(AO_HAVE_char_compare_and_swap_release)
+ AO_INLINE int
+ AO_char_compare_and_swap_release(volatile char *addr, char old_val,
+ char new_val)
+ {
+ return AO_char_fetch_compare_and_swap_release(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_char_compare_and_swap_release
+#endif
+
/* char_fetch_and_add */
#if defined(AO_HAVE_char_compare_and_swap_full) \
&& !defined(AO_HAVE_char_fetch_and_add_full)
# endif
#endif /* !AO_NO_DD_ORDERING */
/*
- * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
# define AO_HAVE_short_store_full
#endif
+/* AO_short_compare_and_swap */
+#if defined(AO_HAVE_short_fetch_compare_and_swap_full) \
+ && !defined(AO_HAVE_short_compare_and_swap_full)
+ AO_INLINE int
+ AO_short_compare_and_swap_full(volatile short *addr, short old_val,
+ short new_val)
+ {
+ return AO_short_fetch_compare_and_swap_full(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_short_compare_and_swap_full
+#endif
+
+#if defined(AO_HAVE_short_fetch_compare_and_swap_acquire) \
+ && !defined(AO_HAVE_short_compare_and_swap_acquire)
+ AO_INLINE int
+ AO_short_compare_and_swap_acquire(volatile short *addr, short old_val,
+ short new_val)
+ {
+ return AO_short_fetch_compare_and_swap_acquire(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_short_compare_and_swap_acquire
+#endif
+
+#if defined(AO_HAVE_short_fetch_compare_and_swap_release) \
+ && !defined(AO_HAVE_short_compare_and_swap_release)
+ AO_INLINE int
+ AO_short_compare_and_swap_release(volatile short *addr, short old_val,
+ short new_val)
+ {
+ return AO_short_fetch_compare_and_swap_release(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_short_compare_and_swap_release
+#endif
+
/* short_fetch_and_add */
#if defined(AO_HAVE_short_compare_and_swap_full) \
&& !defined(AO_HAVE_short_fetch_and_add_full)
# endif
#endif /* !AO_NO_DD_ORDERING */
/*
- * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
# define AO_HAVE_int_store_full
#endif
+/* AO_int_compare_and_swap */
+#if defined(AO_HAVE_int_fetch_compare_and_swap_full) \
+ && !defined(AO_HAVE_int_compare_and_swap_full)
+ AO_INLINE int
+ AO_int_compare_and_swap_full(volatile int *addr, int old_val,
+ int new_val)
+ {
+ return AO_int_fetch_compare_and_swap_full(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_int_compare_and_swap_full
+#endif
+
+#if defined(AO_HAVE_int_fetch_compare_and_swap_acquire) \
+ && !defined(AO_HAVE_int_compare_and_swap_acquire)
+ AO_INLINE int
+ AO_int_compare_and_swap_acquire(volatile int *addr, int old_val,
+ int new_val)
+ {
+ return AO_int_fetch_compare_and_swap_acquire(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_int_compare_and_swap_acquire
+#endif
+
+#if defined(AO_HAVE_int_fetch_compare_and_swap_release) \
+ && !defined(AO_HAVE_int_compare_and_swap_release)
+ AO_INLINE int
+ AO_int_compare_and_swap_release(volatile int *addr, int old_val,
+ int new_val)
+ {
+ return AO_int_fetch_compare_and_swap_release(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_int_compare_and_swap_release
+#endif
+
/* int_fetch_and_add */
#if defined(AO_HAVE_int_compare_and_swap_full) \
&& !defined(AO_HAVE_int_fetch_and_add_full)
/*
- * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
# define AO_HAVE_XSIZE_store_full
#endif
+/* AO_XSIZE_compare_and_swap */
+#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_full) \
+ && !defined(AO_HAVE_XSIZE_compare_and_swap_full)
+ AO_INLINE int
+ AO_XSIZE_compare_and_swap_full(volatile XCTYPE *addr, XCTYPE old_val,
+ XCTYPE new_val)
+ {
+ return AO_XSIZE_fetch_compare_and_swap_full(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_XSIZE_compare_and_swap_full
+#endif
+
+#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_acquire) \
+ && !defined(AO_HAVE_XSIZE_compare_and_swap_acquire)
+ AO_INLINE int
+ AO_XSIZE_compare_and_swap_acquire(volatile XCTYPE *addr, XCTYPE old_val,
+ XCTYPE new_val)
+ {
+ return AO_XSIZE_fetch_compare_and_swap_acquire(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_XSIZE_compare_and_swap_acquire
+#endif
+
+#if defined(AO_HAVE_XSIZE_fetch_compare_and_swap_release) \
+ && !defined(AO_HAVE_XSIZE_compare_and_swap_release)
+ AO_INLINE int
+ AO_XSIZE_compare_and_swap_release(volatile XCTYPE *addr, XCTYPE old_val,
+ XCTYPE new_val)
+ {
+ return AO_XSIZE_fetch_compare_and_swap_release(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_XSIZE_compare_and_swap_release
+#endif
+
/* XSIZE_fetch_and_add */
#if defined(AO_HAVE_XSIZE_compare_and_swap_full) \
&& !defined(AO_HAVE_XSIZE_fetch_and_add_full)
/*
- * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
# error This file should not be included directly.
#endif
+/* Emulate AO_compare_and_swap() via AO_fetch_compare_and_swap(). */
+#if defined(AO_HAVE_fetch_compare_and_swap) \
+ && !defined(AO_HAVE_compare_and_swap)
+ AO_INLINE int
+ AO_compare_and_swap(volatile AO_t *addr, AO_t old_val, AO_t new_val)
+ {
+ return AO_fetch_compare_and_swap(addr, old_val, new_val) == old_val;
+ }
+# define AO_HAVE_compare_and_swap
+#endif
+
+#if defined(AO_HAVE_fetch_compare_and_swap_full) \
+ && !defined(AO_HAVE_compare_and_swap_full)
+ AO_INLINE int
+ AO_compare_and_swap_full(volatile AO_t *addr, AO_t old_val, AO_t new_val)
+ {
+ return AO_fetch_compare_and_swap_full(addr, old_val, new_val) == old_val;
+ }
+# define AO_HAVE_compare_and_swap_full
+#endif
+
+#if defined(AO_HAVE_fetch_compare_and_swap_acquire) \
+ && !defined(AO_HAVE_compare_and_swap_acquire)
+ AO_INLINE int
+ AO_compare_and_swap_acquire(volatile AO_t *addr, AO_t old_val, AO_t new_val)
+ {
+ return AO_fetch_compare_and_swap_acquire(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_compare_and_swap_acquire
+#endif
+
+#if defined(AO_HAVE_fetch_compare_and_swap_release) \
+ && !defined(AO_HAVE_compare_and_swap_release)
+ AO_INLINE int
+ AO_compare_and_swap_release(volatile AO_t *addr, AO_t old_val, AO_t new_val)
+ {
+ return AO_fetch_compare_and_swap_release(addr, old_val, new_val)
+ == old_val;
+ }
+# define AO_HAVE_compare_and_swap_release
+#endif
+
#if AO_CHAR_TS_T
# define AO_TS_COMPARE_AND_SWAP_FULL(a,o,n) \
AO_char_compare_and_swap_full(a,o,n)
# include "standard_ao_double_t.h"
#endif
-int AO_compare_and_swap_emulation(volatile AO_t *addr, AO_t old,
- AO_t new_val);
-
AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val,
AO_t new_val);
void AO_store_full_emulation(volatile AO_t *addr, AO_t val);
-#define AO_compare_and_swap_full(addr, old, newval) \
- AO_compare_and_swap_emulation(addr, old, newval)
-#define AO_HAVE_compare_and_swap_full
-
#ifndef AO_HAVE_fetch_compare_and_swap_full
# define AO_fetch_compare_and_swap_full(addr, old, newval) \
AO_fetch_compare_and_swap_emulation(addr, old, newval)
/*
- * Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#endif /* !_ILP32 */
-AO_INLINE int
-AO_compare_and_swap_acquire(volatile AO_t *addr,
- AO_t old, AO_t new_val)
-{
- AO_t oldval;
- AO_MASK(old);
- __asm__ __volatile__(AO_SWIZZLE
- "mov ar.ccv=%[old] ;; cmpxchg" AO_LEN
- ".acq %0=[%1],%[new_val],ar.ccv"
- : "=r"(oldval) AO_OUT_ADDR
- : AO_IN_ADDR, [new_val]"r"(new_val), [old]"r"(old)
- : "memory");
- return (oldval == old);
-}
-#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_t oldval;
- AO_MASK(old);
- __asm__ __volatile__(AO_SWIZZLE
- "mov ar.ccv=%[old] ;; cmpxchg" AO_LEN
- ".rel %0=[%1],%[new_val],ar.ccv"
- : "=r"(oldval) AO_OUT_ADDR
- : AO_IN_ADDR, [new_val]"r"(new_val), [old]"r"(old)
- : "memory");
- return (oldval == old);
-}
-#define AO_HAVE_compare_and_swap_release
-
-AO_INLINE int
-AO_char_compare_and_swap_acquire(volatile unsigned char *addr,
- unsigned char old, unsigned char new_val)
-{
- unsigned char oldval;
- __asm__ __volatile__(AO_SWIZZLE
- "mov ar.ccv=%[old] ;; cmpxchg1.acq %0=[%1],%[new_val],ar.ccv"
- : "=r"(oldval) AO_OUT_ADDR
- : AO_IN_ADDR, [new_val]"r"(new_val), [old]"r"((AO_t)old)
- : "memory");
- return (oldval == old);
-}
-#define AO_HAVE_char_compare_and_swap_acquire
-
-AO_INLINE int
-AO_char_compare_and_swap_release(volatile unsigned char *addr,
- unsigned char old, unsigned char new_val)
-{
- unsigned char oldval;
- __asm__ __volatile__(AO_SWIZZLE
- "mov ar.ccv=%[old] ;; cmpxchg1.rel %0=[%1],%[new_val],ar.ccv"
- : "=r"(oldval) AO_OUT_ADDR
- : AO_IN_ADDR, [new_val]"r"(new_val), [old]"r"((AO_t)old)
- : "memory");
- return (oldval == old);
-}
-#define AO_HAVE_char_compare_and_swap_release
-
-AO_INLINE int
-AO_short_compare_and_swap_acquire(volatile unsigned short *addr,
- unsigned short old, unsigned short new_val)
-{
- unsigned short oldval;
- __asm__ __volatile__(AO_SWIZZLE
- "mov ar.ccv=%[old] ;; cmpxchg2.acq %0=[%1],%[new_val],ar.ccv"
- : "=r"(oldval) AO_OUT_ADDR
- : AO_IN_ADDR, [new_val]"r"(new_val), [old]"r"((AO_t)old)
- : "memory");
- return (oldval == old);
-}
-#define AO_HAVE_short_compare_and_swap_acquire
-
-AO_INLINE int
-AO_short_compare_and_swap_release(volatile unsigned short *addr,
- unsigned short old, unsigned short new_val)
-{
- unsigned short oldval;
- __asm__ __volatile__(AO_SWIZZLE
- "mov ar.ccv=%[old] ;; cmpxchg2.rel %0=[%1],%[new_val],ar.ccv"
- : "=r"(oldval) AO_OUT_ADDR
- : AO_IN_ADDR, [new_val]"r"(new_val), [old]"r"((AO_t)old)
- : "memory");
- return (oldval == old);
-}
-#define AO_HAVE_short_compare_and_swap_release
-
AO_INLINE AO_t
AO_fetch_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val)
{
#ifndef _ILP32
-AO_INLINE int
-AO_int_compare_and_swap_acquire(volatile unsigned int *addr,
- unsigned int old, unsigned int new_val)
-{
- unsigned int oldval;
- __asm__ __volatile__("mov ar.ccv=%3 ;; cmpxchg4.acq %0=[%1],%2,ar.ccv"
- : "=r"(oldval)
- : AO_IN_ADDR, "r"(new_val), "r"((AO_t)old) : "memory");
- return (oldval == old);
-}
-#define AO_HAVE_int_compare_and_swap_acquire
-
-AO_INLINE int
-AO_int_compare_and_swap_release(volatile unsigned int *addr,
- unsigned int old, unsigned int new_val)
-{
- unsigned int oldval;
- __asm__ __volatile__("mov ar.ccv=%3 ;; cmpxchg4.rel %0=[%1],%2,ar.ccv"
- : "=r"(oldval)
- : AO_IN_ADDR, "r"(new_val), "r"((AO_t)old) : "memory");
- return (oldval == old);
-}
-#define AO_HAVE_int_compare_and_swap_release
-
AO_INLINE unsigned int
AO_int_fetch_compare_and_swap_acquire(volatile unsigned int *addr,
unsigned int old, unsigned int new_val)
}
#define AO_HAVE_xor_full
-AO_INLINE int
-AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val)
-{
- pthread_mutex_lock(&AO_pt_lock);
- if (*addr == old)
- {
- *addr = new_val;
- pthread_mutex_unlock(&AO_pt_lock);
- return 1;
- }
- else
- pthread_mutex_unlock(&AO_pt_lock);
- return 0;
-}
-#define AO_HAVE_compare_and_swap_full
-
AO_INLINE AO_t
AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
AO_t new_val)
/*
- * Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
}
#define AO_HAVE_fetch_and_sub1_release
-AO_INLINE int
-AO_compare_and_swap_acquire(volatile AO_t *addr,
- AO_t old, AO_t new_val)
-{
- AO_t oldval;
-
- _Asm_mov_to_ar(_AREG_CCV, old, _DOWN_MEM_FENCE);
- oldval = _Asm_cmpxchg(AO_T_SIZE, _SEM_ACQ, addr,
- new_val, _LDHINT_NONE, _DOWN_MEM_FENCE);
- return (oldval == old);
-}
-#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_t oldval;
- _Asm_mov_to_ar(_AREG_CCV, old, _UP_MEM_FENCE);
- oldval = _Asm_cmpxchg(AO_T_SIZE, _SEM_REL, addr,
- new_val, _LDHINT_NONE, _UP_MEM_FENCE);
- /* Hopefully the compiler knows not to reorder the above two? */
- return (oldval == old);
-}
-#define AO_HAVE_compare_and_swap_release
-
-AO_INLINE int
-AO_char_compare_and_swap_acquire(volatile unsigned char *addr,
- unsigned char old, unsigned char new_val)
-{
- unsigned char oldval;
-
- _Asm_mov_to_ar(_AREG_CCV, old, _DOWN_MEM_FENCE);
- oldval = _Asm_cmpxchg(_SZ_B, _SEM_ACQ, addr,
- new_val, _LDHINT_NONE, _DOWN_MEM_FENCE);
- return (oldval == old);
-}
-#define AO_HAVE_char_compare_and_swap_acquire
-
-AO_INLINE int
-AO_char_compare_and_swap_release(volatile unsigned char *addr,
- unsigned char old, unsigned char new_val)
-{
- unsigned char oldval;
- _Asm_mov_to_ar(_AREG_CCV, old, _UP_MEM_FENCE);
- oldval = _Asm_cmpxchg(_SZ_B, _SEM_REL, addr,
- new_val, _LDHINT_NONE, _UP_MEM_FENCE);
- /* Hopefully the compiler knows not to reorder the above two? */
- return (oldval == old);
-}
-#define AO_HAVE_char_compare_and_swap_release
-
-AO_INLINE int
-AO_short_compare_and_swap_acquire(volatile unsigned short *addr,
- unsigned short old, unsigned short new_val)
-{
- unsigned short oldval;
-
- _Asm_mov_to_ar(_AREG_CCV, old, _DOWN_MEM_FENCE);
- oldval = _Asm_cmpxchg(_SZ_B, _SEM_ACQ, addr,
- new_val, _LDHINT_NONE, _DOWN_MEM_FENCE);
- return (oldval == old);
-}
-#define AO_HAVE_short_compare_and_swap_acquire
-
-AO_INLINE int
-AO_short_compare_and_swap_release(volatile unsigned short *addr,
- unsigned short old, unsigned short new_val)
-{
- unsigned short oldval;
- _Asm_mov_to_ar(_AREG_CCV, old, _UP_MEM_FENCE);
- oldval = _Asm_cmpxchg(_SZ_B, _SEM_REL, addr,
- new_val, _LDHINT_NONE, _UP_MEM_FENCE);
- /* Hopefully the compiler knows not to reorder the above two? */
- return (oldval == old);
-}
-#define AO_HAVE_short_compare_and_swap_release
-
AO_INLINE AO_t
AO_fetch_compare_and_swap_acquire(volatile AO_t *addr, AO_t old_val,
AO_t new_val)
}
#define AO_HAVE_test_and_set_full
-/*AO_INLINE int
-AO_compare_and_swap(volatile AO_t *addr, AO_t old, AO_t new_val)
-{
-# error FIXME Implement me
-}
-#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_lwsync();
- 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_lwsync();
- 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)
-{
- int result;
- AO_lwsync();
- result = AO_compare_and_swap(addr, old, new_val);
- AO_lwsync();
- return result;
-}
-#define AO_HAVE_compare_and_swap_full
-
/*AO_INLINE AO_t
AO_fetch_compare_and_swap(volatile AO_t *addr, AO_t old_val, AO_t new_val)
{
}
#define AO_HAVE_fetch_and_sub1_release
-AO_INLINE int
-AO_compare_and_swap_acquire(volatile AO_t *addr,
- AO_t old, AO_t new_val)
-{
- AO_t oldval;
- oldval = _InterlockedCompareExchange64_acq(addr, new_val, old);
- return (oldval == old);
-}
-#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_t oldval;
- oldval = _InterlockedCompareExchange64_rel(addr, new_val, old);
- return (oldval == old);
-}
-#define AO_HAVE_compare_and_swap_release
-
-AO_INLINE int
-AO_char_compare_and_swap_acquire(volatile unsigned char *addr,
- unsigned char old, unsigned char new_val)
-{
- unsigned char oldval;
- oldval = _InterlockedCompareExchange8_acq(addr, new_val, old);
- return (oldval == old);
-}
-#define AO_HAVE_char_compare_and_swap_acquire
-
-AO_INLINE int
-AO_char_compare_and_swap_release(volatile unsigned char *addr,
- unsigned char old, unsigned char new_val)
-{
- unsigned char oldval;
- oldval = _InterlockedCompareExchange8_rel(addr, new_val, old);
- return (oldval == old);
-}
-#define AO_HAVE_char_compare_and_swap_release
-
-AO_INLINE int
-AO_short_compare_and_swap_acquire(volatile unsigned short *addr,
- unsigned short old, unsigned short new_val)
-{
- unsigned short oldval;
- oldval = _InterlockedCompareExchange16_acq(addr, new_val, old);
- return (oldval == old);
-}
-#define AO_HAVE_short_compare_and_swap_acquire
-
-AO_INLINE int
-AO_short_compare_and_swap_release(volatile unsigned short *addr,
- unsigned short old, unsigned short new_val)
-{
- unsigned short oldval;
- oldval = _InterlockedCompareExchange16_rel(addr, new_val, old);
- return (oldval == old);
-}
-#define AO_HAVE_short_compare_and_swap_release
-
-AO_INLINE int
-AO_int_compare_and_swap_acquire(volatile unsigned int *addr,
- unsigned int old, unsigned int new_val)
-{
- unsigned int oldval;
- oldval = _InterlockedCompareExchange_acq(addr, new_val, old);
- return (oldval == old);
-}
-#define AO_HAVE_int_compare_and_swap_acquire
-
-AO_INLINE int
-AO_int_compare_and_swap_release(volatile unsigned int *addr,
- unsigned int old, unsigned int new_val)
-{
- unsigned int oldval;
- oldval = _InterlockedCompareExchange_rel(addr, new_val, old);
- return (oldval == old);
-}
-#define AO_HAVE_int_compare_and_swap_release
-
AO_INLINE AO_t
AO_fetch_compare_and_swap_acquire(volatile AO_t *addr, AO_t old_val,
AO_t new_val)
/*
- * Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#define AO_HAVE_fetch_and_sub1_full
#ifdef AO_ASSUME_WINDOWS98
-/* Returns nonzero if the comparison succeeded. */
-AO_INLINE int
-AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val)
-{
-# ifdef AO_OLD_STYLE_INTERLOCKED_COMPARE_EXCHANGE
- return _InterlockedCompareExchange((PVOID AO_INTERLOCKED_VOLATILE *)addr,
- (PVOID)new_val, (PVOID)old)
- == (PVOID)old;
-# else
- return _InterlockedCompareExchange((LONG AO_INTERLOCKED_VOLATILE *)addr,
- (LONG)new_val, (LONG)old)
- == (LONG)old;
-# endif
-}
-# define AO_HAVE_compare_and_swap_full
-
AO_INLINE AO_t
AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
AO_t new_val)
(PVOID)new_val, (PVOID)old_val);
# else
return (AO_t)_InterlockedCompareExchange(
- (LONG AO_INTERLOCKED_VOLATILE *)addr,
- (LONG)new_val, (LONG)old_val);
+ (LONG AO_INTERLOCKED_VOLATILE *)addr,
+ (LONG)new_val, (LONG)old_val);
# endif
}
# define AO_HAVE_fetch_compare_and_swap_full
/*
- * Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
+ * Copyright (c) 2003-2011 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
}
#define AO_HAVE_fetch_and_sub1_full
-AO_INLINE int
-AO_compare_and_swap_full(volatile AO_t *addr,
- AO_t old, AO_t new_val)
-{
- return _InterlockedCompareExchange64((LONGLONG volatile *)addr,
- (LONGLONG)new_val, (LONGLONG)old)
- == (LONGLONG)old;
-}
-#define AO_HAVE_compare_and_swap_full
-
AO_INLINE AO_t
AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val,
AO_t new_val)