summaryrefslogtreecommitdiffstats
path: root/cas.h
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-01-30 11:18:39 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-01-30 11:18:39 +0100
commit0042a0da85c2bd0d321e1e6ec22dfe0330ba6b9b (patch)
treecbf22fefafa1b891875743e741826cfad8fab5a2 /cas.h
parent4e1cc10bb6763bb034acab3e12b6dce0d5570386 (diff)
downloadlock_free-0042a0da85c2bd0d321e1e6ec22dfe0330ba6b9b.zip
lock_free-0042a0da85c2bd0d321e1e6ec22dfe0330ba6b9b.tar.gz
code cleanup
Diffstat (limited to 'cas.h')
-rw-r--r--cas.h56
1 files changed, 28 insertions, 28 deletions
diff --git a/cas.h b/cas.h
index 51312d1..8f88d91 100644
--- a/cas.h
+++ b/cas.h
@@ -1,7 +1,7 @@
/*
* File : cas.h
* Author : Jérémy Zurcher <jeremy@asynk.ch>
- * Date : 25/01/13
+ * Date : 2013/01/25
* License :
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -50,8 +50,8 @@ extern "C" {
struct _cas_pointer_t
{
- _cas_field_t lo;
- _cas_field_t hi;
+ _cas_field_t lo;
+ _cas_field_t hi;
} __attribute__ (( __aligned__( _cas_aligned ) ));
typedef struct _cas_pointer_t cas_pointer_t;
@@ -63,39 +63,39 @@ typedef struct _cas_pointer_t cas_pointer_t;
inline int cas(volatile cas_pointer_t* mem, cas_pointer_t old_val, cas_pointer_t new_val)
{
- char success;
+ char success;
#if defined(__i386__) && defined(__GNUC__)
- asm volatile("lock cmpxchg8b (%6);"
- "setz %7;"
- : "=a" ( old_val.lo ),
- "=d" ( old_val.hi )
- : "0" ( old_val.lo ),
- "1" ( old_val.hi ),
- "b" ( new_val.lo ),
- "c" ( new_val.hi ),
- "r" ( mem ),
- "m" ( success )
- : "cc", "memory"
- );
+ asm volatile("lock cmpxchg8b (%6);"
+ "setz %7;"
+ : "=a" ( old_val.lo )
+ , "=d" ( old_val.hi )
+ : "0" ( old_val.lo )
+ , "1" ( old_val.hi )
+ , "b" ( new_val.lo )
+ , "c" ( new_val.hi )
+ , "r" ( mem )
+ , "m" ( success )
+ : "cc", "memory"
+ );
#elif defined(__x86_64__) && defined(__GNUC__)
- asm volatile (
- "lock cmpxchg16b %1;"
- "setz %0;"
- : "=q" ( success )
- , "+m" ( *mem )
- , "+d" ( old_val.hi )
- , "+a" ( old_val.lo )
- : "c" ( new_val.hi )
- , "b" ( new_val.lo )
- : "cc", "memory"
- );
+ asm volatile (
+ "lock cmpxchg16b %1;"
+ "setz %0;"
+ : "=q" ( success )
+ , "+m" ( *mem )
+ , "+d" ( old_val.hi )
+ , "+a" ( old_val.lo )
+ : "c" ( new_val.hi )
+ , "b" ( new_val.lo )
+ : "cc", "memory"
+ );
#endif
- return (int)success;
+ return (int)success;
}
# ifdef __cplusplus