00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00035 #ifndef LIBC_ia64_ATOMIC_H_
00036 #define LIBC_ia64_ATOMIC_H_
00037
00038 #define LIBC_ARCH_ATOMIC_H_
00039
00040 #include <atomicdflt.h>
00041
00042 static inline void atomic_inc(atomic_t *val)
00043 {
00044 atomic_count_t v;
00045
00046 asm volatile (
00047 "fetchadd8.rel %[v] = %[count], 1\n"
00048 : [v] "=r" (v),
00049 [count] "+m" (val->count)
00050 );
00051 }
00052
00053 static inline void atomic_dec(atomic_t *val)
00054 {
00055 atomic_count_t v;
00056
00057 asm volatile (
00058 "fetchadd8.rel %[v] = %[count], -1\n"
00059 : [v] "=r" (v),
00060 [count] "+m" (val->count)
00061 );
00062 }
00063
00064 static inline atomic_count_t atomic_preinc(atomic_t *val)
00065 {
00066 atomic_count_t v;
00067
00068 asm volatile (
00069 "fetchadd8.rel %[v] = %[count], 1\n"
00070 : [v] "=r" (v),
00071 [count] "+m" (val->count)
00072 );
00073
00074 return (v + 1);
00075 }
00076
00077 static inline atomic_count_t atomic_predec(atomic_t *val)
00078 {
00079 atomic_count_t v;
00080
00081 asm volatile (
00082 "fetchadd8.rel %[v] = %[count], -1\n"
00083 : [v] "=r" (v),
00084 [count] "+m" (val->count)
00085 );
00086
00087 return (v - 1);
00088 }
00089
00090 static inline atomic_count_t atomic_postinc(atomic_t *val)
00091 {
00092 atomic_count_t v;
00093
00094 asm volatile (
00095 "fetchadd8.rel %[v] = %[count], 1\n"
00096 : [v] "=r" (v),
00097 [count] "+m" (val->count)
00098 );
00099
00100 return v;
00101 }
00102
00103 static inline atomic_count_t atomic_postdec(atomic_t *val)
00104 {
00105 atomic_count_t v;
00106
00107 asm volatile (
00108 "fetchadd8.rel %[v] = %[count], -1\n"
00109 : [v] "=r" (v),
00110 [count] "+m" (val->count)
00111 );
00112
00113 return v;
00114 }
00115
00116 #endif
00117