- Timestamp:
- Nov 26, 2019, 3:20:30 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d4f1521
- Parents:
- 7768b8d (diff), 58e280f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- libcfa
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
r7768b8d r30763fd 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jun 25 18:06:52201913 // Update Count : 9712 // Last Modified On : Thu Nov 21 16:31:39 2019 13 // Update Count : 101 14 14 // 15 15 … … 69 69 70 70 // universal typed pointer constant 71 // Compiler issue: there is a problem with anonymous types that do not have a size. 72 static inline forall( dtype DT | sized(DT) ) DT * intptr( uintptr_t addr ) { return (DT *)addr; } 71 static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; } 73 72 74 73 // exponentiation operator implementation -
libcfa/prelude/sync-builtins.cf
r7768b8d r30763fd 1 1 char __sync_fetch_and_add(volatile char *, char,...); 2 char __sync_fetch_and_add_1(volatile char *, char,...);3 2 signed char __sync_fetch_and_add(volatile signed char *, signed char,...); 4 signed char __sync_fetch_and_add_1(volatile signed char *, signed char,...);5 3 unsigned char __sync_fetch_and_add(volatile unsigned char *, unsigned char,...); 6 unsigned char __sync_fetch_and_add_1(volatile unsigned char *, unsigned char,...);7 4 signed short __sync_fetch_and_add(volatile signed short *, signed short,...); 8 signed short __sync_fetch_and_add_2(volatile signed short *, signed short,...);9 5 unsigned short __sync_fetch_and_add(volatile unsigned short *, unsigned short,...); 10 unsigned short __sync_fetch_and_add_2(volatile unsigned short *, unsigned short,...);11 6 signed int __sync_fetch_and_add(volatile signed int *, signed int,...); 12 signed int __sync_fetch_and_add_4(volatile signed int *, signed int,...);13 7 unsigned int __sync_fetch_and_add(volatile unsigned int *, unsigned int,...); 14 unsigned int __sync_fetch_and_add_4(volatile unsigned int *, unsigned int,...); 8 signed long int __sync_fetch_and_add(volatile signed long int *, signed long int,...); 9 unsigned long int __sync_fetch_and_add(volatile unsigned long int *, unsigned long int,...); 15 10 signed long long int __sync_fetch_and_add(volatile signed long long int *, signed long long int,...); 16 signed long long int __sync_fetch_and_add_8(volatile signed long long int *, signed long long int,...);17 11 unsigned long long int __sync_fetch_and_add(volatile unsigned long long int *, unsigned long long int,...); 18 unsigned long long int __sync_fetch_and_add_8(volatile unsigned long long int *, unsigned long long int,...);19 12 #if defined(__SIZEOF_INT128__) 20 13 signed __int128 __sync_fetch_and_add(volatile signed __int128 *, signed __int128,...); 21 signed __int128 __sync_fetch_and_add_16(volatile signed __int128 *, signed __int128,...);22 14 unsigned __int128 __sync_fetch_and_add(volatile unsigned __int128 *, unsigned __int128,...); 23 unsigned __int128 __sync_fetch_and_add_16(volatile unsigned __int128 *, unsigned __int128,...);24 15 #endif 25 16 26 17 char __sync_fetch_and_sub(volatile char *, char,...); 27 char __sync_fetch_and_sub_1(volatile char *, char,...);28 18 signed char __sync_fetch_and_sub(volatile signed char *, signed char,...); 29 signed char __sync_fetch_and_sub_1(volatile signed char *, signed char,...);30 19 unsigned char __sync_fetch_and_sub(volatile unsigned char *, unsigned char,...); 31 unsigned char __sync_fetch_and_sub_1(volatile unsigned char *, unsigned char,...);32 20 signed short __sync_fetch_and_sub(volatile signed short *, signed short,...); 33 signed short __sync_fetch_and_sub_2(volatile signed short *, signed short,...);34 21 unsigned short __sync_fetch_and_sub(volatile unsigned short *, unsigned short,...); 35 unsigned short __sync_fetch_and_sub_2(volatile unsigned short *, unsigned short,...);36 22 signed int __sync_fetch_and_sub(volatile signed int *, signed int,...); 37 signed int __sync_fetch_and_sub_4(volatile signed int *, signed int,...);38 23 unsigned int __sync_fetch_and_sub(volatile unsigned int *, unsigned int,...); 39 unsigned int __sync_fetch_and_sub_4(volatile unsigned int *, unsigned int,...); 24 signed long int __sync_fetch_and_sub(volatile signed long int *, signed long int,...); 25 unsigned long int __sync_fetch_and_sub(volatile unsigned long int *, unsigned long int,...); 40 26 signed long long int __sync_fetch_and_sub(volatile signed long long int *, signed long long int,...); 41 signed long long int __sync_fetch_and_sub_8(volatile signed long long int *, signed long long int,...);42 27 unsigned long long int __sync_fetch_and_sub(volatile unsigned long long int *, unsigned long long int,...); 43 unsigned long long int __sync_fetch_and_sub_8(volatile unsigned long long int *, unsigned long long int,...);44 28 #if defined(__SIZEOF_INT128__) 45 29 signed __int128 __sync_fetch_and_sub(volatile signed __int128 *, signed __int128,...); 46 signed __int128 __sync_fetch_and_sub_16(volatile signed __int128 *, signed __int128,...);47 30 unsigned __int128 __sync_fetch_and_sub(volatile unsigned __int128 *, unsigned __int128,...); 48 unsigned __int128 __sync_fetch_and_sub_16(volatile unsigned __int128 *, unsigned __int128,...);49 31 #endif 50 32 51 33 char __sync_fetch_and_or(volatile char *, char,...); 52 char __sync_fetch_and_or_1(volatile char *, char,...);53 34 signed char __sync_fetch_and_or(volatile signed char *, signed char,...); 54 signed char __sync_fetch_and_or_1(volatile signed char *, signed char,...);55 35 unsigned char __sync_fetch_and_or(volatile unsigned char *, unsigned char,...); 56 unsigned char __sync_fetch_and_or_1(volatile unsigned char *, unsigned char,...);57 36 signed short __sync_fetch_and_or(volatile signed short *, signed short,...); 58 signed short __sync_fetch_and_or_2(volatile signed short *, signed short,...);59 37 unsigned short __sync_fetch_and_or(volatile unsigned short *, unsigned short,...); 60 unsigned short __sync_fetch_and_or_2(volatile unsigned short *, unsigned short,...);61 38 signed int __sync_fetch_and_or(volatile signed int *, signed int,...); 62 signed int __sync_fetch_and_or_4(volatile signed int *, signed int,...);63 39 unsigned int __sync_fetch_and_or(volatile unsigned int *, unsigned int,...); 64 unsigned int __sync_fetch_and_or_4(volatile unsigned int *, unsigned int,...); 40 signed long int __sync_fetch_and_or(volatile signed long int *, signed long int,...); 41 unsigned long int __sync_fetch_and_or(volatile unsigned long int *, unsigned long int,...); 65 42 signed long long int __sync_fetch_and_or(volatile signed long long int *, signed long long int,...); 66 signed long long int __sync_fetch_and_or_8(volatile signed long long int *, signed long long int,...);67 43 unsigned long long int __sync_fetch_and_or(volatile unsigned long long int *, unsigned long long int,...); 68 unsigned long long int __sync_fetch_and_or_8(volatile unsigned long long int *, unsigned long long int,...);69 44 #if defined(__SIZEOF_INT128__) 70 45 signed __int128 __sync_fetch_and_or(volatile signed __int128 *, signed __int128,...); 71 signed __int128 __sync_fetch_and_or_16(volatile signed __int128 *, signed __int128,...);72 46 unsigned __int128 __sync_fetch_and_or(volatile unsigned __int128 *, unsigned __int128,...); 73 unsigned __int128 __sync_fetch_and_or_16(volatile unsigned __int128 *, unsigned __int128,...);74 47 #endif 75 48 76 49 char __sync_fetch_and_and(volatile char *, char,...); 77 char __sync_fetch_and_and_1(volatile char *, char,...);78 50 signed char __sync_fetch_and_and(volatile signed char *, signed char,...); 79 signed char __sync_fetch_and_and_1(volatile signed char *, signed char,...);80 51 unsigned char __sync_fetch_and_and(volatile unsigned char *, unsigned char,...); 81 unsigned char __sync_fetch_and_and_1(volatile unsigned char *, unsigned char,...);82 52 signed short __sync_fetch_and_and(volatile signed short *, signed short,...); 83 signed short __sync_fetch_and_and_2(volatile signed short *, signed short,...);84 53 unsigned short __sync_fetch_and_and(volatile unsigned short *, unsigned short,...); 85 unsigned short __sync_fetch_and_and_2(volatile unsigned short *, unsigned short,...);86 54 signed int __sync_fetch_and_and(volatile signed int *, signed int,...); 87 signed int __sync_fetch_and_and_4(volatile signed int *, signed int,...);88 55 unsigned int __sync_fetch_and_and(volatile unsigned int *, unsigned int,...); 89 unsigned int __sync_fetch_and_and_4(volatile unsigned int *, unsigned int,...); 56 signed long int __sync_fetch_and_and(volatile signed long int *, signed long int,...); 57 unsigned long int __sync_fetch_and_and(volatile unsigned long int *, unsigned long int,...); 90 58 signed long long int __sync_fetch_and_and(volatile signed long long int *, signed long long int,...); 91 signed long long int __sync_fetch_and_and_8(volatile signed long long int *, signed long long int,...);92 59 unsigned long long int __sync_fetch_and_and(volatile unsigned long long int *, unsigned long long int,...); 93 unsigned long long int __sync_fetch_and_and_8(volatile unsigned long long int *, unsigned long long int,...);94 60 #if defined(__SIZEOF_INT128__) 95 61 signed __int128 __sync_fetch_and_and(volatile signed __int128 *, signed __int128,...); 96 signed __int128 __sync_fetch_and_and_16(volatile signed __int128 *, signed __int128,...);97 62 unsigned __int128 __sync_fetch_and_and(volatile unsigned __int128 *, unsigned __int128,...); 98 unsigned __int128 __sync_fetch_and_and_16(volatile unsigned __int128 *, unsigned __int128,...);99 63 #endif 100 64 101 65 char __sync_fetch_and_xor(volatile char *, char,...); 102 char __sync_fetch_and_xor_1(volatile char *, char,...);103 66 signed char __sync_fetch_and_xor(volatile signed char *, signed char,...); 104 signed char __sync_fetch_and_xor_1(volatile signed char *, signed char,...);105 67 unsigned char __sync_fetch_and_xor(volatile unsigned char *, unsigned char,...); 106 unsigned char __sync_fetch_and_xor_1(volatile unsigned char *, unsigned char,...);107 68 signed short __sync_fetch_and_xor(volatile signed short *, signed short,...); 108 signed short __sync_fetch_and_xor_2(volatile signed short *, signed short,...);109 69 unsigned short __sync_fetch_and_xor(volatile unsigned short *, unsigned short,...); 110 unsigned short __sync_fetch_and_xor_2(volatile unsigned short *, unsigned short,...);111 70 signed int __sync_fetch_and_xor(volatile signed int *, signed int,...); 112 signed int __sync_fetch_and_xor_4(volatile signed int *, signed int,...);113 71 unsigned int __sync_fetch_and_xor(volatile unsigned int *, unsigned int,...); 114 unsigned int __sync_fetch_and_xor_4(volatile unsigned int *, unsigned int,...); 72 signed long int __sync_fetch_and_xor(volatile signed long int *, signed long int,...); 73 unsigned long int __sync_fetch_and_xor(volatile unsigned long int *, unsigned long int,...); 115 74 signed long long int __sync_fetch_and_xor(volatile signed long long int *, signed long long int,...); 116 signed long long int __sync_fetch_and_xor_8(volatile signed long long int *, signed long long int,...);117 75 unsigned long long int __sync_fetch_and_xor(volatile unsigned long long int *, unsigned long long int,...); 118 unsigned long long int __sync_fetch_and_xor_8(volatile unsigned long long int *, unsigned long long int,...);119 76 #if defined(__SIZEOF_INT128__) 120 77 signed __int128 __sync_fetch_and_xor(volatile signed __int128 *, signed __int128,...); 121 signed __int128 __sync_fetch_and_xor_16(volatile signed __int128 *, signed __int128,...);122 78 unsigned __int128 __sync_fetch_and_xor(volatile unsigned __int128 *, unsigned __int128,...); 123 unsigned __int128 __sync_fetch_and_xor_16(volatile unsigned __int128 *, unsigned __int128,...);124 79 #endif 125 80 126 81 char __sync_fetch_and_nand(volatile char *, char,...); 127 char __sync_fetch_and_nand_1(volatile char *, char,...);128 82 signed char __sync_fetch_and_nand(volatile signed char *, signed char,...); 129 signed char __sync_fetch_and_nand_1(volatile signed char *, signed char,...);130 83 unsigned char __sync_fetch_and_nand(volatile unsigned char *, unsigned char,...); 131 unsigned char __sync_fetch_and_nand_1(volatile unsigned char *, unsigned char,...);132 84 signed short __sync_fetch_and_nand(volatile signed short *, signed short,...); 133 signed short __sync_fetch_and_nand_2(volatile signed short *, signed short,...);134 85 unsigned short __sync_fetch_and_nand(volatile unsigned short *, unsigned short,...); 135 unsigned short __sync_fetch_and_nand_2(volatile unsigned short *, unsigned short,...);136 86 signed int __sync_fetch_and_nand(volatile signed int *, signed int,...); 137 signed int __sync_fetch_and_nand_4(volatile signed int *, signed int,...);138 87 unsigned int __sync_fetch_and_nand(volatile unsigned int *, unsigned int,...); 139 unsigned int __sync_fetch_and_nand_4(volatile unsigned int *, unsigned int,...); 88 signed long int __sync_fetch_and_nand(volatile signed long int *, signed long int,...); 89 unsigned long int __sync_fetch_and_nand(volatile unsigned long int *, unsigned long int,...); 140 90 signed long long int __sync_fetch_and_nand(volatile signed long long int *, signed long long int,...); 141 signed long long int __sync_fetch_and_nand_8(volatile signed long long int *, signed long long int,...);142 91 unsigned long long int __sync_fetch_and_nand(volatile unsigned long long int *, unsigned long long int,...); 143 unsigned long long int __sync_fetch_and_nand_8(volatile unsigned long long int *, unsigned long long int,...);144 92 #if defined(__SIZEOF_INT128__) 145 93 signed __int128 __sync_fetch_and_nand(volatile signed __int128 *, signed __int128,...); 146 signed __int128 __sync_fetch_and_nand_16(volatile signed __int128 *, signed __int128,...);147 94 unsigned __int128 __sync_fetch_and_nand(volatile unsigned __int128 *, unsigned __int128,...); 148 unsigned __int128 __sync_fetch_and_nand_16(volatile unsigned __int128 *, unsigned __int128,...);149 95 #endif 150 96 151 97 char __sync_add_and_fetch(volatile char *, char,...); 152 char __sync_add_and_fetch_1(volatile char *, char,...);153 98 signed char __sync_add_and_fetch(volatile signed char *, signed char,...); 154 signed char __sync_add_and_fetch_1(volatile signed char *, signed char,...);155 99 unsigned char __sync_add_and_fetch(volatile unsigned char *, unsigned char,...); 156 unsigned char __sync_add_and_fetch_1(volatile unsigned char *, unsigned char,...);157 100 signed short __sync_add_and_fetch(volatile signed short *, signed short,...); 158 signed short __sync_add_and_fetch_2(volatile signed short *, signed short,...);159 101 unsigned short __sync_add_and_fetch(volatile unsigned short *, unsigned short,...); 160 unsigned short __sync_add_and_fetch_2(volatile unsigned short *, unsigned short,...);161 102 signed int __sync_add_and_fetch(volatile signed int *, signed int,...); 162 signed int __sync_add_and_fetch_4(volatile signed int *, signed int,...);163 103 signed int __sync_add_and_fetch(volatile signed int *, signed int,...); 164 signed int __sync_add_and_fetch_4(volatile signed int *, signed int,...); 104 signed long int __sync_add_and_fetch(volatile signed long int *, signed long int,...); 105 unsigned long int __sync_add_and_fetch(volatile unsigned long int *, unsigned long int,...); 165 106 signed long long int __sync_add_and_fetch(volatile signed long long int *, signed long long int,...); 166 signed long long int __sync_add_and_fetch_8(volatile signed long long int *, signed long long int,...);167 107 unsigned long long int __sync_add_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 168 unsigned long long int __sync_add_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);169 108 #if defined(__SIZEOF_INT128__) 170 109 signed __int128 __sync_add_and_fetch(volatile signed __int128 *, signed __int128,...); 171 signed __int128 __sync_add_and_fetch_16(volatile signed __int128 *, signed __int128,...);172 110 unsigned __int128 __sync_add_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 173 unsigned __int128 __sync_add_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);174 111 #endif 175 112 176 113 char __sync_sub_and_fetch(volatile char *, char,...); 177 char __sync_sub_and_fetch_1(volatile char *, char,...);178 114 signed char __sync_sub_and_fetch(volatile signed char *, signed char,...); 179 signed char __sync_sub_and_fetch_1(volatile signed char *, signed char,...);180 115 unsigned char __sync_sub_and_fetch(volatile unsigned char *, unsigned char,...); 181 unsigned char __sync_sub_and_fetch_1(volatile unsigned char *, unsigned char,...);182 116 signed short __sync_sub_and_fetch(volatile signed short *, signed short,...); 183 signed short __sync_sub_and_fetch_2(volatile signed short *, signed short,...);184 117 unsigned short __sync_sub_and_fetch(volatile unsigned short *, unsigned short,...); 185 unsigned short __sync_sub_and_fetch_2(volatile unsigned short *, unsigned short,...);186 118 signed int __sync_sub_and_fetch(volatile signed int *, signed int,...); 187 signed int __sync_sub_and_fetch_4(volatile signed int *, signed int,...);188 119 unsigned int __sync_sub_and_fetch(volatile unsigned int *, unsigned int,...); 189 unsigned int __sync_sub_and_fetch_4(volatile unsigned int *, unsigned int,...); 120 signed long int __sync_sub_and_fetch(volatile signed long int *, signed long int,...); 121 unsigned long int __sync_sub_and_fetch(volatile unsigned long int *, unsigned long int,...); 190 122 signed long long int __sync_sub_and_fetch(volatile signed long long int *, signed long long int,...); 191 signed long long int __sync_sub_and_fetch_8(volatile signed long long int *, signed long long int,...);192 123 unsigned long long int __sync_sub_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 193 unsigned long long int __sync_sub_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);194 124 #if defined(__SIZEOF_INT128__) 195 125 signed __int128 __sync_sub_and_fetch(volatile signed __int128 *, signed __int128,...); 196 signed __int128 __sync_sub_and_fetch_16(volatile signed __int128 *, signed __int128,...);197 126 unsigned __int128 __sync_sub_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 198 unsigned __int128 __sync_sub_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);199 127 #endif 200 128 201 129 char __sync_or_and_fetch(volatile char *, char,...); 202 char __sync_or_and_fetch_1(volatile char *, char,...);203 130 signed char __sync_or_and_fetch(volatile signed char *, signed char,...); 204 signed char __sync_or_and_fetch_1(volatile signed char *, signed char,...);205 131 unsigned char __sync_or_and_fetch(volatile unsigned char *, unsigned char,...); 206 unsigned char __sync_or_and_fetch_1(volatile unsigned char *, unsigned char,...);207 132 signed short __sync_or_and_fetch(volatile signed short *, signed short,...); 208 signed short __sync_or_and_fetch_2(volatile signed short *, signed short,...);209 133 unsigned short __sync_or_and_fetch(volatile unsigned short *, unsigned short,...); 210 unsigned short __sync_or_and_fetch_2(volatile unsigned short *, unsigned short,...);211 134 signed int __sync_or_and_fetch(volatile signed int *, signed int,...); 212 signed int __sync_or_and_fetch_4(volatile signed int *, signed int,...);213 135 unsigned int __sync_or_and_fetch(volatile unsigned int *, unsigned int,...); 214 unsigned int __sync_or_and_fetch_4(volatile unsigned int *, unsigned int,...); 136 signed long int __sync_or_and_fetch(volatile signed long int *, signed long int,...); 137 unsigned long int __sync_or_and_fetch(volatile unsigned long int *, unsigned long int,...); 215 138 signed long long int __sync_or_and_fetch(volatile signed long long int *, signed long long int,...); 216 signed long long int __sync_or_and_fetch_8(volatile signed long long int *, signed long long int,...);217 139 unsigned long long int __sync_or_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 218 unsigned long long int __sync_or_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);219 140 #if defined(__SIZEOF_INT128__) 220 141 signed __int128 __sync_or_and_fetch(volatile signed __int128 *, signed __int128,...); 221 signed __int128 __sync_or_and_fetch_16(volatile signed __int128 *, signed __int128,...);222 142 unsigned __int128 __sync_or_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 223 unsigned __int128 __sync_or_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);224 143 #endif 225 144 226 145 char __sync_and_and_fetch(volatile char *, char,...); 227 char __sync_and_and_fetch_1(volatile char *, char,...);228 146 signed char __sync_and_and_fetch(volatile signed char *, signed char,...); 229 signed char __sync_and_and_fetch_1(volatile signed char *, signed char,...);230 147 unsigned char __sync_and_and_fetch(volatile unsigned char *, unsigned char,...); 231 unsigned char __sync_and_and_fetch_1(volatile unsigned char *, unsigned char,...);232 148 signed short __sync_and_and_fetch(volatile signed short *, signed short,...); 233 signed short __sync_and_and_fetch_2(volatile signed short *, signed short,...);234 149 unsigned short __sync_and_and_fetch(volatile unsigned short *, unsigned short,...); 235 unsigned short __sync_and_and_fetch_2(volatile unsigned short *, unsigned short,...);236 150 signed int __sync_and_and_fetch(volatile signed int *, signed int,...); 237 signed int __sync_and_and_fetch_4(volatile signed int *, signed int,...);238 151 unsigned int __sync_and_and_fetch(volatile unsigned int *, unsigned int,...); 239 unsigned int __sync_and_and_fetch_4(volatile unsigned int *, unsigned int,...); 152 signed long int __sync_and_and_fetch(volatile signed long int *, signed long int,...); 153 unsigned long int __sync_and_and_fetch(volatile unsigned long int *, unsigned long int,...); 240 154 signed long long int __sync_and_and_fetch(volatile signed long long int *, signed long long int,...); 241 signed long long int __sync_and_and_fetch_8(volatile signed long long int *, signed long long int,...);242 155 unsigned long long int __sync_and_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 243 unsigned long long int __sync_and_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);244 156 #if defined(__SIZEOF_INT128__) 245 157 signed __int128 __sync_and_and_fetch(volatile signed __int128 *, signed __int128,...); 246 signed __int128 __sync_and_and_fetch_16(volatile signed __int128 *, signed __int128,...);247 158 unsigned __int128 __sync_and_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 248 unsigned __int128 __sync_and_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);249 159 #endif 250 160 251 161 char __sync_xor_and_fetch(volatile char *, char,...); 252 char __sync_xor_and_fetch_1(volatile char *, char,...);253 162 signed char __sync_xor_and_fetch(volatile signed char *, signed char,...); 254 signed char __sync_xor_and_fetch_1(volatile signed char *, signed char,...);255 163 unsigned char __sync_xor_and_fetch(volatile unsigned char *, unsigned char,...); 256 unsigned char __sync_xor_and_fetch_1(volatile unsigned char *, unsigned char,...);257 164 signed short __sync_xor_and_fetch(volatile signed short *, signed short,...); 258 signed short __sync_xor_and_fetch_2(volatile signed short *, signed short,...);259 165 unsigned short __sync_xor_and_fetch(volatile unsigned short *, unsigned short,...); 260 unsigned short __sync_xor_and_fetch_2(volatile unsigned short *, unsigned short,...);261 166 signed int __sync_xor_and_fetch(volatile signed int *, signed int,...); 262 signed int __sync_xor_and_fetch_4(volatile signed int *, signed int,...);263 167 unsigned int __sync_xor_and_fetch(volatile unsigned int *, unsigned int,...); 264 unsigned int __sync_xor_and_fetch_4(volatile unsigned int *, unsigned int,...); 168 signed long int __sync_xor_and_fetch(volatile signed long int *, signed long int,...); 169 unsigned long int __sync_xor_and_fetch(volatile unsigned long int *, unsigned long int,...); 265 170 signed long long int __sync_xor_and_fetch(volatile signed long long int *, signed long long int,...); 266 signed long long int __sync_xor_and_fetch_8(volatile signed long long int *, signed long long int,...);267 171 unsigned long long int __sync_xor_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 268 unsigned long long int __sync_xor_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);269 172 #if defined(__SIZEOF_INT128__) 270 173 signed __int128 __sync_xor_and_fetch(volatile signed __int128 *, signed __int128,...); 271 signed __int128 __sync_xor_and_fetch_16(volatile signed __int128 *, signed __int128,...);272 174 unsigned __int128 __sync_xor_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 273 unsigned __int128 __sync_xor_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);274 175 #endif 275 176 276 177 char __sync_nand_and_fetch(volatile char *, char,...); 277 char __sync_nand_and_fetch_1(volatile char *, char,...);278 178 signed char __sync_nand_and_fetch(volatile signed char *, signed char,...); 279 signed char __sync_nand_and_fetch_1(volatile signed char *, signed char,...);280 179 unsigned char __sync_nand_and_fetch(volatile unsigned char *, unsigned char,...); 281 unsigned char __sync_nand_and_fetch_1(volatile unsigned char *, unsigned char,...);282 180 signed short __sync_nand_and_fetch(volatile signed short *, signed short,...); 283 signed short __sync_nand_and_fetch_2(volatile signed short *, signed short,...);284 181 unsigned short __sync_nand_and_fetch(volatile unsigned short *, unsigned short,...); 285 unsigned short __sync_nand_and_fetch_2(volatile unsigned short *, unsigned short,...);286 182 signed int __sync_nand_and_fetch(volatile signed int *, signed int,...); 287 signed int __sync_nand_and_fetch_4(volatile signed int *, signed int,...);288 183 unsigned int __sync_nand_and_fetch(volatile unsigned int *, unsigned int,...); 289 unsigned int __sync_nand_and_fetch_4(volatile unsigned int *, unsigned int,...); 184 signed long int __sync_nand_and_fetch(volatile signed long int *, signed long int,...); 185 unsigned long int __sync_nand_and_fetch(volatile unsigned long int *, unsigned long int,...); 290 186 signed long long int __sync_nand_and_fetch(volatile signed long long int *, signed long long int,...); 291 signed long long int __sync_nand_and_fetch_8(volatile signed long long int *, signed long long int,...);292 187 unsigned long long int __sync_nand_and_fetch(volatile unsigned long long int *, unsigned long long int,...); 293 unsigned long long int __sync_nand_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);294 188 #if defined(__SIZEOF_INT128__) 295 189 signed __int128 __sync_nand_and_fetch(volatile signed __int128 *, signed __int128,...); 296 signed __int128 __sync_nand_and_fetch_16(volatile signed __int128 *, signed __int128,...);297 190 unsigned __int128 __sync_nand_and_fetch(volatile unsigned __int128 *, unsigned __int128,...); 298 unsigned __int128 __sync_nand_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);299 191 #endif 300 192 301 193 _Bool __sync_bool_compare_and_swap(volatile char *, char, char,...); 302 _Bool __sync_bool_compare_and_swap_1(volatile char *, char, char,...);303 194 _Bool __sync_bool_compare_and_swap(volatile signed char *, signed char, signed char,...); 304 _Bool __sync_bool_compare_and_swap_1(volatile signed char *, signed char, signed char,...);305 195 _Bool __sync_bool_compare_and_swap(volatile unsigned char *, unsigned char, unsigned char,...); 306 _Bool __sync_bool_compare_and_swap_1(volatile unsigned char *, unsigned char, unsigned char,...);307 196 _Bool __sync_bool_compare_and_swap(volatile short *, signed short, signed short,...); 308 _Bool __sync_bool_compare_and_swap_2(volatile short *, signed short, signed short,...);309 197 _Bool __sync_bool_compare_and_swap(volatile short *, unsigned short, unsigned short,...); 310 _Bool __sync_bool_compare_and_swap_2(volatile short *, unsigned short, unsigned short,...);311 198 _Bool __sync_bool_compare_and_swap(volatile signed int *, signed int, signed int,...); 312 _Bool __sync_bool_compare_and_swap_4(volatile signed int *, signed int, signed int,...);313 199 _Bool __sync_bool_compare_and_swap(volatile unsigned int *, unsigned int, unsigned int,...); 314 _Bool __sync_bool_compare_and_swap_4(volatile unsigned int *, unsigned int, unsigned int,...); 200 _Bool __sync_bool_compare_and_swap(volatile signed long int *, signed long int, signed long int,...); 201 _Bool __sync_bool_compare_and_swap(volatile unsigned long int *, unsigned long int, unsigned long int,...); 315 202 _Bool __sync_bool_compare_and_swap(volatile signed long long int *, signed long long int, signed long long int,...); 316 _Bool __sync_bool_compare_and_swap_8(volatile signed long long int *, signed long long int, signed long long int,...);317 203 _Bool __sync_bool_compare_and_swap(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...); 318 _Bool __sync_bool_compare_and_swap_8(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);319 204 #if defined(__SIZEOF_INT128__) 320 205 _Bool __sync_bool_compare_and_swap(volatile signed __int128 *, signed __int128, signed __int128,...); 321 _Bool __sync_bool_compare_and_swap_16(volatile signed __int128 *, signed __int128, signed __int128,...);322 206 _Bool __sync_bool_compare_and_swap(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...); 323 _Bool __sync_bool_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);324 207 #endif 325 208 forall(dtype T) _Bool __sync_bool_compare_and_swap(T * volatile *, T *, T*, ...); 326 209 327 210 char __sync_val_compare_and_swap(volatile char *, char, char,...); 328 char __sync_val_compare_and_swap_1(volatile char *, char, char,...);329 211 signed char __sync_val_compare_and_swap(volatile signed char *, signed char, signed char,...); 330 signed char __sync_val_compare_and_swap_1(volatile signed char *, signed char, signed char,...);331 212 unsigned char __sync_val_compare_and_swap(volatile unsigned char *, unsigned char, unsigned char,...); 332 unsigned char __sync_val_compare_and_swap_1(volatile unsigned char *, unsigned char, unsigned char,...);333 213 signed short __sync_val_compare_and_swap(volatile signed short *, signed short, signed short,...); 334 signed short __sync_val_compare_and_swap_2(volatile signed short *, signed short, signed short,...);335 214 unsigned short __sync_val_compare_and_swap(volatile unsigned short *, unsigned short, unsigned short,...); 336 unsigned short __sync_val_compare_and_swap_2(volatile unsigned short *, unsigned short, unsigned short,...);337 215 signed int __sync_val_compare_and_swap(volatile signed int *, signed int, signed int,...); 338 signed int __sync_val_compare_and_swap_4(volatile signed int *, signed int, signed int,...);339 216 unsigned int __sync_val_compare_and_swap(volatile unsigned int *, unsigned int, unsigned int,...); 340 unsigned int __sync_val_compare_and_swap_4(volatile unsigned int *, unsigned int, unsigned int,...); 217 signed long int __sync_val_compare_and_swap(volatile signed long int *, signed long int, signed long int,...); 218 unsigned long int __sync_val_compare_and_swap(volatile unsigned long int *, unsigned long int, unsigned long int,...); 341 219 signed long long int __sync_val_compare_and_swap(volatile signed long long int *, signed long long int, signed long long int,...); 342 signed long long int __sync_val_compare_and_swap_8(volatile signed long long int *, signed long long int, signed long long int,...);343 220 unsigned long long int __sync_val_compare_and_swap(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...); 344 unsigned long long int __sync_val_compare_and_swap_8(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);345 221 #if defined(__SIZEOF_INT128__) 346 222 signed __int128 __sync_val_compare_and_swap(volatile signed __int128 *, signed __int128, signed __int128,...); 347 signed __int128 __sync_val_compare_and_swap_16(volatile signed __int128 *, signed __int128, signed __int128,...);348 223 unsigned __int128 __sync_val_compare_and_swap(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...); 349 unsigned __int128 __sync_val_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);350 224 #endif 351 225 forall(dtype T) T * __sync_val_compare_and_swap(T * volatile *, T *, T*,...); 352 226 353 227 char __sync_lock_test_and_set(volatile char *, char,...); 354 char __sync_lock_test_and_set_1(volatile char *, char,...);355 228 signed char __sync_lock_test_and_set(volatile signed char *, signed char,...); 356 signed char __sync_lock_test_and_set_1(volatile signed char *, signed char,...);357 229 unsigned char __sync_lock_test_and_set(volatile unsigned char *, unsigned char,...); 358 unsigned char __sync_lock_test_and_set_1(volatile unsigned char *, unsigned char,...);359 230 signed short __sync_lock_test_and_set(volatile signed short *, signed short,...); 360 signed short __sync_lock_test_and_set_2(volatile signed short *, signed short,...);361 231 unsigned short __sync_lock_test_and_set(volatile unsigned short *, unsigned short,...); 362 unsigned short __sync_lock_test_and_set_2(volatile unsigned short *, unsigned short,...);363 232 signed int __sync_lock_test_and_set(volatile signed int *, signed int,...); 364 signed int __sync_lock_test_and_set_4(volatile signed int *, signed int,...);365 233 unsigned int __sync_lock_test_and_set(volatile unsigned int *, unsigned int,...); 366 unsigned int __sync_lock_test_and_set_4(volatile unsigned int *, unsigned int,...); 234 signed long int __sync_lock_test_and_set(volatile signed long int *, signed long int,...); 235 unsigned long int __sync_lock_test_and_set(volatile unsigned long int *, unsigned long int,...); 367 236 signed long long int __sync_lock_test_and_set(volatile signed long long int *, signed long long int,...); 368 signed long long int __sync_lock_test_and_set_8(volatile signed long long int *, signed long long int,...);369 237 unsigned long long int __sync_lock_test_and_set(volatile unsigned long long int *, unsigned long long int,...); 370 unsigned long long int __sync_lock_test_and_set_8(volatile unsigned long long int *, unsigned long long int,...);371 238 #if defined(__SIZEOF_INT128__) 372 239 signed __int128 __sync_lock_test_and_set(volatile signed __int128 *, signed __int128,...); 373 signed __int128 __sync_lock_test_and_set_16(volatile signed __int128 *, signed __int128,...);374 240 unsigned __int128 __sync_lock_test_and_set(volatile unsigned __int128 *, unsigned __int128,...); 375 unsigned __int128 __sync_lock_test_and_set_16(volatile unsigned __int128 *, unsigned __int128,...);376 241 #endif 377 242 378 243 void __sync_lock_release(volatile char *,...); 379 void __sync_lock_release_1(volatile char *,...);380 244 void __sync_lock_release(volatile signed char *,...); 381 void __sync_lock_release_1(volatile signed char *,...);382 245 void __sync_lock_release(volatile unsigned char *,...); 383 void __sync_lock_release_1(volatile unsigned char *,...);384 246 void __sync_lock_release(volatile signed short *,...); 385 void __sync_lock_release_2(volatile signed short *,...);386 247 void __sync_lock_release(volatile unsigned short *,...); 387 void __sync_lock_release_2(volatile unsigned short *,...);388 248 void __sync_lock_release(volatile signed int *,...); 389 void __sync_lock_release_4(volatile signed int *,...);390 249 void __sync_lock_release(volatile unsigned int *,...); 391 void __sync_lock_release_4(volatile unsigned int *,...); 250 void __sync_lock_release(volatile signed long int *,...); 251 void __sync_lock_release(volatile unsigned long int *,...); 392 252 void __sync_lock_release(volatile signed long long int *,...); 393 void __sync_lock_release_8(volatile signed long long int *,...);394 253 void __sync_lock_release(volatile unsigned long long int *,...); 395 void __sync_lock_release_8(volatile unsigned long long int *,...);396 254 #if defined(__SIZEOF_INT128__) 397 255 void __sync_lock_release(volatile signed __int128 *,...); 398 void __sync_lock_release_16(volatile signed __int128 *,...);399 256 void __sync_lock_release(volatile unsigned __int128 *,...); 400 void __sync_lock_release_16(volatile unsigned __int128 *,...);401 257 #endif 402 258 … … 414 270 _Bool __atomic_test_and_set(volatile signed int *, int); 415 271 _Bool __atomic_test_and_set(volatile unsigned int *, int); 272 _Bool __atomic_test_and_set(volatile signed long int *, int); 273 _Bool __atomic_test_and_set(volatile unsigned long int *, int); 416 274 _Bool __atomic_test_and_set(volatile signed long long int *, int); 417 275 _Bool __atomic_test_and_set(volatile unsigned long long int *, int); … … 429 287 void __atomic_clear(volatile signed int *, int); 430 288 void __atomic_clear(volatile unsigned int *, int); 289 void __atomic_clear(volatile signed long int *, int); 290 void __atomic_clear(volatile unsigned long int *, int); 431 291 void __atomic_clear(volatile signed long long int *, int); 432 292 void __atomic_clear(volatile unsigned long long int *, int); … … 437 297 438 298 _Bool __atomic_exchange_n(volatile _Bool *, _Bool, int); 439 _Bool __atomic_exchange_1(volatile _Bool *, _Bool, int);440 299 void __atomic_exchange(volatile _Bool *, volatile _Bool *, volatile _Bool *, int); 441 300 char __atomic_exchange_n(volatile char *, char, int); 442 char __atomic_exchange_1(volatile char *, char, int);443 301 void __atomic_exchange(volatile char *, volatile char *, volatile char *, int); 444 302 signed char __atomic_exchange_n(volatile signed char *, signed char, int); 445 signed char __atomic_exchange_1(volatile signed char *, signed char, int);446 303 void __atomic_exchange(volatile signed char *, volatile signed char *, volatile signed char *, int); 447 304 unsigned char __atomic_exchange_n(volatile unsigned char *, unsigned char, int); 448 unsigned char __atomic_exchange_1(volatile unsigned char *, unsigned char, int);449 305 void __atomic_exchange(volatile unsigned char *, volatile unsigned char *, volatile unsigned char *, int); 450 306 signed short __atomic_exchange_n(volatile signed short *, signed short, int); 451 signed short __atomic_exchange_2(volatile signed short *, signed short, int);452 307 void __atomic_exchange(volatile signed short *, volatile signed short *, volatile signed short *, int); 453 308 unsigned short __atomic_exchange_n(volatile unsigned short *, unsigned short, int); 454 unsigned short __atomic_exchange_2(volatile unsigned short *, unsigned short, int);455 309 void __atomic_exchange(volatile unsigned short *, volatile unsigned short *, volatile unsigned short *, int); 456 310 signed int __atomic_exchange_n(volatile signed int *, signed int, int); 457 signed int __atomic_exchange_4(volatile signed int *, signed int, int);458 311 void __atomic_exchange(volatile signed int *, volatile signed int *, volatile signed int *, int); 459 312 unsigned int __atomic_exchange_n(volatile unsigned int *, unsigned int, int); 460 unsigned int __atomic_exchange_4(volatile unsigned int *, unsigned int, int);461 313 void __atomic_exchange(volatile unsigned int *, volatile unsigned int *, volatile unsigned int *, int); 314 signed long int __atomic_exchange_n(volatile signed long int *, signed long int, int); 315 void __atomic_exchange(volatile signed long int *, volatile signed long int *, volatile signed long int *, int); 316 unsigned long int __atomic_exchange_n(volatile unsigned long int *, unsigned long int, int); 317 void __atomic_exchange(volatile unsigned long int *, volatile unsigned long int *, volatile unsigned long int *, int); 462 318 signed long long int __atomic_exchange_n(volatile signed long long int *, signed long long int, int); 463 signed long long int __atomic_exchange_8(volatile signed long long int *, signed long long int, int);464 319 void __atomic_exchange(volatile signed long long int *, volatile signed long long int *, volatile signed long long int *, int); 465 320 unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, unsigned long long int, int); 466 unsigned long long int __atomic_exchange_8(volatile unsigned long long int *, unsigned long long int, int);467 321 void __atomic_exchange(volatile unsigned long long int *, volatile unsigned long long int *, volatile unsigned long long int *, int); 468 322 #if defined(__SIZEOF_INT128__) 469 323 signed __int128 __atomic_exchange_n(volatile signed __int128 *, signed __int128, int); 470 signed __int128 __atomic_exchange_16(volatile signed __int128 *, signed __int128, int);471 324 void __atomic_exchange(volatile signed __int128 *, volatile signed __int128 *, volatile signed __int128 *, int); 472 325 unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, unsigned __int128, int); 473 unsigned __int128 __atomic_exchange_16(volatile unsigned __int128 *, unsigned __int128, int);474 326 void __atomic_exchange(volatile unsigned __int128 *, volatile unsigned __int128 *, volatile unsigned __int128 *, int); 475 327 #endif … … 480 332 void __atomic_load(const volatile _Bool *, volatile _Bool *, int); 481 333 char __atomic_load_n(const volatile char *, int); 482 char __atomic_load_1(const volatile char *, int);483 334 void __atomic_load(const volatile char *, volatile char *, int); 484 335 signed char __atomic_load_n(const volatile signed char *, int); 485 signed char __atomic_load_1(const volatile signed char *, int);486 336 void __atomic_load(const volatile signed char *, volatile signed char *, int); 487 337 unsigned char __atomic_load_n(const volatile unsigned char *, int); 488 unsigned char __atomic_load_1(const volatile unsigned char *, int);489 338 void __atomic_load(const volatile unsigned char *, volatile unsigned char *, int); 490 339 signed short __atomic_load_n(const volatile signed short *, int); 491 signed short __atomic_load_2(const volatile signed short *, int);492 340 void __atomic_load(const volatile signed short *, volatile signed short *, int); 493 341 unsigned short __atomic_load_n(const volatile unsigned short *, int); 494 unsigned short __atomic_load_2(const volatile unsigned short *, int);495 342 void __atomic_load(const volatile unsigned short *, volatile unsigned short *, int); 496 343 signed int __atomic_load_n(const volatile signed int *, int); 497 signed int __atomic_load_4(const volatile signed int *, int);498 344 void __atomic_load(const volatile signed int *, volatile signed int *, int); 499 345 unsigned int __atomic_load_n(const volatile unsigned int *, int); 500 unsigned int __atomic_load_4(const volatile unsigned int *, int);501 346 void __atomic_load(const volatile unsigned int *, volatile unsigned int *, int); 347 signed long int __atomic_load_n(const volatile signed long int *, int); 348 void __atomic_load(const volatile signed long int *, volatile signed long int *, int); 349 unsigned long int __atomic_load_n(const volatile unsigned long int *, int); 350 void __atomic_load(const volatile unsigned long int *, volatile unsigned long int *, int); 502 351 signed long long int __atomic_load_n(const volatile signed long long int *, int); 503 signed long long int __atomic_load_8(const volatile signed long long int *, int);504 352 void __atomic_load(const volatile signed long long int *, volatile signed long long int *, int); 505 353 unsigned long long int __atomic_load_n(const volatile unsigned long long int *, int); 506 unsigned long long int __atomic_load_8(const volatile unsigned long long int *, int);507 354 void __atomic_load(const volatile unsigned long long int *, volatile unsigned long long int *, int); 508 355 #if defined(__SIZEOF_INT128__) 509 356 signed __int128 __atomic_load_n(const volatile signed __int128 *, int); 510 signed __int128 __atomic_load_16(const volatile signed __int128 *, int);511 357 void __atomic_load(const volatile signed __int128 *, volatile signed __int128 *, int); 512 358 unsigned __int128 __atomic_load_n(const volatile unsigned __int128 *, int); 513 unsigned __int128 __atomic_load_16(const volatile unsigned __int128 *, int);514 359 void __atomic_load(const volatile unsigned __int128 *, volatile unsigned __int128 *, int); 515 360 #endif … … 518 363 519 364 _Bool __atomic_compare_exchange_n(volatile char *, char *, char, _Bool, int, int); 520 _Bool __atomic_compare_exchange_1(volatile char *, char *, char, _Bool, int, int);521 365 _Bool __atomic_compare_exchange (volatile char *, char *, char *, _Bool, int, int); 522 366 _Bool __atomic_compare_exchange_n(volatile signed char *, signed char *, signed char, _Bool, int, int); 523 _Bool __atomic_compare_exchange_1(volatile signed char *, signed char *, signed char, _Bool, int, int);524 367 _Bool __atomic_compare_exchange (volatile signed char *, signed char *, signed char *, _Bool, int, int); 525 368 _Bool __atomic_compare_exchange_n(volatile unsigned char *, unsigned char *, unsigned char, _Bool, int, int); 526 _Bool __atomic_compare_exchange_1(volatile unsigned char *, unsigned char *, unsigned char, _Bool, int, int);527 369 _Bool __atomic_compare_exchange (volatile unsigned char *, unsigned char *, unsigned char *, _Bool, int, int); 528 370 _Bool __atomic_compare_exchange_n(volatile signed short *, signed short *, signed short, _Bool, int, int); 529 _Bool __atomic_compare_exchange_2(volatile signed short *, signed short *, signed short, _Bool, int, int);530 371 _Bool __atomic_compare_exchange (volatile signed short *, signed short *, signed short *, _Bool, int, int); 531 372 _Bool __atomic_compare_exchange_n(volatile unsigned short *, unsigned short *, unsigned short, _Bool, int, int); 532 _Bool __atomic_compare_exchange_2(volatile unsigned short *, unsigned short *, unsigned short, _Bool, int, int);533 373 _Bool __atomic_compare_exchange (volatile unsigned short *, unsigned short *, unsigned short *, _Bool, int, int); 534 374 _Bool __atomic_compare_exchange_n(volatile signed int *, signed int *, signed int, _Bool, int, int); 535 _Bool __atomic_compare_exchange_4(volatile signed int *, signed int *, signed int, _Bool, int, int);536 375 _Bool __atomic_compare_exchange (volatile signed int *, signed int *, signed int *, _Bool, int, int); 537 376 _Bool __atomic_compare_exchange_n(volatile unsigned int *, unsigned int *, unsigned int, _Bool, int, int); 538 _Bool __atomic_compare_exchange_4(volatile unsigned int *, unsigned int *, unsigned int, _Bool, int, int);539 377 _Bool __atomic_compare_exchange (volatile unsigned int *, unsigned int *, unsigned int *, _Bool, int, int); 378 _Bool __atomic_compare_exchange_n(volatile signed long int *, signed long int *, signed long int, _Bool, int, int); 379 _Bool __atomic_compare_exchange (volatile signed long int *, signed long int *, signed long int *, _Bool, int, int); 380 _Bool __atomic_compare_exchange_n(volatile unsigned long int *, unsigned long int *, unsigned long int, _Bool, int, int); 381 _Bool __atomic_compare_exchange (volatile unsigned long int *, unsigned long int *, unsigned long int *, _Bool, int, int); 540 382 _Bool __atomic_compare_exchange_n(volatile signed long long int *, signed long long int *, signed long long int, _Bool, int, int); 541 _Bool __atomic_compare_exchange_8(volatile signed long long int *, signed long long int *, signed long long int, _Bool, int, int);542 383 _Bool __atomic_compare_exchange (volatile signed long long int *, signed long long int *, signed long long int *, _Bool, int, int); 543 384 _Bool __atomic_compare_exchange_n(volatile unsigned long long int *, unsigned long long int *, unsigned long long int, _Bool, int, int); 544 _Bool __atomic_compare_exchange_8(volatile unsigned long long int *, unsigned long long int *, unsigned long long int, _Bool, int, int);545 385 _Bool __atomic_compare_exchange (volatile unsigned long long int *, unsigned long long int *, unsigned long long int *, _Bool, int, int); 546 386 #if defined(__SIZEOF_INT128__) 547 387 _Bool __atomic_compare_exchange_n (volatile signed __int128 *, signed __int128 *, signed __int128, _Bool, int, int); 548 _Bool __atomic_compare_exchange_16(volatile signed __int128 *, signed __int128 *, signed __int128, _Bool, int, int);549 388 _Bool __atomic_compare_exchange (volatile signed __int128 *, signed __int128 *, signed __int128 *, _Bool, int, int); 550 389 _Bool __atomic_compare_exchange_n (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128, _Bool, int, int); 551 _Bool __atomic_compare_exchange_16(volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128, _Bool, int, int);552 390 _Bool __atomic_compare_exchange (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128 *, _Bool, int, int); 553 391 #endif … … 558 396 void __atomic_store(volatile _Bool *, _Bool *, int); 559 397 void __atomic_store_n(volatile char *, char, int); 560 void __atomic_store_1(volatile char *, char, int);561 398 void __atomic_store(volatile char *, char *, int); 562 399 void __atomic_store_n(volatile signed char *, signed char, int); 563 void __atomic_store_1(volatile signed char *, signed char, int);564 400 void __atomic_store(volatile signed char *, signed char *, int); 565 401 void __atomic_store_n(volatile unsigned char *, unsigned char, int); 566 void __atomic_store_1(volatile unsigned char *, unsigned char, int);567 402 void __atomic_store(volatile unsigned char *, unsigned char *, int); 568 403 void __atomic_store_n(volatile signed short *, signed short, int); 569 void __atomic_store_2(volatile signed short *, signed short, int);570 404 void __atomic_store(volatile signed short *, signed short *, int); 571 405 void __atomic_store_n(volatile unsigned short *, unsigned short, int); 572 void __atomic_store_2(volatile unsigned short *, unsigned short, int);573 406 void __atomic_store(volatile unsigned short *, unsigned short *, int); 574 407 void __atomic_store_n(volatile signed int *, signed int, int); 575 void __atomic_store_4(volatile signed int *, signed int, int);576 408 void __atomic_store(volatile signed int *, signed int *, int); 577 409 void __atomic_store_n(volatile unsigned int *, unsigned int, int); 578 void __atomic_store_4(volatile unsigned int *, unsigned int, int);579 410 void __atomic_store(volatile unsigned int *, unsigned int *, int); 411 void __atomic_store_n(volatile signed long int *, signed long int, int); 412 void __atomic_store(volatile signed long int *, signed long int *, int); 413 void __atomic_store_n(volatile unsigned long int *, unsigned long int, int); 414 void __atomic_store(volatile unsigned long int *, unsigned long int *, int); 580 415 void __atomic_store_n(volatile signed long long int *, signed long long int, int); 581 void __atomic_store_8(volatile signed long long int *, signed long long int, int);582 416 void __atomic_store(volatile signed long long int *, signed long long int *, int); 583 417 void __atomic_store_n(volatile unsigned long long int *, unsigned long long int, int); 584 void __atomic_store_8(volatile unsigned long long int *, unsigned long long int, int);585 418 void __atomic_store(volatile unsigned long long int *, unsigned long long int *, int); 586 419 #if defined(__SIZEOF_INT128__) 587 420 void __atomic_store_n(volatile signed __int128 *, signed __int128, int); 588 void __atomic_store_16(volatile signed __int128 *, signed __int128, int);589 421 void __atomic_store(volatile signed __int128 *, signed __int128 *, int); 590 422 void __atomic_store_n(volatile unsigned __int128 *, unsigned __int128, int); 591 void __atomic_store_16(volatile unsigned __int128 *, unsigned __int128, int);592 423 void __atomic_store(volatile unsigned __int128 *, unsigned __int128 *, int); 593 424 #endif … … 596 427 597 428 char __atomic_add_fetch (volatile char *, char, int); 598 char __atomic_add_fetch_1(volatile char *, char, int);599 429 signed char __atomic_add_fetch (volatile signed char *, signed char, int); 600 signed char __atomic_add_fetch_1(volatile signed char *, signed char, int);601 430 unsigned char __atomic_add_fetch (volatile unsigned char *, unsigned char, int); 602 unsigned char __atomic_add_fetch_1(volatile unsigned char *, unsigned char, int);603 431 signed short __atomic_add_fetch (volatile signed short *, signed short, int); 604 signed short __atomic_add_fetch_2(volatile signed short *, signed short, int);605 432 unsigned short __atomic_add_fetch (volatile unsigned short *, unsigned short, int); 606 unsigned short __atomic_add_fetch_2(volatile unsigned short *, unsigned short, int);607 433 signed int __atomic_add_fetch (volatile signed int *, signed int, int); 608 signed int __atomic_add_fetch_4(volatile signed int *, signed int, int);609 434 unsigned int __atomic_add_fetch (volatile unsigned int *, unsigned int, int); 610 unsigned int __atomic_add_fetch_4(volatile unsigned int *, unsigned int, int); 435 signed long int __atomic_add_fetch (volatile signed long int *, signed long int, int); 436 unsigned long int __atomic_add_fetch (volatile unsigned long int *, unsigned long int, int); 611 437 signed long long int __atomic_add_fetch (volatile signed long long int *, signed long long int, int); 612 signed long long int __atomic_add_fetch_8(volatile signed long long int *, signed long long int, int);613 438 unsigned long long int __atomic_add_fetch (volatile unsigned long long int *, unsigned long long int, int); 614 unsigned long long int __atomic_add_fetch_8(volatile unsigned long long int *, unsigned long long int, int);615 439 #if defined(__SIZEOF_INT128__) 616 440 signed __int128 __atomic_add_fetch (volatile signed __int128 *, signed __int128, int); 617 signed __int128 __atomic_add_fetch_16(volatile signed __int128 *, signed __int128, int);618 441 unsigned __int128 __atomic_add_fetch (volatile unsigned __int128 *, unsigned __int128, int); 619 unsigned __int128 __atomic_add_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);620 442 #endif 621 443 622 444 char __atomic_sub_fetch (volatile char *, char, int); 623 char __atomic_sub_fetch_1(volatile char *, char, int);624 445 signed char __atomic_sub_fetch (volatile signed char *, signed char, int); 625 signed char __atomic_sub_fetch_1(volatile signed char *, signed char, int);626 446 unsigned char __atomic_sub_fetch (volatile unsigned char *, unsigned char, int); 627 unsigned char __atomic_sub_fetch_1(volatile unsigned char *, unsigned char, int);628 447 signed short __atomic_sub_fetch (volatile signed short *, signed short, int); 629 signed short __atomic_sub_fetch_2(volatile signed short *, signed short, int);630 448 unsigned short __atomic_sub_fetch (volatile unsigned short *, unsigned short, int); 631 unsigned short __atomic_sub_fetch_2(volatile unsigned short *, unsigned short, int);632 449 signed int __atomic_sub_fetch (volatile signed int *, signed int, int); 633 signed int __atomic_sub_fetch_4(volatile signed int *, signed int, int);634 450 unsigned int __atomic_sub_fetch (volatile unsigned int *, unsigned int, int); 635 unsigned int __atomic_sub_fetch_4(volatile unsigned int *, unsigned int, int); 451 signed long long int __atomic_sub_fetch (volatile signed long int *, signed long int, int); 452 unsigned long long int __atomic_sub_fetch (volatile unsigned long int *, unsigned long int, int); 636 453 signed long long int __atomic_sub_fetch (volatile signed long long int *, signed long long int, int); 637 signed long long int __atomic_sub_fetch_8(volatile signed long long int *, signed long long int, int);638 454 unsigned long long int __atomic_sub_fetch (volatile unsigned long long int *, unsigned long long int, int); 639 unsigned long long int __atomic_sub_fetch_8(volatile unsigned long long int *, unsigned long long int, int);640 455 #if defined(__SIZEOF_INT128__) 641 456 signed __int128 __atomic_sub_fetch (volatile signed __int128 *, signed __int128, int); 642 signed __int128 __atomic_sub_fetch_16(volatile signed __int128 *, signed __int128, int);643 457 unsigned __int128 __atomic_sub_fetch (volatile unsigned __int128 *, unsigned __int128, int); 644 unsigned __int128 __atomic_sub_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);645 458 #endif 646 459 647 460 char __atomic_and_fetch (volatile char *, char, int); 648 char __atomic_and_fetch_1(volatile char *, char, int);649 461 signed char __atomic_and_fetch (volatile signed char *, signed char, int); 650 signed char __atomic_and_fetch_1(volatile signed char *, signed char, int);651 462 unsigned char __atomic_and_fetch (volatile unsigned char *, unsigned char, int); 652 unsigned char __atomic_and_fetch_1(volatile unsigned char *, unsigned char, int);653 463 signed short __atomic_and_fetch (volatile signed short *, signed short, int); 654 signed short __atomic_and_fetch_2(volatile signed short *, signed short, int);655 464 unsigned short __atomic_and_fetch (volatile unsigned short *, unsigned short, int); 656 unsigned short __atomic_and_fetch_2(volatile unsigned short *, unsigned short, int);657 465 signed int __atomic_and_fetch (volatile signed int *, signed int, int); 658 signed int __atomic_and_fetch_4(volatile signed int *, signed int, int);659 466 unsigned int __atomic_and_fetch (volatile unsigned int *, unsigned int, int); 660 unsigned int __atomic_and_fetch_4(volatile unsigned int *, unsigned int, int); 467 signed long int __atomic_and_fetch (volatile signed long int *, signed long int, int); 468 unsigned long int __atomic_and_fetch (volatile unsigned long int *, unsigned long int, int); 661 469 signed long long int __atomic_and_fetch (volatile signed long long int *, signed long long int, int); 662 signed long long int __atomic_and_fetch_8(volatile signed long long int *, signed long long int, int);663 470 unsigned long long int __atomic_and_fetch (volatile unsigned long long int *, unsigned long long int, int); 664 unsigned long long int __atomic_and_fetch_8(volatile unsigned long long int *, unsigned long long int, int);665 471 #if defined(__SIZEOF_INT128__) 666 472 signed __int128 __atomic_and_fetch (volatile signed __int128 *, signed __int128, int); 667 signed __int128 __atomic_and_fetch_16(volatile signed __int128 *, signed __int128, int);668 473 unsigned __int128 __atomic_and_fetch (volatile unsigned __int128 *, unsigned __int128, int); 669 unsigned __int128 __atomic_and_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);670 474 #endif 671 475 672 476 char __atomic_nand_fetch (volatile char *, char, int); 673 char __atomic_nand_fetch_1(volatile char *, char, int);674 477 signed char __atomic_nand_fetch (volatile signed char *, signed char, int); 675 signed char __atomic_nand_fetch_1(volatile signed char *, signed char, int);676 478 unsigned char __atomic_nand_fetch (volatile unsigned char *, unsigned char, int); 677 unsigned char __atomic_nand_fetch_1(volatile unsigned char *, unsigned char, int);678 479 signed short __atomic_nand_fetch (volatile signed short *, signed short, int); 679 signed short __atomic_nand_fetch_2(volatile signed short *, signed short, int);680 480 unsigned short __atomic_nand_fetch (volatile unsigned short *, unsigned short, int); 681 unsigned short __atomic_nand_fetch_2(volatile unsigned short *, unsigned short, int);682 481 signed int __atomic_nand_fetch (volatile signed int *, signed int, int); 683 signed int __atomic_nand_fetch_4(volatile signed int *, signed int, int);684 482 unsigned int __atomic_nand_fetch (volatile unsigned int *, unsigned int, int); 685 unsigned int __atomic_nand_fetch_4(volatile unsigned int *, unsigned int, int); 483 signed long int __atomic_nand_fetch (volatile signed long int *, signed long int, int); 484 unsigned long int __atomic_nand_fetch (volatile unsigned long int *, unsigned long int, int); 686 485 signed long long int __atomic_nand_fetch (volatile signed long long int *, signed long long int, int); 687 signed long long int __atomic_nand_fetch_8(volatile signed long long int *, signed long long int, int);688 486 unsigned long long int __atomic_nand_fetch (volatile unsigned long long int *, unsigned long long int, int); 689 unsigned long long int __atomic_nand_fetch_8(volatile unsigned long long int *, unsigned long long int, int);690 487 #if defined(__SIZEOF_INT128__) 691 488 signed __int128 __atomic_nand_fetch (volatile signed __int128 *, signed __int128, int); 692 signed __int128 __atomic_nand_fetch_16(volatile signed __int128 *, signed __int128, int);693 489 unsigned __int128 __atomic_nand_fetch (volatile unsigned __int128 *, unsigned __int128, int); 694 unsigned __int128 __atomic_nand_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);695 490 #endif 696 491 697 492 char __atomic_xor_fetch (volatile char *, char, int); 698 char __atomic_xor_fetch_1(volatile char *, char, int);699 493 signed char __atomic_xor_fetch (volatile signed char *, signed char, int); 700 signed char __atomic_xor_fetch_1(volatile signed char *, signed char, int);701 494 unsigned char __atomic_xor_fetch (volatile unsigned char *, unsigned char, int); 702 unsigned char __atomic_xor_fetch_1(volatile unsigned char *, unsigned char, int);703 495 signed short __atomic_xor_fetch (volatile signed short *, signed short, int); 704 signed short __atomic_xor_fetch_2(volatile signed short *, signed short, int);705 496 unsigned short __atomic_xor_fetch (volatile unsigned short *, unsigned short, int); 706 unsigned short __atomic_xor_fetch_2(volatile unsigned short *, unsigned short, int);707 497 signed int __atomic_xor_fetch (volatile signed int *, signed int, int); 708 signed int __atomic_xor_fetch_4(volatile signed int *, signed int, int);709 498 unsigned int __atomic_xor_fetch (volatile unsigned int *, unsigned int, int); 710 unsigned int __atomic_xor_fetch_4(volatile unsigned int *, unsigned int, int); 499 signed long int __atomic_xor_fetch (volatile signed long int *, signed long int, int); 500 unsigned long int __atomic_xor_fetch (volatile unsigned long int *, unsigned long int, int); 711 501 signed long long int __atomic_xor_fetch (volatile signed long long int *, signed long long int, int); 712 signed long long int __atomic_xor_fetch_8(volatile signed long long int *, signed long long int, int);713 502 unsigned long long int __atomic_xor_fetch (volatile unsigned long long int *, unsigned long long int, int); 714 unsigned long long int __atomic_xor_fetch_8(volatile unsigned long long int *, unsigned long long int, int);715 503 #if defined(__SIZEOF_INT128__) 716 504 signed __int128 __atomic_xor_fetch (volatile signed __int128 *, signed __int128, int); 717 signed __int128 __atomic_xor_fetch_16(volatile signed __int128 *, signed __int128, int);718 505 unsigned __int128 __atomic_xor_fetch (volatile unsigned __int128 *, unsigned __int128, int); 719 unsigned __int128 __atomic_xor_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);720 506 #endif 721 507 722 508 char __atomic_or_fetch (volatile char *, char, int); 723 char __atomic_or_fetch_1(volatile char *, char, int);724 509 signed char __atomic_or_fetch (volatile signed char *, signed char, int); 725 signed char __atomic_or_fetch_1(volatile signed char *, signed char, int);726 510 unsigned char __atomic_or_fetch (volatile unsigned char *, unsigned char, int); 727 unsigned char __atomic_or_fetch_1(volatile unsigned char *, unsigned char, int);728 511 signed short __atomic_or_fetch (volatile signed short *, signed short, int); 729 signed short __atomic_or_fetch_2(volatile signed short *, signed short, int);730 512 unsigned short __atomic_or_fetch (volatile unsigned short *, unsigned short, int); 731 unsigned short __atomic_or_fetch_2(volatile unsigned short *, unsigned short, int);732 513 signed int __atomic_or_fetch (volatile signed int *, signed int, int); 733 signed int __atomic_or_fetch_4(volatile signed int *, signed int, int);734 514 unsigned int __atomic_or_fetch (volatile unsigned int *, unsigned int, int); 735 unsigned int __atomic_or_fetch_4(volatile unsigned int *, unsigned int, int); 515 signed long int __atomic_or_fetch (volatile signed long int *, signed long int, int); 516 unsigned long int __atomic_or_fetch (volatile unsigned long int *, unsigned long int, int); 736 517 signed long long int __atomic_or_fetch (volatile signed long long int *, signed long long int, int); 737 signed long long int __atomic_or_fetch_8(volatile signed long long int *, signed long long int, int);738 518 unsigned long long int __atomic_or_fetch (volatile unsigned long long int *, unsigned long long int, int); 739 unsigned long long int __atomic_or_fetch_8(volatile unsigned long long int *, unsigned long long int, int);740 519 #if defined(__SIZEOF_INT128__) 741 520 signed __int128 __atomic_or_fetch (volatile signed __int128 *, signed __int128, int); 742 signed __int128 __atomic_or_fetch_16(volatile signed __int128 *, signed __int128, int);743 521 unsigned __int128 __atomic_or_fetch (volatile unsigned __int128 *, unsigned __int128, int); 744 unsigned __int128 __atomic_or_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);745 522 #endif 746 523 747 524 char __atomic_fetch_add (volatile char *, char, int); 748 char __atomic_fetch_add_1(volatile char *, char, int);749 525 signed char __atomic_fetch_add (volatile signed char *, signed char, int); 750 signed char __atomic_fetch_add_1(volatile signed char *, signed char, int);751 526 unsigned char __atomic_fetch_add (volatile unsigned char *, unsigned char, int); 752 unsigned char __atomic_fetch_add_1(volatile unsigned char *, unsigned char, int);753 527 signed short __atomic_fetch_add (volatile signed short *, signed short, int); 754 signed short __atomic_fetch_add_2(volatile signed short *, signed short, int);755 528 unsigned short __atomic_fetch_add (volatile unsigned short *, unsigned short, int); 756 unsigned short __atomic_fetch_add_2(volatile unsigned short *, unsigned short, int);757 529 signed int __atomic_fetch_add (volatile signed int *, signed int, int); 758 signed int __atomic_fetch_add_4(volatile signed int *, signed int, int);759 530 unsigned int __atomic_fetch_add (volatile unsigned int *, unsigned int, int); 760 unsigned int __atomic_fetch_add_4(volatile unsigned int *, unsigned int, int); 531 signed long int __atomic_fetch_add (volatile signed long int *, signed long int, int); 532 unsigned long int __atomic_fetch_add (volatile unsigned long int *, unsigned long int, int); 761 533 signed long long int __atomic_fetch_add (volatile signed long long int *, signed long long int, int); 762 signed long long int __atomic_fetch_add_8(volatile signed long long int *, signed long long int, int);763 534 unsigned long long int __atomic_fetch_add (volatile unsigned long long int *, unsigned long long int, int); 764 unsigned long long int __atomic_fetch_add_8(volatile unsigned long long int *, unsigned long long int, int);765 535 #if defined(__SIZEOF_INT128__) 766 536 signed __int128 __atomic_fetch_add (volatile signed __int128 *, signed __int128, int); 767 signed __int128 __atomic_fetch_add_16(volatile signed __int128 *, signed __int128, int);768 537 unsigned __int128 __atomic_fetch_add (volatile unsigned __int128 *, unsigned __int128, int); 769 unsigned __int128 __atomic_fetch_add_16(volatile unsigned __int128 *, unsigned __int128, int);770 538 #endif 771 539 772 540 char __atomic_fetch_sub (volatile char *, char, int); 773 char __atomic_fetch_sub_1(volatile char *, char, int);774 541 signed char __atomic_fetch_sub (volatile signed char *, signed char, int); 775 signed char __atomic_fetch_sub_1(volatile signed char *, signed char, int);776 542 unsigned char __atomic_fetch_sub (volatile unsigned char *, unsigned char, int); 777 unsigned char __atomic_fetch_sub_1(volatile unsigned char *, unsigned char, int);778 543 signed short __atomic_fetch_sub (volatile signed short *, signed short, int); 779 signed short __atomic_fetch_sub_2(volatile signed short *, signed short, int);780 544 unsigned short __atomic_fetch_sub (volatile unsigned short *, unsigned short, int); 781 unsigned short __atomic_fetch_sub_2(volatile unsigned short *, unsigned short, int);782 545 signed int __atomic_fetch_sub (volatile signed int *, signed int, int); 783 signed int __atomic_fetch_sub_4(volatile signed int *, signed int, int);784 546 unsigned int __atomic_fetch_sub (volatile unsigned int *, unsigned int, int); 785 unsigned int __atomic_fetch_sub_4(volatile unsigned int *, unsigned int, int); 547 signed long int __atomic_fetch_sub (volatile signed long int *, signed long int, int); 548 unsigned long int __atomic_fetch_sub (volatile unsigned long int *, unsigned long int, int); 786 549 signed long long int __atomic_fetch_sub (volatile signed long long int *, signed long long int, int); 787 signed long long int __atomic_fetch_sub_8(volatile signed long long int *, signed long long int, int);788 550 unsigned long long int __atomic_fetch_sub (volatile unsigned long long int *, unsigned long long int, int); 789 unsigned long long int __atomic_fetch_sub_8(volatile unsigned long long int *, unsigned long long int, int);790 551 #if defined(__SIZEOF_INT128__) 791 552 signed __int128 __atomic_fetch_sub (volatile signed __int128 *, signed __int128, int); 792 signed __int128 __atomic_fetch_sub_16(volatile signed __int128 *, signed __int128, int);793 553 unsigned __int128 __atomic_fetch_sub (volatile unsigned __int128 *, unsigned __int128, int); 794 unsigned __int128 __atomic_fetch_sub_16(volatile unsigned __int128 *, unsigned __int128, int);795 554 #endif 796 555 797 556 char __atomic_fetch_and (volatile char *, char, int); 798 char __atomic_fetch_and_1(volatile char *, char, int);799 557 signed char __atomic_fetch_and (volatile signed char *, signed char, int); 800 signed char __atomic_fetch_and_1(volatile signed char *, signed char, int);801 558 unsigned char __atomic_fetch_and (volatile unsigned char *, unsigned char, int); 802 unsigned char __atomic_fetch_and_1(volatile unsigned char *, unsigned char, int);803 559 signed short __atomic_fetch_and (volatile signed short *, signed short, int); 804 signed short __atomic_fetch_and_2(volatile signed short *, signed short, int);805 560 unsigned short __atomic_fetch_and (volatile unsigned short *, unsigned short, int); 806 unsigned short __atomic_fetch_and_2(volatile unsigned short *, unsigned short, int);807 561 signed int __atomic_fetch_and (volatile signed int *, signed int, int); 808 signed int __atomic_fetch_and_4(volatile signed int *, signed int, int);809 562 unsigned int __atomic_fetch_and (volatile unsigned int *, unsigned int, int); 810 unsigned int __atomic_fetch_and_4(volatile unsigned int *, unsigned int, int); 563 signed long int __atomic_fetch_and (volatile signed long int *, signed long int, int); 564 unsigned long int __atomic_fetch_and (volatile unsigned long int *, unsigned long int, int); 811 565 signed long long int __atomic_fetch_and (volatile signed long long int *, signed long long int, int); 812 signed long long int __atomic_fetch_and_8(volatile signed long long int *, signed long long int, int);813 566 unsigned long long int __atomic_fetch_and (volatile unsigned long long int *, unsigned long long int, int); 814 unsigned long long int __atomic_fetch_and_8(volatile unsigned long long int *, unsigned long long int, int);815 567 #if defined(__SIZEOF_INT128__) 816 568 signed __int128 __atomic_fetch_and (volatile signed __int128 *, signed __int128, int); 817 signed __int128 __atomic_fetch_and_16(volatile signed __int128 *, signed __int128, int);818 569 unsigned __int128 __atomic_fetch_and (volatile unsigned __int128 *, unsigned __int128, int); 819 unsigned __int128 __atomic_fetch_and_16(volatile unsigned __int128 *, unsigned __int128, int);820 570 #endif 821 571 822 572 char __atomic_fetch_nand (volatile char *, char, int); 823 char __atomic_fetch_nand_1(volatile char *, char, int);824 573 signed char __atomic_fetch_nand (volatile signed char *, signed char, int); 825 signed char __atomic_fetch_nand_1(volatile signed char *, signed char, int);826 574 unsigned char __atomic_fetch_nand (volatile unsigned char *, unsigned char, int); 827 unsigned char __atomic_fetch_nand_1(volatile unsigned char *, unsigned char, int);828 575 signed short __atomic_fetch_nand (volatile signed short *, signed short, int); 829 signed short __atomic_fetch_nand_2(volatile signed short *, signed short, int);830 576 unsigned short __atomic_fetch_nand (volatile unsigned short *, unsigned short, int); 831 unsigned short __atomic_fetch_nand_2(volatile unsigned short *, unsigned short, int);832 577 signed int __atomic_fetch_nand (volatile signed int *, signed int, int); 833 signed int __atomic_fetch_nand_4(volatile signed int *, signed int, int);834 578 unsigned int __atomic_fetch_nand (volatile unsigned int *, unsigned int, int); 835 unsigned int __atomic_fetch_nand_4(volatile unsigned int *, unsigned int, int); 579 signed long int __atomic_fetch_nand (volatile signed long int *, signed long int, int); 580 unsigned long int __atomic_fetch_nand (volatile unsigned long int *, unsigned long int, int); 836 581 signed long long int __atomic_fetch_nand (volatile signed long long int *, signed long long int, int); 837 signed long long int __atomic_fetch_nand_8(volatile signed long long int *, signed long long int, int);838 582 unsigned long long int __atomic_fetch_nand (volatile unsigned long long int *, unsigned long long int, int); 839 unsigned long long int __atomic_fetch_nand_8(volatile unsigned long long int *, unsigned long long int, int);840 583 #if defined(__SIZEOF_INT128__) 841 584 signed __int128 __atomic_fetch_nand (volatile signed __int128 *, signed __int128, int); 842 signed __int128 __atomic_fetch_nand_16(volatile signed __int128 *, signed __int128, int);843 585 unsigned __int128 __atomic_fetch_nand (volatile unsigned __int128 *, unsigned __int128, int); 844 unsigned __int128 __atomic_fetch_nand_16(volatile unsigned __int128 *, unsigned __int128, int);845 586 #endif 846 587 847 588 char __atomic_fetch_xor (volatile char *, char, int); 848 char __atomic_fetch_xor_1(volatile char *, char, int);849 589 signed char __atomic_fetch_xor (volatile signed char *, signed char, int); 850 signed char __atomic_fetch_xor_1(volatile signed char *, signed char, int);851 590 unsigned char __atomic_fetch_xor (volatile unsigned char *, unsigned char, int); 852 unsigned char __atomic_fetch_xor_1(volatile unsigned char *, unsigned char, int);853 591 signed short __atomic_fetch_xor (volatile signed short *, signed short, int); 854 signed short __atomic_fetch_xor_2(volatile signed short *, signed short, int);855 592 unsigned short __atomic_fetch_xor (volatile unsigned short *, unsigned short, int); 856 unsigned short __atomic_fetch_xor_2(volatile unsigned short *, unsigned short, int);857 593 signed int __atomic_fetch_xor (volatile signed int *, signed int, int); 858 signed int __atomic_fetch_xor_4(volatile signed int *, signed int, int);859 594 unsigned int __atomic_fetch_xor (volatile unsigned int *, unsigned int, int); 860 unsigned int __atomic_fetch_xor_4(volatile unsigned int *, unsigned int, int); 595 signed long int __atomic_fetch_xor (volatile signed long int *, signed long int, int); 596 unsigned long int __atomic_fetch_xor (volatile unsigned long int *, unsigned long int, int); 861 597 signed long long int __atomic_fetch_xor (volatile signed long long int *, signed long long int, int); 862 signed long long int __atomic_fetch_xor_8(volatile signed long long int *, signed long long int, int);863 598 unsigned long long int __atomic_fetch_xor (volatile unsigned long long int *, unsigned long long int, int); 864 unsigned long long int __atomic_fetch_xor_8(volatile unsigned long long int *, unsigned long long int, int);865 599 #if defined(__SIZEOF_INT128__) 866 600 signed __int128 __atomic_fetch_xor (volatile signed __int128 *, signed __int128, int); 867 signed __int128 __atomic_fetch_xor_16(volatile signed __int128 *, signed __int128, int);868 601 unsigned __int128 __atomic_fetch_xor (volatile unsigned __int128 *, unsigned __int128, int); 869 unsigned __int128 __atomic_fetch_xor_16(volatile unsigned __int128 *, unsigned __int128, int);870 602 #endif 871 603 872 604 char __atomic_fetch_or (volatile char *, char, int); 873 char __atomic_fetch_or_1(volatile char *, char, int);874 605 signed char __atomic_fetch_or (volatile signed char *, signed char, int); 875 signed char __atomic_fetch_or_1(volatile signed char *, signed char, int);876 606 unsigned char __atomic_fetch_or (volatile unsigned char *, unsigned char, int); 877 unsigned char __atomic_fetch_or_1(volatile unsigned char *, unsigned char, int);878 607 signed short __atomic_fetch_or (volatile signed short *, signed short, int); 879 signed short __atomic_fetch_or_2(volatile signed short *, signed short, int);880 608 unsigned short __atomic_fetch_or (volatile unsigned short *, unsigned short, int); 881 unsigned short __atomic_fetch_or_2(volatile unsigned short *, unsigned short, int);882 609 signed int __atomic_fetch_or (volatile signed int *, signed int, int); 883 signed int __atomic_fetch_or_4(volatile signed int *, signed int, int);884 610 unsigned int __atomic_fetch_or (volatile unsigned int *, unsigned int, int); 885 unsigned int __atomic_fetch_or_4(volatile unsigned int *, unsigned int, int); 611 signed long int __atomic_fetch_or (volatile signed long int *, signed long int, int); 612 unsigned long int __atomic_fetch_or (volatile unsigned long int *, unsigned long int, int); 886 613 signed long long int __atomic_fetch_or (volatile signed long long int *, signed long long int, int); 887 signed long long int __atomic_fetch_or_8(volatile signed long long int *, signed long long int, int);888 614 unsigned long long int __atomic_fetch_or (volatile unsigned long long int *, unsigned long long int, int); 889 unsigned long long int __atomic_fetch_or_8(volatile unsigned long long int *, unsigned long long int, int);890 615 #if defined(__SIZEOF_INT128__) 891 616 signed __int128 __atomic_fetch_or (volatile signed __int128 *, signed __int128, int); 892 signed __int128 __atomic_fetch_or_16(volatile signed __int128 *, signed __int128, int);893 617 unsigned __int128 __atomic_fetch_or (volatile unsigned __int128 *, unsigned __int128, int); 894 unsigned __int128 __atomic_fetch_or_16(volatile unsigned __int128 *, unsigned __int128, int);895 618 #endif 896 619 -
libcfa/src/assert.cfa
r7768b8d r30763fd 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 20 15:10:26 201713 // Update Count : 212 // Last Modified On : Thu Nov 21 17:09:26 2019 13 // Update Count : 5 14 14 // 15 15 … … 17 17 #include <stdarg.h> // varargs 18 18 #include <stdio.h> // fprintf 19 #include <unistd.h> // STDERR_FILENO 19 20 #include "bits/debug.hfa" 20 21 … … 26 27 // called by macro assert in assert.h 27 28 void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) { 28 __cfaabi_ dbg_bits_print_safe(CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );29 __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file ); 29 30 abort(); 30 31 } … … 32 33 // called by macro assertf 33 34 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) { 34 __cfaabi_ dbg_bits_acquire();35 __cfaabi_ dbg_bits_print_nolock(CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );35 __cfaabi_bits_acquire(); 36 __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file ); 36 37 37 38 va_list args; 38 39 va_start( args, fmt ); 39 __cfaabi_ dbg_bits_print_vararg(fmt, args );40 __cfaabi_bits_print_vararg( STDERR_FILENO, fmt, args ); 40 41 va_end( args ); 41 42 42 __cfaabi_ dbg_bits_print_nolock("\n" );43 __cfaabi_ dbg_bits_release();43 __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" ); 44 __cfaabi_bits_release(); 44 45 abort(); 45 46 } -
libcfa/src/bits/align.hfa
r7768b8d r30763fd 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 21 23:05:35 201713 // Update Count : 212 // Last Modified On : Sat Nov 16 18:58:22 2019 13 // Update Count : 3 14 14 // 15 15 // This library is free software; you can redistribute it and/or modify it … … 33 33 34 34 // Minimum size used to align memory boundaries for memory allocations. 35 #define libAlign() (sizeof(double)) 35 //#define libAlign() (sizeof(double)) 36 // gcc-7 uses xmms instructions, which require 16 byte alignment. 37 #define libAlign() (16) 36 38 37 39 // Check for power of 2 -
libcfa/src/bits/debug.cfa
r7768b8d r30763fd 10 10 // Created On : Thu Mar 30 12:30:01 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jul 14 22:17:35201913 // Update Count : 412 // Last Modified On : Thu Nov 21 17:16:30 2019 13 // Update Count : 10 14 14 // 15 15 … … 28 28 extern "C" { 29 29 30 void __cfaabi_ dbg_bits_write(const char *in_buffer, int len ) {30 void __cfaabi_bits_write( int fd, const char *in_buffer, int len ) { 31 31 // ensure all data is written 32 32 for ( int count = 0, retcode; count < len; count += retcode ) { … … 34 34 35 35 for ( ;; ) { 36 retcode = write( STDERR_FILENO, in_buffer, len - count );36 retcode = write( fd, in_buffer, len - count ); 37 37 38 38 // not a timer interrupt ? … … 44 44 } 45 45 46 void __cfaabi_ dbg_bits_acquire() __attribute__((__weak__)) {}47 void __cfaabi_ dbg_bits_release() __attribute__((__weak__)) {}46 void __cfaabi_bits_acquire() __attribute__((__weak__)) {} 47 void __cfaabi_bits_release() __attribute__((__weak__)) {} 48 48 49 void __cfaabi_ dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {49 void __cfaabi_bits_print_safe ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) { 50 50 va_list args; 51 51 52 52 va_start( args, fmt ); 53 __cfaabi_ dbg_bits_acquire();53 __cfaabi_bits_acquire(); 54 54 55 55 int len = vsnprintf( buffer, buffer_size, fmt, args ); 56 __cfaabi_ dbg_bits_write(buffer, len );56 __cfaabi_bits_write( fd, buffer, len ); 57 57 58 __cfaabi_ dbg_bits_release();58 __cfaabi_bits_release(); 59 59 va_end( args ); 60 60 } 61 61 62 void __cfaabi_ dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {62 void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) { 63 63 va_list args; 64 64 … … 66 66 67 67 int len = vsnprintf( buffer, buffer_size, fmt, args ); 68 __cfaabi_ dbg_bits_write(buffer, len );68 __cfaabi_bits_write( fd, buffer, len ); 69 69 70 70 va_end( args ); 71 71 } 72 72 73 void __cfaabi_ dbg_bits_print_vararg(const char fmt[], va_list args ) {73 void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list args ) { 74 74 int len = vsnprintf( buffer, buffer_size, fmt, args ); 75 __cfaabi_ dbg_bits_write(buffer, len );75 __cfaabi_bits_write( fd, buffer, len ); 76 76 } 77 77 78 void __cfaabi_ dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) {78 void __cfaabi_bits_print_buffer( int fd, char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) )) { 79 79 va_list args; 80 80 … … 82 82 83 83 int len = vsnprintf( in_buffer, in_buffer_size, fmt, args ); 84 __cfaabi_ dbg_bits_write(in_buffer, len );84 __cfaabi_bits_write( fd, in_buffer, len ); 85 85 86 86 va_end( args ); -
libcfa/src/bits/debug.hfa
r7768b8d r30763fd 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 8 12:35:19 201813 // Update Count : 212 // Last Modified On : Thu Nov 21 17:06:58 2019 13 // Update Count : 8 14 14 // 15 15 … … 38 38 #include <stdio.h> 39 39 40 extern void __cfaabi_dbg_bits_write(const char *buffer, int len );41 extern void __cfaabi_dbg_bits_acquire();42 extern void __cfaabi_dbg_bits_release();43 extern void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));44 extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));45 extern void __cfaabi_dbg_bits_print_vararg(const char fmt[], va_list arg );46 extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) ));40 extern void __cfaabi_bits_write( int fd, const char *buffer, int len ); 41 extern void __cfaabi_bits_acquire(); 42 extern void __cfaabi_bits_release(); 43 extern void __cfaabi_bits_print_safe ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )); 44 extern void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )); 45 extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg ); 46 extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) )); 47 47 #ifdef __cforall 48 48 } … … 50 50 51 51 #ifdef __CFA_DEBUG_PRINT__ 52 #define __cfaabi_dbg_write( buffer, len ) __cfaabi_ dbg_bits_write(buffer, len )53 #define __cfaabi_dbg_acquire() __cfaabi_ dbg_bits_acquire()54 #define __cfaabi_dbg_release() __cfaabi_ dbg_bits_release()55 #define __cfaabi_dbg_print_safe(...) __cfaabi_ dbg_bits_print_safe (__VA_ARGS__)56 #define __cfaabi_dbg_print_nolock(...) __cfaabi_ dbg_bits_print_nolock (__VA_ARGS__)57 #define __cfaabi_dbg_print_buffer(...) __cfaabi_ dbg_bits_print_buffer (__VA_ARGS__)58 #define __cfaabi_dbg_print_buffer_decl(...) char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_ dbg_bits_write( __dbg_text, __dbg_len );59 #define __cfaabi_dbg_print_buffer_local(...) __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_ bits_write( __dbg_text, __dbg_len );52 #define __cfaabi_dbg_write( buffer, len ) __cfaabi_bits_write( STDERR_FILENO, buffer, len ) 53 #define __cfaabi_dbg_acquire() __cfaabi_bits_acquire() 54 #define __cfaabi_dbg_release() __cfaabi_bits_release() 55 #define __cfaabi_dbg_print_safe(...) __cfaabi_bits_print_safe (__VA_ARGS__) 56 #define __cfaabi_dbg_print_nolock(...) __cfaabi_bits_print_nolock (__VA_ARGS__) 57 #define __cfaabi_dbg_print_buffer(...) __cfaabi_bits_print_buffer (__VA_ARGS__) 58 #define __cfaabi_dbg_print_buffer_decl(...) char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len ); 59 #define __cfaabi_dbg_print_buffer_local(...) __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( __dbg_text, __dbg_len ); 60 60 #else 61 61 #define __cfaabi_dbg_write(...) ((void)0) -
libcfa/src/concurrency/kernel.cfa
r7768b8d r30763fd 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 20 17:21:23201913 // Update Count : 2 512 // Last Modified On : Thu Nov 21 16:46:59 2019 13 // Update Count : 27 14 14 // 15 15 … … 841 841 if(thrd) { 842 842 int len = snprintf( abort_text, abort_text_size, "Error occurred while executing thread %.256s (%p)", thrd->self_cor.name, thrd ); 843 __cfaabi_ dbg_bits_write(abort_text, len );843 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 844 844 845 845 if ( &thrd->self_cor != thrd->curr_cor ) { 846 846 len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", thrd->curr_cor->name, thrd->curr_cor ); 847 __cfaabi_ dbg_bits_write(abort_text, len );847 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 848 848 } 849 849 else { 850 __cfaabi_ dbg_bits_write(".\n", 2 );850 __cfaabi_bits_write( STDERR_FILENO, ".\n", 2 ); 851 851 } 852 852 } 853 853 else { 854 854 int len = snprintf( abort_text, abort_text_size, "Error occurred outside of any thread.\n" ); 855 __cfaabi_ dbg_bits_write(abort_text, len );855 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 856 856 } 857 857 } … … 864 864 865 865 extern "C" { 866 void __cfaabi_ dbg_bits_acquire() {866 void __cfaabi_bits_acquire() { 867 867 lock( kernel_debug_lock __cfaabi_dbg_ctx2 ); 868 868 } 869 869 870 void __cfaabi_ dbg_bits_release() {870 void __cfaabi_bits_release() { 871 871 unlock( kernel_debug_lock ); 872 872 } -
libcfa/src/heap.cfa
r7768b8d r30763fd 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Oct 18 07:42:09201913 // Update Count : 55612 // Last Modified On : Sun Nov 24 17:56:15 2019 13 // Update Count : 638 14 14 // 15 15 … … 18 18 #include <stdio.h> // snprintf, fileno 19 19 #include <errno.h> // errno 20 #include <string.h> // memset, memcpy 20 21 extern "C" { 21 22 #include <sys/mman.h> // mmap, munmap … … 27 28 #include "bits/locks.hfa" // __spinlock_t 28 29 #include "startup.hfa" // STARTUP_PRIORITY_MEMORY 29 #include "stdlib.hfa" // bsearchl30 //#include "stdlib.hfa" // bsearchl 30 31 #include "malloc.h" 31 32 33 #define MIN(x, y) (y > x ? x : y) 32 34 33 35 static bool traceHeap = false; … … 50 52 51 53 52 static bool checkFree = false;53 54 inline bool checkFree() {55 return checkFree;56 } // checkFree57 58 bool checkFreeOn() {59 bool temp = checkFree;60 checkFree = true;54 static bool prtFree = false; 55 56 inline bool prtFree() { 57 return prtFree; 58 } // prtFree 59 60 bool prtFreeOn() { 61 bool temp = prtFree; 62 prtFree = true; 61 63 return temp; 62 } // checkFreeOn63 64 bool checkFreeOff() {65 bool temp = checkFree;66 checkFree = false;64 } // prtFreeOn 65 66 bool prtFreeOff() { 67 bool temp = prtFree; 68 prtFree = false; 67 69 return temp; 68 } // checkFreeOff70 } // prtFreeOff 69 71 70 72 … … 89 91 90 92 enum { 93 // Define the default extension heap amount in units of bytes. When the uC++ supplied heap reaches the brk address, 94 // the brk address is extended by the extension amount. 95 __CFA_DEFAULT_HEAP_EXPANSION__ = (1 * 1024 * 1024), 96 97 // Define the mmap crossover point during allocation. Allocations less than this amount are allocated from buckets; 98 // values greater than or equal to this value are mmap from the operating system. 91 99 __CFA_DEFAULT_MMAP_START__ = (512 * 1024 + 1), 92 __CFA_DEFAULT_HEAP_EXPANSION__ = (1 * 1024 * 1024),93 100 }; 94 101 … … 105 112 static unsigned int allocFree; // running total of allocations minus frees 106 113 107 static void checkUnfreed() {114 static void prtUnfreed() { 108 115 if ( allocFree != 0 ) { 109 116 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT. … … 112 119 // "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n", 113 120 // (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid 114 // __cfaabi_dbg_bits_write( helpText, len );115 } // if 116 } // checkUnfreed121 // __cfaabi_dbg_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug 122 } // if 123 } // prtUnfreed 117 124 118 125 extern "C" { … … 123 130 void heapAppStop() { // called by __cfaabi_appready_startdown 124 131 fclose( stdin ); fclose( stdout ); 125 checkUnfreed();132 prtUnfreed(); 126 133 } // heapAppStop 127 134 } // extern "C" 128 135 #endif // __CFA_DEBUG__ 136 129 137 130 138 // statically allocated variables => zero filled. … … 134 142 static unsigned int maxBucketsUsed; // maximum number of buckets in use 135 143 136 137 // #comment TD : This defined is significantly different from the __ALIGN__ define from locks.hfa138 #define ALIGN 16139 144 140 145 #define SPINLOCK 0 … … 147 152 // Recursive definitions: HeapManager needs size of bucket array and bucket area needs sizeof HeapManager storage. 148 153 // Break recusion by hardcoding number of buckets and statically checking number is correct after bucket array defined. 149 enum { NoBucketSizes = 9 3}; // number of buckets sizes154 enum { NoBucketSizes = 91 }; // number of buckets sizes 150 155 151 156 struct HeapManager { … … 194 199 } kind; // Kind 195 200 } header; // Header 196 char pad[ ALIGN- sizeof( Header )];201 char pad[libAlign() - sizeof( Header )]; 197 202 char data[0]; // storage 198 203 }; // Storage 199 204 200 static_assert( ALIGN >= sizeof( Storage ), "ALIGN< sizeof( Storage )" );205 static_assert( libAlign() >= sizeof( Storage ), "libAlign() < sizeof( Storage )" ); 201 206 202 207 struct FreeHeader { … … 228 233 #define __STATISTICS__ 229 234 235 // Bucket size must be multiple of 16. 230 236 // Powers of 2 are common allocation sizes, so make powers of 2 generate the minimum required size. 231 237 static const unsigned int bucketSizes[] @= { // different bucket sizes 232 16, 32, 48, 64, 233 64 + sizeof(HeapManager.Storage), 96, 112, 128, 128 + sizeof(HeapManager.Storage), 160, 192, 224, 234 256 + sizeof(HeapManager.Storage), 320, 384, 448, 512 + sizeof(HeapManager.Storage), 640, 768, 896, 235 1_024 + sizeof(HeapManager.Storage), 1_536, 2_048 + sizeof(HeapManager.Storage), 2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), 6_144, 236 8_192 + sizeof(HeapManager.Storage), 9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360, 237 16_384 + sizeof(HeapManager.Storage), 18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720, 238 32_768 + sizeof(HeapManager.Storage), 36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440, 239 65_536 + sizeof(HeapManager.Storage), 73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880, 240 131_072 + sizeof(HeapManager.Storage), 147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760, 241 262_144 + sizeof(HeapManager.Storage), 294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520, 242 524_288 + sizeof(HeapManager.Storage), 655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), 1_179_648, 1_310_720, 1_441_792, 243 1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), 2_621_440, 3_145_728, 3_670_016, 244 4_194_304 + sizeof(HeapManager.Storage) 238 16, 32, 48, 64 + sizeof(HeapManager.Storage), // 4 239 96, 112, 128 + sizeof(HeapManager.Storage), // 3 240 160, 192, 224, 256 + sizeof(HeapManager.Storage), // 4 241 320, 384, 448, 512 + sizeof(HeapManager.Storage), // 4 242 640, 768, 896, 1_024 + sizeof(HeapManager.Storage), // 4 243 1_536, 2_048 + sizeof(HeapManager.Storage), // 2 244 2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), // 4 245 6_144, 8_192 + sizeof(HeapManager.Storage), // 2 246 9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360, 16_384 + sizeof(HeapManager.Storage), // 8 247 18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720, 32_768 + sizeof(HeapManager.Storage), // 8 248 36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440, 65_536 + sizeof(HeapManager.Storage), // 8 249 73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880, 131_072 + sizeof(HeapManager.Storage), // 8 250 147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760, 262_144 + sizeof(HeapManager.Storage), // 8 251 294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520, 524_288 + sizeof(HeapManager.Storage), // 8 252 655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), // 4 253 1_179_648, 1_310_720, 1_441_792, 1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), // 8 254 2_621_440, 3_145_728, 3_670_016, 4_194_304 + sizeof(HeapManager.Storage), // 4 245 255 }; 246 256 … … 251 261 static unsigned char lookup[LookupSizes]; // O(1) lookup for small sizes 252 262 #endif // FASTLOOKUP 263 253 264 static int mmapFd = -1; // fake or actual fd for anonymous file 254 255 256 265 #ifdef __CFA_DEBUG__ 257 266 static bool heapBoot = 0; // detect recursion during boot … … 259 268 static HeapManager heapManager __attribute__(( aligned (128) )) @= {}; // size of cache line to prevent false sharing 260 269 261 // #comment TD : The return type of this function should be commented262 static inline bool setMmapStart( size_t value ) {263 if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;264 mmapStart = value; // set global265 266 // find the closest bucket size less than or equal to the mmapStart size267 maxBucketsUsed = bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search268 assert( maxBucketsUsed < NoBucketSizes ); // subscript failure ?269 assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?270 return false;271 } // setMmapStart272 273 274 static void ?{}( HeapManager & manager ) with ( manager ) {275 pageSize = sysconf( _SC_PAGESIZE );276 277 for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists278 freeLists[i].blockSize = bucketSizes[i];279 } // for280 281 #ifdef FASTLOOKUP282 unsigned int idx = 0;283 for ( unsigned int i = 0; i < LookupSizes; i += 1 ) {284 if ( i > bucketSizes[idx] ) idx += 1;285 lookup[i] = idx;286 } // for287 #endif // FASTLOOKUP288 289 if ( setMmapStart( default_mmap_start() ) ) {290 abort( "HeapManager : internal error, mmap start initialization failure." );291 } // if292 heapExpand = default_heap_expansion();293 294 char * End = (char *)sbrk( 0 );295 sbrk( (char *)libCeiling( (long unsigned int)End, libAlign() ) - End ); // move start of heap to multiple of alignment296 heapBegin = heapEnd = sbrk( 0 ); // get new start point297 } // HeapManager298 299 300 static void ^?{}( HeapManager & ) {301 #ifdef __STATISTICS__302 // if ( traceHeapTerm() ) {303 // printStats();304 // if ( checkfree() ) checkFree( heapManager, true );305 // } // if306 #endif // __STATISTICS__307 } // ~HeapManager308 309 310 static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) ));311 void memory_startup( void ) {312 #ifdef __CFA_DEBUG__313 if ( unlikely( heapBoot ) ) { // check for recursion during system boot314 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.315 abort( "boot() : internal error, recursively invoked during system boot." );316 } // if317 heapBoot = true;318 #endif // __CFA_DEBUG__319 320 //assert( heapManager.heapBegin != 0 );321 //heapManager{};322 if ( heapManager.heapBegin == 0 ) heapManager{};323 } // memory_startup324 325 static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) ));326 void memory_shutdown( void ) {327 ^heapManager{};328 } // memory_shutdown329 330 270 331 271 #ifdef __STATISTICS__ 332 static unsigned long long int mmap_storage; // heap statistics counters 272 // Heap statistics counters. 273 static unsigned long long int mmap_storage; 333 274 static unsigned int mmap_calls; 334 275 static unsigned long long int munmap_storage; … … 348 289 static unsigned long long int realloc_storage; 349 290 static unsigned int realloc_calls; 350 351 static int statfd; // statistics file descriptor (changed by malloc_stats_fd) 352 291 // Statistics file descriptor (changed by malloc_stats_fd). 292 static int statfd = STDERR_FILENO; // default stderr 353 293 354 294 // Use "write" because streams may be shutdown when calls are made. 355 295 static void printStats() { 356 296 char helpText[512]; 357 __cfaabi_ dbg_bits_print_buffer(helpText, sizeof(helpText),297 __cfaabi_bits_print_buffer( STDERR_FILENO, helpText, sizeof(helpText), 358 298 "\nHeap statistics:\n" 359 299 " malloc: calls %u / storage %llu\n" … … 405 345 sbrk_calls, sbrk_storage 406 346 ); 407 return write( fileno( stream ), helpText, len ); // -1 => error 347 __cfaabi_bits_write( fileno( stream ), helpText, len ); // ensures all bytes written or exit 348 return len; 408 349 } // printStatsXML 409 350 #endif // __STATISTICS__ 351 410 352 411 353 // #comment TD : Is this the samething as Out-of-Memory? … … 418 360 419 361 static inline void checkAlign( size_t alignment ) { 420 if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) {421 abort( "Alignment %zu for memory allocation is less than sizeof(void *) and/or not a power of 2.", alignment);362 if ( alignment < libAlign() || ! libPow2( alignment ) ) { 363 abort( "Alignment %zu for memory allocation is less than %d and/or not a power of 2.", alignment, libAlign() ); 422 364 } // if 423 365 } // checkAlign … … 431 373 432 374 433 static inline void checkHeader( bool check, const char * name, void * addr ) { 434 if ( unlikely( check ) ) { // bad address ? 435 abort( "Attempt to %s storage %p with address outside the heap.\n" 436 "Possible cause is duplicate free on same block or overwriting of memory.", 437 name, addr ); 438 } // if 439 } // checkHeader 440 441 // #comment TD : function should be commented and/or have a more evocative name 442 // this isn't either a check or a constructor which is what I would expect this function to be 443 static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & size, size_t & alignment ) { 444 if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ? 445 size_t offset = header->kind.fake.offset; 446 alignment = header->kind.fake.alignment & -2; // remove flag from value 447 #ifdef __CFA_DEBUG__ 448 checkAlign( alignment ); // check alignment 449 #endif // __CFA_DEBUG__ 450 header = (HeapManager.Storage.Header *)((char *)header - offset); 451 } // if 452 } // fakeHeader 453 454 // #comment TD : Why is this a define 455 #define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) )) 456 457 static inline bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) { 458 header = headerAddr( addr ); 459 460 if ( unlikely( heapEnd < addr ) ) { // mmapped ? 461 fakeHeader( header, size, alignment ); 462 size = header->kind.real.blockSize & -3; // mmap size 463 return true; 464 } // if 465 466 #ifdef __CFA_DEBUG__ 467 checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ? 468 #endif // __CFA_DEBUG__ 469 470 // #comment TD : This code looks weird... 471 // It's called as the first statement of both branches of the last if, with the same parameters in all cases 472 473 // header may be safe to dereference 474 fakeHeader( header, size, alignment ); 475 #ifdef __CFA_DEBUG__ 476 checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -) 477 #endif // __CFA_DEBUG__ 478 479 freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3); 480 #ifdef __CFA_DEBUG__ 481 if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) { 482 abort( "Attempt to %s storage %p with corrupted header.\n" 483 "Possible cause is duplicate free on same block or overwriting of header information.", 484 name, addr ); 485 } // if 486 #endif // __CFA_DEBUG__ 487 size = freeElem->blockSize; 488 return false; 489 } // headers 490 491 492 static inline void * extend( size_t size ) with ( heapManager ) { 493 lock( extlock __cfaabi_dbg_ctx2 ); 494 ptrdiff_t rem = heapRemaining - size; 495 if ( rem < 0 ) { 496 // If the size requested is bigger than the current remaining storage, increase the size of the heap. 497 498 size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() ); 499 if ( sbrk( increase ) == (void *)-1 ) { 500 unlock( extlock ); 501 errno = ENOMEM; 502 return 0; 503 } // if 504 #ifdef __STATISTICS__ 505 sbrk_calls += 1; 506 sbrk_storage += increase; 507 #endif // __STATISTICS__ 508 #ifdef __CFA_DEBUG__ 509 // Set new memory to garbage so subsequent uninitialized usages might fail. 510 memset( (char *)heapEnd + heapRemaining, '\377', increase ); 511 #endif // __CFA_DEBUG__ 512 rem = heapRemaining + increase - size; 513 } // if 514 515 HeapManager.Storage * block = (HeapManager.Storage *)heapEnd; 516 heapRemaining = rem; 517 heapEnd = (char *)heapEnd + size; 518 unlock( extlock ); 519 return block; 520 } // extend 521 522 375 // thunk problem 523 376 size_t Bsearchl( unsigned int key, const unsigned int * vals, size_t dim ) { 524 377 size_t l = 0, m, h = dim; … … 535 388 536 389 390 static inline bool setMmapStart( size_t value ) { // true => mmapped, false => sbrk 391 if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true; 392 mmapStart = value; // set global 393 394 // find the closest bucket size less than or equal to the mmapStart size 395 maxBucketsUsed = Bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search 396 assert( maxBucketsUsed < NoBucketSizes ); // subscript failure ? 397 assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ? 398 return false; 399 } // setMmapStart 400 401 402 static inline void checkHeader( bool check, const char * name, void * addr ) { 403 if ( unlikely( check ) ) { // bad address ? 404 abort( "Attempt to %s storage %p with address outside the heap.\n" 405 "Possible cause is duplicate free on same block or overwriting of memory.", 406 name, addr ); 407 } // if 408 } // checkHeader 409 410 411 static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & alignment ) { 412 if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ? 413 size_t offset = header->kind.fake.offset; 414 alignment = header->kind.fake.alignment & -2; // remove flag from value 415 #ifdef __CFA_DEBUG__ 416 checkAlign( alignment ); // check alignment 417 #endif // __CFA_DEBUG__ 418 header = (HeapManager.Storage.Header *)((char *)header - offset); 419 } // if 420 } // fakeHeader 421 422 423 // <-------+----------------------------------------------------> bsize (bucket size) 424 // |header |addr 425 //================================================================================== 426 // | alignment 427 // <-----------------<------------+-----------------------------> bsize (bucket size) 428 // |fake-header | addr 429 #define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) )) 430 431 // <-------<<--------------------- dsize ---------------------->> bsize (bucket size) 432 // |header |addr 433 //================================================================================== 434 // | alignment 435 // <------------------------------<<---------- dsize --------->>> bsize (bucket size) 436 // |fake-header |addr 437 #define dataStorage( bsize, addr, header ) (bsize - ( (char *)addr - (char *)header )) 438 439 440 static inline bool headers( const char * name __attribute__(( unused )), void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) { 441 header = headerAddr( addr ); 442 443 if ( unlikely( heapEnd < addr ) ) { // mmapped ? 444 fakeHeader( header, alignment ); 445 size = header->kind.real.blockSize & -3; // mmap size 446 return true; 447 } // if 448 449 #ifdef __CFA_DEBUG__ 450 checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ? 451 #endif // __CFA_DEBUG__ 452 453 // header may be safe to dereference 454 fakeHeader( header, alignment ); 455 #ifdef __CFA_DEBUG__ 456 checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -) 457 #endif // __CFA_DEBUG__ 458 459 freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3); 460 #ifdef __CFA_DEBUG__ 461 if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) { 462 abort( "Attempt to %s storage %p with corrupted header.\n" 463 "Possible cause is duplicate free on same block or overwriting of header information.", 464 name, addr ); 465 } // if 466 #endif // __CFA_DEBUG__ 467 size = freeElem->blockSize; 468 return false; 469 } // headers 470 471 472 static inline void * extend( size_t size ) with ( heapManager ) { 473 lock( extlock __cfaabi_dbg_ctx2 ); 474 ptrdiff_t rem = heapRemaining - size; 475 if ( rem < 0 ) { 476 // If the size requested is bigger than the current remaining storage, increase the size of the heap. 477 478 size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() ); 479 if ( sbrk( increase ) == (void *)-1 ) { 480 unlock( extlock ); 481 errno = ENOMEM; 482 return 0p; 483 } // if 484 #ifdef __STATISTICS__ 485 sbrk_calls += 1; 486 sbrk_storage += increase; 487 #endif // __STATISTICS__ 488 #ifdef __CFA_DEBUG__ 489 // Set new memory to garbage so subsequent uninitialized usages might fail. 490 memset( (char *)heapEnd + heapRemaining, '\377', increase ); 491 #endif // __CFA_DEBUG__ 492 rem = heapRemaining + increase - size; 493 } // if 494 495 HeapManager.Storage * block = (HeapManager.Storage *)heapEnd; 496 heapRemaining = rem; 497 heapEnd = (char *)heapEnd + size; 498 unlock( extlock ); 499 return block; 500 } // extend 501 502 537 503 static inline void * doMalloc( size_t size ) with ( heapManager ) { 538 504 HeapManager.Storage * block; // pointer to new block of storage … … 541 507 // along with the block and is a multiple of the alignment size. 542 508 543 if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0 ;509 if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0p; 544 510 size_t tsize = size + sizeof(HeapManager.Storage); 545 511 if ( likely( tsize < mmapStart ) ) { // small size => sbrk … … 574 540 block = freeElem->freeList.pop(); 575 541 #endif // SPINLOCK 576 if ( unlikely( block == 0 ) ) {// no free block ?542 if ( unlikely( block == 0p ) ) { // no free block ? 577 543 #if defined( SPINLOCK ) 578 544 unlock( freeElem->lock ); … … 583 549 584 550 block = (HeapManager.Storage *)extend( tsize ); // mutual exclusion on call 585 if ( unlikely( block == 0 ) ) return 0;586 551 if ( unlikely( block == 0p ) ) return 0p; 552 #if defined( SPINLOCK ) 587 553 } else { 588 554 freeElem->freeList = block->header.kind.real.next; 589 555 unlock( freeElem->lock ); 590 556 #endif // SPINLOCK 591 557 } // if 592 558 593 559 block->header.kind.real.home = freeElem; // pointer back to free list of apropriate size 594 560 } else { // large size => mmap 595 if ( unlikely( size > ~0ul - pageSize ) ) return 0 ;561 if ( unlikely( size > ~0ul - pageSize ) ) return 0p; 596 562 tsize = libCeiling( tsize, pageSize ); // must be multiple of page size 597 563 #ifdef __STATISTICS__ … … 611 577 } // if 612 578 613 void * a rea= &(block->data); // adjust off header to user bytes579 void * addr = &(block->data); // adjust off header to user bytes 614 580 615 581 #ifdef __CFA_DEBUG__ 616 assert( ((uintptr_t)a rea& (libAlign() - 1)) == 0 ); // minimum alignment ?582 assert( ((uintptr_t)addr & (libAlign() - 1)) == 0 ); // minimum alignment ? 617 583 __atomic_add_fetch( &allocFree, tsize, __ATOMIC_SEQ_CST ); 618 584 if ( traceHeap() ) { 619 585 enum { BufferSize = 64 }; 620 586 char helpText[BufferSize]; 621 int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", a rea, size, tsize );622 // int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", a rea, size );623 __cfaabi_ dbg_bits_write( helpText, len );587 int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", addr, size, tsize ); 588 // int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", addr, size ); 589 __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug 624 590 } // if 625 591 #endif // __CFA_DEBUG__ 626 592 627 return a rea;593 return addr; 628 594 } // doMalloc 629 595 … … 631 597 static inline void doFree( void * addr ) with ( heapManager ) { 632 598 #ifdef __CFA_DEBUG__ 633 if ( unlikely( heapManager.heapBegin == 0 ) ) {599 if ( unlikely( heapManager.heapBegin == 0p ) ) { 634 600 abort( "doFree( %p ) : internal error, called before heap is initialized.", addr ); 635 601 } // if … … 677 643 char helpText[BufferSize]; 678 644 int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size ); 679 __cfaabi_ dbg_bits_write( helpText, len );645 __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug 680 646 } // if 681 647 #endif // __CFA_DEBUG__ … … 683 649 684 650 685 size_t checkFree( HeapManager & manager ) with ( manager ) {651 size_t prtFree( HeapManager & manager ) with ( manager ) { 686 652 size_t total = 0; 687 653 #ifdef __STATISTICS__ 688 __cfaabi_ dbg_bits_acquire();689 __cfaabi_ dbg_bits_print_nolock("\nBin lists (bin size : free blocks on list)\n" );654 __cfaabi_bits_acquire(); 655 __cfaabi_bits_print_nolock( STDERR_FILENO, "\nBin lists (bin size : free blocks on list)\n" ); 690 656 #endif // __STATISTICS__ 691 657 for ( unsigned int i = 0; i < maxBucketsUsed; i += 1 ) { … … 696 662 697 663 #if defined( SPINLOCK ) 698 for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0 ; p = p->header.kind.real.next ) {664 for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0p; p = p->header.kind.real.next ) { 699 665 #else 700 for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0 ; p = p->header.kind.real.next.top ) {666 for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0p; p = p->header.kind.real.next.top ) { 701 667 #endif // SPINLOCK 702 668 total += size; … … 707 673 708 674 #ifdef __STATISTICS__ 709 __cfaabi_ dbg_bits_print_nolock("%7zu, %-7u ", size, N );710 if ( (i + 1) % 8 == 0 ) __cfaabi_ dbg_bits_print_nolock("\n" );675 __cfaabi_bits_print_nolock( STDERR_FILENO, "%7zu, %-7u ", size, N ); 676 if ( (i + 1) % 8 == 0 ) __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" ); 711 677 #endif // __STATISTICS__ 712 678 } // for 713 679 #ifdef __STATISTICS__ 714 __cfaabi_ dbg_bits_print_nolock("\ntotal free blocks:%zu\n", total );715 __cfaabi_ dbg_bits_release();680 __cfaabi_bits_print_nolock( STDERR_FILENO, "\ntotal free blocks:%zu\n", total ); 681 __cfaabi_bits_release(); 716 682 #endif // __STATISTICS__ 717 683 return (char *)heapEnd - (char *)heapBegin - total; 718 } // checkFree 684 } // prtFree 685 686 687 static void ?{}( HeapManager & manager ) with ( manager ) { 688 pageSize = sysconf( _SC_PAGESIZE ); 689 690 for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists 691 freeLists[i].blockSize = bucketSizes[i]; 692 } // for 693 694 #ifdef FASTLOOKUP 695 unsigned int idx = 0; 696 for ( unsigned int i = 0; i < LookupSizes; i += 1 ) { 697 if ( i > bucketSizes[idx] ) idx += 1; 698 lookup[i] = idx; 699 } // for 700 #endif // FASTLOOKUP 701 702 if ( setMmapStart( default_mmap_start() ) ) { 703 abort( "HeapManager : internal error, mmap start initialization failure." ); 704 } // if 705 heapExpand = default_heap_expansion(); 706 707 char * end = (char *)sbrk( 0 ); 708 sbrk( (char *)libCeiling( (long unsigned int)end, libAlign() ) - end ); // move start of heap to multiple of alignment 709 heapBegin = heapEnd = sbrk( 0 ); // get new start point 710 } // HeapManager 711 712 713 static void ^?{}( HeapManager & ) { 714 #ifdef __STATISTICS__ 715 // if ( traceHeapTerm() ) { 716 // printStats(); 717 // if ( prtfree() ) prtFree( heapManager, true ); 718 // } // if 719 #endif // __STATISTICS__ 720 } // ~HeapManager 721 722 723 static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) )); 724 void memory_startup( void ) { 725 #ifdef __CFA_DEBUG__ 726 if ( unlikely( heapBoot ) ) { // check for recursion during system boot 727 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT. 728 abort( "boot() : internal error, recursively invoked during system boot." ); 729 } // if 730 heapBoot = true; 731 #endif // __CFA_DEBUG__ 732 733 //assert( heapManager.heapBegin != 0 ); 734 //heapManager{}; 735 if ( heapManager.heapBegin == 0p ) heapManager{}; 736 } // memory_startup 737 738 static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) )); 739 void memory_shutdown( void ) { 740 ^heapManager{}; 741 } // memory_shutdown 719 742 720 743 721 744 static inline void * mallocNoStats( size_t size ) { // necessary for malloc statistics 722 745 //assert( heapManager.heapBegin != 0 ); 723 if ( unlikely( heapManager.heapBegin == 0 ) ) heapManager{}; // called before memory_startup ?724 void * a rea= doMalloc( size );725 if ( unlikely( a rea == 0) ) errno = ENOMEM; // POSIX726 return a rea;746 if ( unlikely( heapManager.heapBegin == 0p ) ) heapManager{}; // called before memory_startup ? 747 void * addr = doMalloc( size ); 748 if ( unlikely( addr == 0p ) ) errno = ENOMEM; // POSIX 749 return addr; 727 750 } // mallocNoStats 751 752 753 static inline void * callocNoStats( size_t noOfElems, size_t elemSize ) { 754 size_t size = noOfElems * elemSize; 755 char * addr = (char *)mallocNoStats( size ); 756 if ( unlikely( addr == 0p ) ) return 0p; 757 758 HeapManager.Storage.Header * header; 759 HeapManager.FreeHeader * freeElem; 760 size_t bsize, alignment; 761 bool mapped __attribute__(( unused )) = headers( "calloc", addr, header, freeElem, bsize, alignment ); 762 #ifndef __CFA_DEBUG__ 763 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 764 if ( ! mapped ) 765 #endif // __CFA_DEBUG__ 766 // Zero entire data space even when > than size => realloc without a new allocation and zero fill works. 767 // <-------00000000000000000000000000000000000000000000000000000> bsize (bucket size) 768 // `-header`-addr `-size 769 memset( addr, '\0', bsize - sizeof(HeapManager.Storage) ); // set to zeros 770 771 header->kind.real.blockSize |= 2; // mark as zero filled 772 return addr; 773 } // callocNoStats 728 774 729 775 … … 745 791 // subtract libAlign() because it is already the minimum alignment 746 792 // add sizeof(Storage) for fake header 747 // #comment TD : this is the only place that calls doMalloc without calling mallocNoStats, why ? 748 char * area = (char *)doMalloc( size + alignment - libAlign() + sizeof(HeapManager.Storage) ); 749 if ( unlikely( area == 0 ) ) return area; 793 char * addr = (char *)mallocNoStats( size + alignment - libAlign() + sizeof(HeapManager.Storage) ); 794 if ( unlikely( addr == 0p ) ) return addr; 750 795 751 796 // address in the block of the "next" alignment address 752 char * user = (char *)libCeiling( (uintptr_t)(a rea+ sizeof(HeapManager.Storage)), alignment );797 char * user = (char *)libCeiling( (uintptr_t)(addr + sizeof(HeapManager.Storage)), alignment ); 753 798 754 799 // address of header from malloc 755 HeapManager.Storage.Header * realHeader = headerAddr( a rea);800 HeapManager.Storage.Header * realHeader = headerAddr( addr ); 756 801 // address of fake header * before* the alignment location 757 802 HeapManager.Storage.Header * fakeHeader = headerAddr( user ); … … 763 808 return user; 764 809 } // memalignNoStats 810 811 812 static inline void * cmemalignNoStats( size_t alignment, size_t noOfElems, size_t elemSize ) { 813 size_t size = noOfElems * elemSize; 814 char * addr = (char *)memalignNoStats( alignment, size ); 815 if ( unlikely( addr == 0p ) ) return 0p; 816 HeapManager.Storage.Header * header; 817 HeapManager.FreeHeader * freeElem; 818 size_t bsize; 819 bool mapped __attribute__(( unused )) = headers( "cmemalign", addr, header, freeElem, bsize, alignment ); 820 #ifndef __CFA_DEBUG__ 821 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 822 if ( ! mapped ) 823 #endif // __CFA_DEBUG__ 824 memset( addr, '\0', dataStorage( bsize, addr, header ) ); // set to zeros 825 header->kind.real.blockSize |= 2; // mark as zero filled 826 827 return addr; 828 } // cmemalignNoStats 765 829 766 830 … … 776 840 extern "C" { 777 841 // The malloc() function allocates size bytes and returns a pointer to the allocated memory. The memory is not 778 // initialized. If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be842 // initialized. If size is 0, then malloc() returns either 0p, or a unique pointer value that can later be 779 843 // successfully passed to free(). 780 844 void * malloc( size_t size ) { … … 788 852 789 853 // The calloc() function allocates memory for an array of nmemb elements of size bytes each and returns a pointer to 790 // the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either NULL, or a854 // the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either 0p, or a 791 855 // unique pointer value that can later be successfully passed to free(). 792 856 void * calloc( size_t noOfElems, size_t elemSize ) { 793 size_t size = noOfElems * elemSize;794 857 #ifdef __STATISTICS__ 795 858 __atomic_add_fetch( &calloc_calls, 1, __ATOMIC_SEQ_CST ); 796 __atomic_add_fetch( &calloc_storage, size, __ATOMIC_SEQ_CST ); 797 #endif // __STATISTICS__ 798 799 char * area = (char *)mallocNoStats( size ); 800 if ( unlikely( area == 0 ) ) return 0; 859 __atomic_add_fetch( &calloc_storage, noOfElems * elemSize, __ATOMIC_SEQ_CST ); 860 #endif // __STATISTICS__ 861 862 return callocNoStats( noOfElems, elemSize ); 863 } // calloc 864 865 // The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be 866 // unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size 867 // is larger than the old size, the added memory will not be initialized. If ptr is 0p, then the call is 868 // equivalent to malloc(size), for all values of size; if size is equal to zero, and ptr is not 0p, then the call 869 // is equivalent to free(ptr). Unless ptr is 0p, it must have been returned by an earlier call to malloc(), 870 // calloc() or realloc(). If the area pointed to was moved, a free(ptr) is done. 871 void * realloc( void * oaddr, size_t size ) { 872 #ifdef __STATISTICS__ 873 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST ); 874 #endif // __STATISTICS__ 875 876 if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases 877 if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size ); 801 878 802 879 HeapManager.Storage.Header * header; 803 880 HeapManager.FreeHeader * freeElem; 804 size_t asize, alignment; 805 bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment ); 806 #ifndef __CFA_DEBUG__ 807 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 808 if ( ! mapped ) 809 #endif // __CFA_DEBUG__ 810 memset( area, '\0', asize - sizeof(HeapManager.Storage) ); // set to zeros 811 812 header->kind.real.blockSize |= 2; // mark as zero filled 813 return area; 814 } // calloc 815 816 // #comment TD : Document this function 817 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) { 818 size_t size = noOfElems * elemSize; 819 #ifdef __STATISTICS__ 820 __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST ); 821 __atomic_add_fetch( &cmemalign_storage, size, __ATOMIC_SEQ_CST ); 822 #endif // __STATISTICS__ 823 824 char * area = (char *)memalignNoStats( alignment, size ); 825 if ( unlikely( area == 0 ) ) return 0; 826 HeapManager.Storage.Header * header; 827 HeapManager.FreeHeader * freeElem; 828 size_t asize; 829 bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment ); 830 #ifndef __CFA_DEBUG__ 831 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 832 if ( ! mapped ) 833 #endif // __CFA_DEBUG__ 834 memset( area, '\0', asize - ( (char *)area - (char *)header ) ); // set to zeros 835 header->kind.real.blockSize |= 2; // mark as zero filled 836 837 return area; 838 } // cmemalign 839 840 // The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be 841 // unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size 842 // is larger than the old size, the added memory will not be initialized. If ptr is NULL, then the call is 843 // equivalent to malloc(size), for all values of size; if size is equal to zero, and ptr is not NULL, then the call 844 // is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to malloc(), 845 // calloc() or realloc(). If the area pointed to was moved, a free(ptr) is done. 846 void * realloc( void * addr, size_t size ) { 847 #ifdef __STATISTICS__ 848 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST ); 849 #endif // __STATISTICS__ 850 851 if ( unlikely( addr == 0 ) ) return mallocNoStats( size ); // special cases 852 if ( unlikely( size == 0 ) ) { free( addr ); return 0; } 853 854 HeapManager.Storage.Header * header; 855 HeapManager.FreeHeader * freeElem; 856 size_t asize, alignment = 0; 857 headers( "realloc", addr, header, freeElem, asize, alignment ); 858 859 size_t usize = asize - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block 860 if ( usize >= size ) { // already sufficient storage 881 size_t bsize, oalign = 0; 882 headers( "realloc", oaddr, header, freeElem, bsize, oalign ); 883 884 size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket 885 if ( size <= odsize && odsize <= size * 2 ) { // allow up to 50% wasted storage in smaller size 886 // Do not know size of original allocation => cannot do 0 fill for any additional space because do not know 887 // where to start filling, i.e., do not overwrite existing values in space. 888 // 861 889 // This case does not result in a new profiler entry because the previous one still exists and it must match with 862 890 // the free for this memory. Hence, this realloc does not appear in the profiler output. 863 return addr;891 return oaddr; 864 892 } // if 865 893 … … 868 896 #endif // __STATISTICS__ 869 897 870 void * area; 871 if ( unlikely( alignment != 0 ) ) { // previous request memalign? 872 area = memalign( alignment, size ); // create new aligned area 898 // change size and copy old content to new storage 899 900 void * naddr; 901 if ( unlikely( oalign != 0 ) ) { // previous request memalign? 902 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill 903 naddr = cmemalignNoStats( oalign, 1, size ); // create new aligned area 904 } else { 905 naddr = memalignNoStats( oalign, size ); // create new aligned area 906 } // if 873 907 } else { 874 area = mallocNoStats( size ); // create new area 908 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill 909 naddr = callocNoStats( 1, size ); // create new area 910 } else { 911 naddr = mallocNoStats( size ); // create new area 912 } // if 875 913 } // if 876 if ( unlikely( area == 0 ) ) return 0; 877 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill (calloc/cmemalign) ? 878 assert( (header->kind.real.blockSize & 1) == 0 ); 879 bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment ); 880 #ifndef __CFA_DEBUG__ 881 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. 882 if ( ! mapped ) 883 #endif // __CFA_DEBUG__ 884 memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part 885 header->kind.real.blockSize |= 2; // mark new request as zero fill 886 } // if 887 memcpy( area, addr, usize ); // copy bytes 888 free( addr ); 889 return area; 914 if ( unlikely( naddr == 0p ) ) return 0p; 915 916 headers( "realloc", naddr, header, freeElem, bsize, oalign ); 917 size_t ndsize = dataStorage( bsize, naddr, header ); // data storage avilable in bucket 918 // To preserve prior fill, the entire bucket must be copied versus the size. 919 memcpy( naddr, oaddr, MIN( odsize, ndsize ) ); // copy bytes 920 free( oaddr ); 921 return naddr; 890 922 } // realloc 891 923 … … 898 930 #endif // __STATISTICS__ 899 931 900 void * area = memalignNoStats( alignment, size ); 901 902 return area; 932 return memalignNoStats( alignment, size ); 903 933 } // memalign 934 935 936 // The cmemalign() function is the same as calloc() with memory alignment. 937 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) { 938 #ifdef __STATISTICS__ 939 __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST ); 940 __atomic_add_fetch( &cmemalign_storage, noOfElems * elemSize, __ATOMIC_SEQ_CST ); 941 #endif // __STATISTICS__ 942 943 return cmemalignNoStats( alignment, noOfElems, elemSize ); 944 } // cmemalign 904 945 905 946 // The function aligned_alloc() is the same as memalign(), except for the added restriction that size should be a … … 912 953 // The function posix_memalign() allocates size bytes and places the address of the allocated memory in *memptr. The 913 954 // address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of 914 // sizeof(void *). If size is 0, then posix_memalign() returns either NULL, or a unique pointer value that can later955 // sizeof(void *). If size is 0, then posix_memalign() returns either 0p, or a unique pointer value that can later 915 956 // be successfully passed to free(3). 916 957 int posix_memalign( void ** memptr, size_t alignment, size_t size ) { 917 958 if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) return EINVAL; // check alignment 918 959 * memptr = memalign( alignment, size ); 919 if ( unlikely( * memptr == 0 ) ) return ENOMEM;960 if ( unlikely( * memptr == 0p ) ) return ENOMEM; 920 961 return 0; 921 962 } // posix_memalign … … 930 971 // The free() function frees the memory space pointed to by ptr, which must have been returned by a previous call to 931 972 // malloc(), calloc() or realloc(). Otherwise, or if free(ptr) has already been called before, undefined behavior 932 // occurs. If ptr is NULL, no operation is performed.973 // occurs. If ptr is 0p, no operation is performed. 933 974 void free( void * addr ) { 934 975 #ifdef __STATISTICS__ … … 936 977 #endif // __STATISTICS__ 937 978 938 // #comment TD : To decrease nesting I would but the special case in the 939 // else instead, plus it reads more naturally to have the 940 // short / normal case instead 941 if ( unlikely( addr == 0 ) ) { // special case 942 #ifdef __CFA_DEBUG__ 943 if ( traceHeap() ) { 944 #define nullmsg "Free( 0x0 ) size:0\n" 945 // Do not debug print free( 0 ), as it can cause recursive entry from sprintf. 946 __cfaabi_dbg_bits_write( nullmsg, sizeof(nullmsg) - 1 ); 947 } // if 948 #endif // __CFA_DEBUG__ 979 if ( unlikely( addr == 0p ) ) { // special case 980 // #ifdef __CFA_DEBUG__ 981 // if ( traceHeap() ) { 982 // #define nullmsg "Free( 0x0 ) size:0\n" 983 // // Do not debug print free( 0p ), as it can cause recursive entry from sprintf. 984 // __cfaabi_dbg_write( nullmsg, sizeof(nullmsg) - 1 ); 985 // } // if 986 // #endif // __CFA_DEBUG__ 949 987 return; 950 988 } // exit … … 953 991 } // free 954 992 955 // The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see 956 // malloc(3)). The param argument specifies the parameter to be modified, and value specifies the new value for that 957 // parameter. 958 int mallopt( int option, int value ) { 959 choose( option ) { 960 case M_TOP_PAD: 961 if ( setHeapExpand( value ) ) fallthru default; 962 case M_MMAP_THRESHOLD: 963 if ( setMmapStart( value ) ) fallthru default; 964 default: 965 // #comment TD : 1 for unsopported feels wrong 966 return 1; // success, or unsupported 967 } // switch 968 return 0; // error 969 } // mallopt 970 971 // The malloc_trim() function attempts to release free memory at the top of the heap (by calling sbrk(2) with a 972 // suitable argument). 973 int malloc_trim( size_t ) { 974 return 0; // => impossible to release memory 975 } // malloc_trim 976 977 // The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to 978 // a block of memory allocated by malloc(3) or a related function. 979 size_t malloc_usable_size( void * addr ) { 980 if ( unlikely( addr == 0 ) ) return 0; // null allocation has 0 size 981 982 HeapManager.Storage.Header * header; 983 HeapManager.FreeHeader * freeElem; 984 size_t size, alignment; 985 986 headers( "malloc_usable_size", addr, header, freeElem, size, alignment ); 987 size_t usize = size - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block 988 return usize; 989 } // malloc_usable_size 990 991 992 // The malloc_alignment() function returns the alignment of the allocation. 993 994 // The malloc_alignment() function returns the alignment of the allocation. 993 995 size_t malloc_alignment( void * addr ) { 994 if ( unlikely( addr == 0 ) ) return libAlign(); // minimum alignment996 if ( unlikely( addr == 0p ) ) return libAlign(); // minimum alignment 995 997 HeapManager.Storage.Header * header = headerAddr( addr ); 996 998 if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ? … … 1002 1004 1003 1005 1004 1006 // The malloc_zero_fill() function returns true if the allocation is zero filled, i.e., initially allocated by calloc(). 1005 1007 bool malloc_zero_fill( void * addr ) { 1006 if ( unlikely( addr == 0 ) ) return false; // null allocation is not zero fill1008 if ( unlikely( addr == 0p ) ) return false; // null allocation is not zero fill 1007 1009 HeapManager.Storage.Header * header = headerAddr( addr ); 1008 1010 if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ? … … 1013 1015 1014 1016 1015 // The malloc_stats() function prints (on default standard error) statistics about memory allocated by malloc(3) and 1016 // related functions. 1017 // The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to 1018 // a block of memory allocated by malloc(3) or a related function. 1019 size_t malloc_usable_size( void * addr ) { 1020 if ( unlikely( addr == 0p ) ) return 0; // null allocation has 0 size 1021 HeapManager.Storage.Header * header; 1022 HeapManager.FreeHeader * freeElem; 1023 size_t bsize, alignment; 1024 1025 headers( "malloc_usable_size", addr, header, freeElem, bsize, alignment ); 1026 return dataStorage( bsize, addr, header ); // data storage in bucket 1027 } // malloc_usable_size 1028 1029 1030 // The malloc_stats() function prints (on default standard error) statistics about memory allocated by malloc(3) and 1031 // related functions. 1017 1032 void malloc_stats( void ) { 1018 1033 #ifdef __STATISTICS__ 1019 1034 printStats(); 1020 if ( checkFree() ) checkFree( heapManager );1035 if ( prtFree() ) prtFree( heapManager ); 1021 1036 #endif // __STATISTICS__ 1022 1037 } // malloc_stats 1023 1038 1024 1039 // The malloc_stats_fd() function changes the file descripter where malloc_stats() writes the statistics. 1025 int malloc_stats_fd( int fd ) {1040 int malloc_stats_fd( int fd __attribute__(( unused )) ) { 1026 1041 #ifdef __STATISTICS__ 1027 1042 int temp = statfd; … … 1033 1048 } // malloc_stats_fd 1034 1049 1050 1051 // The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see 1052 // malloc(3)). The param argument specifies the parameter to be modified, and value specifies the new value for that 1053 // parameter. 1054 int mallopt( int option, int value ) { 1055 choose( option ) { 1056 case M_TOP_PAD: 1057 if ( setHeapExpand( value ) ) return 1; 1058 case M_MMAP_THRESHOLD: 1059 if ( setMmapStart( value ) ) return 1; 1060 } // switch 1061 return 0; // error, unsupported 1062 } // mallopt 1063 1064 // The malloc_trim() function attempts to release free memory at the top of the heap (by calling sbrk(2) with a 1065 // suitable argument). 1066 int malloc_trim( size_t ) { 1067 return 0; // => impossible to release memory 1068 } // malloc_trim 1069 1070 1035 1071 // The malloc_info() function exports an XML string that describes the current state of the memory-allocation 1036 1072 // implementation in the caller. The string is printed on the file stream stream. The exported string includes 1037 1073 // information about all arenas (see malloc(3)). 1038 1074 int malloc_info( int options, FILE * stream ) { 1075 if ( options != 0 ) { errno = EINVAL; return -1; } 1039 1076 return printStatsXML( stream ); 1040 1077 } // malloc_info … … 1046 1083 // structure is returned as the function result. (It is the caller's responsibility to free(3) this memory.) 1047 1084 void * malloc_get_state( void ) { 1048 return 0 ; // unsupported1085 return 0p; // unsupported 1049 1086 } // malloc_get_state 1050 1087 … … 1058 1095 1059 1096 1097 // Must have CFA linkage to overload with C linkage realloc. 1098 void * realloc( void * oaddr, size_t nalign, size_t size ) { 1099 #ifdef __STATISTICS__ 1100 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST ); 1101 #endif // __STATISTICS__ 1102 1103 if ( unlikely( size == 0 ) ) { free( oaddr ); return 0p; } // special cases 1104 if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size ); 1105 1106 if ( unlikely( nalign == 0 ) ) nalign = libAlign(); // reset alignment to minimum 1107 #ifdef __CFA_DEBUG__ 1108 else 1109 checkAlign( nalign ); // check alignment 1110 #endif // __CFA_DEBUG__ 1111 1112 HeapManager.Storage.Header * header; 1113 HeapManager.FreeHeader * freeElem; 1114 size_t bsize, oalign = 0; 1115 headers( "realloc", oaddr, header, freeElem, bsize, oalign ); 1116 size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket 1117 1118 if ( oalign != 0 && (uintptr_t)oaddr % nalign == 0 ) { // has alignment and just happens to work out 1119 headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same) 1120 return realloc( oaddr, size ); 1121 } // if 1122 1123 #ifdef __STATISTICS__ 1124 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST ); 1125 #endif // __STATISTICS__ 1126 1127 // change size and copy old content to new storage 1128 1129 void * naddr; 1130 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill 1131 naddr = cmemalignNoStats( nalign, 1, size ); // create new aligned area 1132 } else { 1133 naddr = memalignNoStats( nalign, size ); // create new aligned area 1134 } // if 1135 1136 headers( "realloc", naddr, header, freeElem, bsize, oalign ); 1137 size_t ndsize = dataStorage( bsize, naddr, header ); // data storage avilable in bucket 1138 // To preserve prior fill, the entire bucket must be copied versus the size. 1139 memcpy( naddr, oaddr, MIN( odsize, ndsize ) ); // copy bytes 1140 free( oaddr ); 1141 return naddr; 1142 } // realloc 1143 1144 1060 1145 // Local Variables: // 1061 1146 // tab-width: 4 // -
libcfa/src/interpose.cfa
r7768b8d r30763fd 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jul 14 22:57:16201913 // Update Count : 11 612 // Last Modified On : Thu Nov 21 16:47:02 2019 13 // Update Count : 118 14 14 // 15 15 … … 163 163 abort_lastframe = kernel_abort_lastframe(); 164 164 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid) 165 __cfaabi_dbg_ bits_write( abort_text, len );165 __cfaabi_dbg_write( abort_text, len ); 166 166 167 167 if ( fmt ) { … … 171 171 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 172 172 va_end( args ); 173 __cfaabi_dbg_ bits_write( abort_text, len );173 __cfaabi_dbg_write( abort_text, len ); 174 174 175 175 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 176 __cfaabi_dbg_ bits_write( "\n", 1 );176 __cfaabi_dbg_write( "\n", 1 ); 177 177 } 178 178 } … … 194 194 // find executable name 195 195 *index( messages[0], '(' ) = '\0'; 196 __cfaabi_ dbg_bits_print_nolock("Stack back trace for: %s\n", messages[0]);196 __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]); 197 197 198 198 for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) { … … 200 200 201 201 for ( char * p = messages[i]; *p; ++p ) { 202 //__cfaabi_ dbg_bits_print_nolock( "X %s\n", p);202 //__cfaabi_bits_print_nolock( "X %s\n", p); 203 203 // find parantheses and +offset 204 204 if ( *p == '(' ) { … … 220 220 *offset_end++ = '\0'; 221 221 222 __cfaabi_ dbg_bits_print_nolock("(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);222 __cfaabi_bits_print_nolock( STDERR_FILENO, "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end); 223 223 } else { // otherwise, print the whole line 224 __cfaabi_ dbg_bits_print_nolock("(%i) %s\n", frameNo, messages[i] );224 __cfaabi_bits_print_nolock( STDERR_FILENO, "(%i) %s\n", frameNo, messages[i] ); 225 225 } 226 226 } -
libcfa/src/stdlib.cfa
r7768b8d r30763fd 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 22 08:57:52201913 // Update Count : 4 7812 // Last Modified On : Wed Nov 20 17:22:47 2019 13 // Update Count : 485 14 14 // 15 15 … … 30 30 T * alloc_set( T ptr[], size_t dim, char fill ) { // realloc array with fill 31 31 size_t olen = malloc_usable_size( ptr ); // current allocation 32 char * nptr = (char*)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc32 void * nptr = (void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc 33 33 size_t nlen = malloc_usable_size( nptr ); // new allocation 34 34 if ( nlen > olen ) { // larger ? 35 memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage35 memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage 36 36 } // if 37 37 return (T *)nptr; 38 38 } // alloc_set 39 39 40 T * alloc_align( T ptr[], size_t align ) { // aligned realloc array41 char * nptr;42 size_t alignment = malloc_alignment( ptr );43 if ( align != alignment && (uintptr_t)ptr % align != 0 ) {44 size_t olen = malloc_usable_size( ptr ); // current allocation45 nptr = (char *)memalign( align, olen );46 size_t nlen = malloc_usable_size( nptr ); // new allocation47 size_t lnth = olen < nlen ? olen : nlen; // min48 memcpy( nptr, ptr, lnth ); // initialize storage49 free( ptr );50 } else {51 nptr = (char *)ptr;52 } // if53 return (T *)nptr;54 } // alloc_align55 56 T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array57 char * nptr;58 size_t alignment = malloc_alignment( ptr );59 if ( align != alignment ) {60 size_t olen = malloc_usable_size( ptr ); // current allocation61 nptr = (char *)memalign( align, dim * sizeof(T) );62 size_t nlen = malloc_usable_size( nptr ); // new allocation63 size_t lnth = olen < nlen ? olen : nlen; // min64 memcpy( nptr, ptr, lnth ); // initialize storage65 free( ptr );66 } else {67 nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc68 } // if69 return (T *)nptr;70 } // alloc_align71 72 40 T * alloc_align_set( T ptr[], size_t align, char fill ) { // aligned realloc with fill 73 41 size_t olen = malloc_usable_size( ptr ); // current allocation 74 char * nptr = alloc_align( ptr, align ); 42 void * nptr = (void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc 43 // char * nptr = alloc_align( ptr, align ); 75 44 size_t nlen = malloc_usable_size( nptr ); // new allocation 76 45 if ( nlen > olen ) { // larger ? 77 memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage46 memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage 78 47 } // if 79 48 return (T *)nptr; -
libcfa/src/stdlib.hfa
r7768b8d r30763fd 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Oct 20 22:57:33201913 // Update Count : 39 012 // Last Modified On : Fri Nov 22 15:13:14 2019 13 // Update Count : 399 14 14 // 15 15 … … 28 28 } // extern "C" 29 29 30 void * realloc( void * oaddr, size_t nalign, size_t size ); // CFA heap 31 30 32 //--------------------------------------- 31 33 … … 50 52 } // calloc 51 53 52 T * realloc( T * ptr, size_t size ) { 53 if ( unlikely( ptr == 0 ) ) return malloc(); 54 T * realloc( T * ptr, size_t size ) { // CFA realloc, eliminate return-type cast 54 55 return (T *)(void *)realloc( (void *)ptr, size ); // C realloc 55 56 } // realloc … … 59 60 } // memalign 60 61 62 T * cmemalign( size_t align, size_t dim ) { 63 return (T *)cmemalign( align, dim, sizeof(T) ); // CFA cmemalign 64 } // cmemalign 65 61 66 T * aligned_alloc( size_t align ) { 62 67 return (T *)aligned_alloc( align, sizeof(T) ); // C aligned_alloc … … 79 84 80 85 T * alloc( T ptr[], size_t dim ) { // realloc 81 return realloc( ptr, dim * sizeof(T) );86 return (T *)(void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc 82 87 } // alloc 83 88 … … 118 123 } // alloc_align 119 124 125 T * alloc_align( T ptr[], size_t align ) { // aligned realloc array 126 return (T *)(void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc 127 } // alloc_align 128 129 T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array 130 return (T *)(void *)realloc( (void *)ptr, align, dim * sizeof(T) ); // CFA realloc 131 } // alloc_align 132 120 133 T * alloc_align_set( size_t align, char fill ) { 121 134 return (T *)memset( (T *)alloc_align( align ), (int)fill, sizeof(T) ); // initialize with fill value … … 142 155 143 156 forall( dtype T | sized(T) ) { 144 T * alloc_align( T ptr[], size_t align ); // realign145 T * alloc_align( T ptr[], size_t align, size_t dim ); // aligned realloc array146 157 T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); // aligned realloc array with fill 147 158 } // distribution
Note: See TracChangeset
for help on using the changeset viewer.