- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# include/compiler/iar.h

Go to the documentation of this file.

    00001
    00041 #ifndef COMPILER_IAR_H_INCLUDED
    00042 #define COMPILER_IAR_H_INCLUDED
    00043
    00044 #include <intrinsics.h>
    00045
    00046 #define __noreturn      __noreturn
    00047 #define __used          __root
    00048 #define __always_inline _Pragma("inline=forced")
    00049
    00050 #define barrier()       asm("")
    00051
    00052 /* These are undocumented, but appear to work */
    00053 #define min(a, b)       __min(a, b)
    00054 #define max(a, b)       __max(a, b)
    00055
    00056 /* Atomic operations. These are available as builtins on gcc */
    00057 static inline unsigned int __sync_or_and_fetch(unsigned int *addr,
    00058                 unsigned int mask)
    00059 {
    00060         unsigned int word;
    00061
    00062         do {
    00063                 __set_status_flag(5);
    00064                 barrier();
    00065                 word = *addr;
    00066                 word |= mask;
    00067         } while (!__store_conditional(addr, word));
    00068
    00069         barrier();
    00070
    00071         return word;
    00072 }
    00073
    00074 static inline unsigned int __sync_and_and_fetch(unsigned int *addr,
    00075                 unsigned int mask)
    00076 {
    00077         unsigned int word;
    00078
    00079         do {
    00080                 __set_status_flag(5);
    00081                 barrier();
    00082                 word = *addr;
    00083                 word &= mask;
    00084         } while (!__store_conditional(addr, word));
    00085
    00086         barrier();
    00087
    00088         return word;
    00089 }
    00090
    00091 static inline unsigned int __sync_xor_and_fetch(unsigned int *addr,
    00092                 unsigned int mask)
    00093 {
    00094         unsigned int word;
    00095
    00096         do {
    00097                 __set_status_flag(5);
    00098                 barrier();
    00099                 word = *addr;
    00100                 word ^= mask;
    00101         } while (!__store_conditional(addr, word));
    00102
    00103         barrier();
    00104
    00105         return word;
    00106 }
    00107
    00108 static inline unsigned int __sync_fetch_and_or(unsigned int *addr,
    00109                 unsigned int mask)
    00110 {
    00111         unsigned int word;
    00112         unsigned int old;
    00113
    00114         do {
    00115                 __set_status_flag(5);
    00116                 barrier();
    00117                 word = *addr;
    00118                 old = word;
    00119                 word |= mask;
    00120         } while (!__store_conditional(addr, word));
    00121
    00122         barrier();
    00123
    00124         return old;
    00125 }
    00126
    00127 static inline unsigned int __sync_fetch_and_and(unsigned int *addr,
    00128                 unsigned int mask)
    00129 {
    00130         unsigned int word;
    00131         unsigned int old;
    00132
    00133         do {
    00134                 __set_status_flag(5);
    00135                 barrier();
    00136                 word = *addr;
    00137                 old = word;
    00138                 word &= mask;
    00139         } while (!__store_conditional(addr, word));
    00140
    00141         barrier();
    00142
    00143         return old;
    00144 }
    00145
    00146 #endif /* COMPILER_IAR_H_INCLUDED */