Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ --> |
| 4 | <html> |
| 5 | <head> |
| 6 | <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| 7 | <title><atomic> design</title> |
| 8 | <link type="text/css" rel="stylesheet" href="menu.css"> |
| 9 | <link type="text/css" rel="stylesheet" href="content.css"> |
| 10 | </head> |
| 11 | |
| 12 | <body> |
| 13 | <div id="menu"> |
| 14 | <div> |
| 15 | <a href="http://llvm.org/">LLVM Home</a> |
| 16 | </div> |
| 17 | |
| 18 | <div class="submenu"> |
| 19 | <label>libc++ Info</label> |
| 20 | <a href="/index.html">About</a> |
| 21 | </div> |
| 22 | |
| 23 | <div class="submenu"> |
| 24 | <label>Quick Links</label> |
| 25 | <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a> |
| 26 | <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a> |
| 27 | <a href="http://llvm.org/bugs/">Bug Reports</a> |
| 28 | <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a> |
| 29 | <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a> |
| 30 | </div> |
| 31 | </div> |
| 32 | |
| 33 | <div id="content"> |
| 34 | <!--*********************************************************************--> |
| 35 | <h1><atomic> design</h1> |
| 36 | <!--*********************************************************************--> |
| 37 | |
| 38 | <p> |
| 39 | This is more of a synopsis than a true description. The compiler supplies all |
| 40 | of the intrinsics as described below. This list of intrinsics roughly parallels |
| 41 | the requirements of the C and C++ atomics proposals. The C and C++ library |
| 42 | imlpementations simply drop through to these intrinsics. Anything the platform |
| 43 | does not support in hardware, the compiler arranges for a (compiler-rt) library |
| 44 | call to be made which will do the job with a mutex, and in this case ignoring |
| 45 | the memory ordering parameter. |
| 46 | </p> |
| 47 | |
| 48 | <blockquote><pre> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 49 | <font color="#C80000">// In every intrinsic signature below, type* atomic_obj may be a pointer to a</font> |
| 50 | <font color="#C80000">// volatile-qualifed type.</font> |
| 51 | |
| 52 | <font color="#C80000">// type must be trivially copyable</font> |
Howard Hinnant | 08f2969 | 2010-10-08 17:36:50 +0000 | [diff] [blame] | 53 | bool __atomic_is_lock_free(const type* atomic_obj); |
| 54 | |
| 55 | <font color="#C80000">// type must be trivially copyable</font> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 56 | <font color="#C80000">// Behavior is defined for mem_ord = 0, 1, 2, 5</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 57 | type __atomic_load(const type* atomic_obj, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 58 | |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 59 | <font color="#C80000">// type must be trivially copyable</font> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 60 | <font color="#C80000">// Behavior is defined for mem_ord = 0, 3, 5</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 61 | type __atomic_store(type* atomic_obj, type desired, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 62 | |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 63 | <font color="#C80000">// type must be trivially copyable</font> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 64 | <font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 65 | type __atomic_exchange(type* atomic_obj, type desired, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 66 | |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 67 | <font color="#C80000">// type must be trivially copyable</font> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 68 | <font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 69 | <font color="#C80000">// mem_falure <= mem_success</font> |
| 70 | bool __atomic_compare_exchange_strong(type* atomic_obj, |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 71 | type* expected, type desired, |
| 72 | int mem_success, int mem_failure); |
| 73 | |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 74 | <font color="#C80000">// type must be trivially copyable</font> |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 75 | <font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 76 | <font color="#C80000">// mem_falure <= mem_success</font> |
| 77 | bool __atomic_compare_exchange_weak(type* atomic_obj, |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 78 | type* expected, type desired, |
| 79 | int mem_success, int mem_failure); |
| 80 | |
| 81 | <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font> |
| 82 | <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font> |
| 83 | <font color="#C80000">// char16_t, char32_t, wchar_t</font> |
| 84 | <font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 85 | type __atomic_fetch_add(type* atomic_obj, type operand, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 86 | |
| 87 | <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font> |
| 88 | <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font> |
| 89 | <font color="#C80000">// char16_t, char32_t, wchar_t</font> |
| 90 | <font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 91 | type __atomic_fetch_sub(type* atomic_obj, type operand, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 92 | |
| 93 | <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font> |
| 94 | <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font> |
| 95 | <font color="#C80000">// char16_t, char32_t, wchar_t</font> |
| 96 | <font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 97 | type __atomic_fetch_and(type* atomic_obj, type operand, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 98 | |
| 99 | <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font> |
| 100 | <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font> |
| 101 | <font color="#C80000">// char16_t, char32_t, wchar_t</font> |
| 102 | <font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 103 | type __atomic_fetch_or(type* atomic_obj, type operand, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 104 | |
| 105 | <font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font> |
| 106 | <font color="#C80000">// unsigned int, long, unsigned long, long long, unsigned long long,</font> |
| 107 | <font color="#C80000">// char16_t, char32_t, wchar_t</font> |
| 108 | <font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 109 | type __atomic_fetch_xor(type* atomic_obj, type operand, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 110 | |
| 111 | <font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font> |
Howard Hinnant | 77868b9 | 2010-10-07 14:18:37 +0000 | [diff] [blame] | 112 | void* __atomic_fetch_add(void** atomic_obj, ptrdiff_t operand, int mem_ord); |
| 113 | void* __atomic_fetch_sub(void** atomic_obj, ptrdiff_t operand, int mem_ord); |
Howard Hinnant | 086b718 | 2010-10-06 16:15:10 +0000 | [diff] [blame] | 114 | |
| 115 | <font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font> |
| 116 | void __atomic_thread_fence(int mem_ord); |
| 117 | void __atomic_signal_fence(int mem_ord); |
| 118 | </pre></blockquote> |
| 119 | |
| 120 | <p> |
| 121 | If desired the intrinsics taking a single <tt>mem_ord</tt> parameter can default |
| 122 | this argument to 5. |
| 123 | </p> |
| 124 | |
| 125 | <p> |
| 126 | If desired the intrinsics taking two ordering parameters can default |
| 127 | <tt>mem_success</tt> to 5, and <tt>mem_failure</tt> to <tt>mem_success</tt>. |
| 128 | </p> |
| 129 | |
| 130 | </div> |
| 131 | </body> |
| 132 | </html> |