1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
|
/* SPDX-License-Identifier: BSL-1.0 */
/* Copyright (c) 2017 Arm Limited. All rights reserved.
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to do
so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer, must
be included in all copies of the Software, in whole or in part, and all
derivative works of the Software, unless such copies or derivative works are
solely in the form of machine-executable object code generated by a source
language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR
ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. */
#ifdef __HAVE_LOAD_NO_SPECULATE
#define load_no_speculate(__ptr, __low, __high) \
(__extension__ ({ \
__typeof__ ((__ptr)) __ptr_once = (__ptr); \
__builtin_load_no_speculate (__ptr_once, __low, __high, \
0, __ptr_once); \
}))
#define load_no_speculate_fail(__ptr, __low, __high, __failval) \
(__extension__ ({ \
__typeof__ ((__ptr)) __ptr_once = (__ptr); \
__builtin_load_no_speculate (__ptr_once, __low, __high, \
__failval, __ptr_once); \
}))
#define load_no_speculate_cmp(__ptr, __low, __high, __failval, __cmpptr) \
(__builtin_load_no_speculate (__ptr, __low, __high, __failval, __cmpptr))
#else
#ifdef __GNUC__
#define __UNUSED __attribute__((unused))
#else
#define __UNUSED
#endif
#ifdef __aarch64__
#define __load_no_speculate1(__ptr, __low, __high, __failval, \
__cmpptr, __w, __sz) \
(__extension__ ({ \
__typeof__ (0 + (*(__ptr))) __nln_val; \
/* This typecasting is required to ensure correct handling of upper \
bits of failval, to ensure a clean return from the CSEL below. */ \
__typeof__(*(__ptr)) __fv \
= (__typeof__(*(__ptr)))(unsigned long long) (__failval); \
/* If __high is explicitly NULL, we must not emit the \
upper-bound comparison. We need to cast __high to an \
unsigned long long before handing it to __builtin_constant_p to \
ensure that clang/llvm correctly detects NULL as a constant if it \
is defined as (void*) 0. */ \
if (__builtin_constant_p ((unsigned long long)__high) \
&& __high == ((void *)0)) \
{ \
__asm__ volatile ( \
"cmp\t%[__c], %[__l]\n\t" \
"bcc\t.ns%=\n\t" \
"ldr" __sz "\t%" __w "[__v], %[__p]\n" \
".ns%=:\n\t" \
"csel\t%" __w "[__v], %" __w "[__v], %" __w "[__f], cs\n\t" \
"hint\t#0x14 // CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&r" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
/* The memory location from which we will load. */ \
[__p] "m" (*(__ptr)), \
/* The value to return if the condition check fails. */ \
[__f] "rZ" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
else \
{ \
__asm__ volatile ( \
"cmp\t%[__c], %[__l]\n\t" \
"ccmp\t%[__c], %[__h], 2, cs\n\t" \
"bcs\t.ns%=\n\t" \
"ldr" __sz "\t%" __w "[__v], %[__p]\n" \
".ns%=:\n\t" \
"csel\t%" __w "[__v], %" __w "[__v], %" __w "[__f], cc\n\t" \
"hint\t#0x14 // CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&r" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
[__h] "r" (__high), \
/* The memory location from which we will load. */ \
[__p] "m" (*(__ptr)), \
/* The value to return if the condition check fails. */ \
[__f] "rZ" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
(__typeof__ (*(__ptr))) __nln_val; \
}))
#define __load_no_speculate(__ptr, __low, __high, __failval, __cmpptr) \
(__extension__ ({ \
__typeof__ (0 + *(__ptr)) __nl_val; \
\
switch (sizeof(*(__ptr))) { \
case 1: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "w", "b"); \
break; \
case 2: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "w", "h"); \
break; \
case 4: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "w", ""); \
break; \
case 8: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "x", ""); \
break; \
default: \
{ \
char __static_assert_no_speculate_load_size_too_big \
[sizeof (__nl_val) > 8 ? -1 : 1] __UNUSED; \
break; \
} \
} \
\
(__typeof__ (*(__ptr))) __nl_val; \
}))
#define load_no_speculate(__ptr, __low, __high) \
(__extension__ ({ \
__typeof__ ((__ptr)) __ptr_once = (__ptr); \
__load_no_speculate (__ptr_once, __low, __high, 0, __ptr_once); \
}))
#define load_no_speculate_fail(__ptr, __low, __high, __failval) \
(__extension__ ({ \
__typeof__ ((__ptr)) __ptr_once = (__ptr); \
__load_no_speculate (__ptr_once, __low, __high, \
__failval, __ptr_once); \
}))
#define load_no_speculate_cmp(__ptr, __low, __high, __failval, __cmpptr) \
(__load_no_speculate (__ptr, __low, __high, __failval, __cmpptr))
/* AArch32 support for ARM and Thumb-2. Thumb-1 is not supported. */
#elif defined (__ARM_32BIT_STATE) && (defined (__thumb2__) || !defined (__thumb__))
#ifdef __thumb2__
/* Thumb2 case. */
#define __load_no_speculate1(__ptr, __low, __high, __failval, \
__cmpptr, __sz) \
(__extension__ ({ \
__typeof__ (0 + *(__ptr)) __nln_val; \
__typeof__(*(__ptr)) __fv \
= (__typeof__(*(__ptr)))(unsigned long) (__failval); \
/* If __high is explicitly NULL, we must not emit the \
upper-bound comparison. We need to cast __high to an \
unsigned long before handing it to __builtin_constant_p to \
ensure that clang/llvm correctly detects NULL as a constant if it \
is defined as (void*) 0. */ \
if (__builtin_constant_p ((unsigned long)__high) \
&& __high == ((void *)0)) \
{ \
__asm__ volatile ( \
".syntax unified\n\t" \
"cmp\t%[__c], %[__l]\n\t" \
"bcc\t.ns%=\n\t" \
"ldr" __sz "\t%[__v], %[__p]\n" \
".ns%=:\n\t" \
"it\tcc\n\t" \
"movcc\t%[__v], %[__f]\n\t" \
".inst.n 0xf3af\t@ CSDB\n\t" \
".inst.n 0x8014\t@ CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&l" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
/* The memory location from which we will load. */ \
[__p] "m" (*(__ptr)), \
/* The value to return if the condition check fails. */ \
[__f] "r" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
else \
{ \
__asm__ volatile ( \
".syntax unified\n\t" \
"cmp\t%[__c], %[__l]\n\t" \
"it\tcs\n\t" \
"cmpcs\t%[__h], %[__c]\n\t" \
"bls\t.ns%=\n\t" \
"ldr" __sz "\t%[__v], %[__p]\n" \
".ns%=:\n\t" \
"it\tls\n\t" \
"movls\t%[__v], %[__f]\n\t" \
".inst.n 0xf3af\t@ CSDB\n\t" \
".inst.n 0x8014\t@ CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&l" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
[__h] "r" (__high), \
/* The memory location from which we will load. */ \
[__p] "m" (*(__ptr)), \
/* The value to return if the condition check fails. */ \
[__f] "r" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
(__typeof__ (*(__ptr))) __nln_val; \
})) \
\
/* Double-word version. */
#define __load_no_speculate2(__ptr, __low, __high, __failval, \
__cmpptr) \
(__extension__ ({ \
__typeof__ (0 + *(__ptr)) __nln_val; \
__typeof__(*(__ptr)) __fv \
= (__typeof__(*(__ptr)))(unsigned long) (__failval); \
/* If __high is explicitly NULL, we must not emit the \
upper-bound comparison. We need to cast __high to an \
unsigned long before handing it to __builtin_constant_p to \
ensure that clang/llvm correctly detects NULL as a constant if it \
is defined as (void*) 0. */ \
if (__builtin_constant_p ((unsigned long)__high) \
&& __high == ((void *)0)) \
{ \
__asm__ volatile ( \
".syntax unified\n\t" \
"cmp\t%[__c], %[__l]\n\t" \
"bcc\t.ns%=\n\t" \
"ldr\t%Q[__v], [%[__p]]\n\t" \
"ldr\t%R[__v], [%[__p], #4]\n" \
".ns%=:\n\t" \
"it\tcc\n\t" \
"movcc\t%Q[__v], %Q[__f]\n\t" \
"it\tcc\n\t" \
"movcc\t%R[__v], %R[__f]\n\t" \
".inst.n 0xf3af\t@ CSDB\n\t" \
".inst.n 0x8014\t@ CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&l" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
/* The memory location from which we will load. */ \
[__p] "r" (__ptr), \
/* The value to return if the condition check fails. */ \
[__f] "r" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
else \
{ \
__asm__ volatile ( \
".syntax unified\n\t" \
"cmp\t%[__c], %[__l]\n\t" \
"it\tcs\n\t" \
"cmpcs\t%[__h], %[__c]\n\t" \
"bls\t.ns%=\n\t" \
"ldr\t%Q[__v], [%[__p]]\n\t" \
"ldr\t%R[__v], [%[__p], #4]\n" \
".ns%=:\n\t" \
"it\tls\n\t" \
"movls\t%Q[__v], %Q[__f]\n\t" \
"it\tls\n\t" \
"movls\t%R[__v], %R[__f]\n\t" \
".inst.n 0xf3af\t@ CSDB\n\t" \
".inst.n 0x8014\t@ CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&l" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
[__h] "r" (__high), \
/* The memory location from which we will load. */ \
[__p] "r" (__ptr), \
/* The value to return if the condition check fails. */ \
[__f] "r" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
(__typeof__ (*(__ptr))) __nln_val; \
}))
#else
/* ARM case. */
#define __load_no_speculate1(__ptr, __low, __high, __failval, \
__cmpptr, __sz) \
(__extension__ ({ \
__typeof__ (0 + *(__ptr)) __nln_val; \
__typeof__(*(__ptr)) __fv \
= (__typeof__(*(__ptr)))(unsigned long) (__failval); \
/* If __high is explicitly NULL, we must not emit the \
upper-bound comparison. We need to cast __high to an \
unsigned long before handing it to __builtin_constant_p to \
ensure that clang/llvm correctly detects NULL as a constant if it \
is defined as (void*) 0. */ \
if (__builtin_constant_p ((unsigned long)__high) \
&& __high == ((void *)0)) \
{ \
__asm__ volatile ( \
".syntax unified\n\t" \
"cmp\t%[__c], %[__l]\n\t" \
"ldr" __sz "cs\t%[__v], %[__p]\n\t" \
"movcc\t%[__v], %[__f]\n\t" \
".inst 0xe320f014\t@ CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&r" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
/* The memory location from which we will load. */ \
[__p] "m" (*(__ptr)), \
/* The value to return if the condition check fails. */ \
[__f] "rKI" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
else \
{ \
__asm__ volatile ( \
".syntax unified\n\t" \
"cmp\t%[__c], %[__l]\n\t" \
"cmpcs\t%[__h], %[__c]\n\t" \
"ldr" __sz "hi\t%[__v], %[__p]\n\t" \
"movls\t%[__v], %[__f]\n\t" \
".inst 0xe320f014\t@ CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&r" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
[__h] "r" (__high), \
/* The memory location from which we will load. */ \
[__p] "m" (*(__ptr)), \
/* The value to return if the condition check fails. */ \
[__f] "rKI" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
(__typeof__ (*(__ptr))) __nln_val; \
}))
/* Double-word version. */
#define __load_no_speculate2(__ptr, __low, __high, __failval, \
__cmpptr) \
(__extension__ ({ \
__typeof__ (0 + *(__ptr)) __nln_val; \
__typeof__(*(__ptr)) __fv \
= (__typeof__(*(__ptr)))(unsigned long) (__failval); \
/* If __high is explicitly NULL, we must not emit the \
upper-bound comparison. We need to cast __high to an \
unsigned long before handing it to __builtin_constant_p to \
ensure that clang/llvm correctly detects NULL as a constant if it \
is defined as (void*) 0. */ \
if (__builtin_constant_p ((unsigned long)__high) \
&& __high == ((void *)0)) \
{ \
__asm__ volatile ( \
".syntax unified\n\t" \
"cmp\t%[__c], %[__l]\n\t" \
"ldrcs\t%Q[__v], [%[__p]]\n\t" \
"ldrcs\t%R[__v], [%[__p], #4]\n\t" \
"movcc\t%Q[__v], %Q[__f]\n\t" \
"movcc\t%R[__v], %R[__f]\n\t" \
".inst 0xe320f014\t@ CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&r" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
/* The memory location from which we will load. */ \
[__p] "r" (__ptr), \
/* The value to return if the condition check fails. */ \
[__f] "r" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
else \
{ \
__asm__ volatile ( \
".syntax unified\n\t" \
"cmp\t%[__c], %[__l]\n\t" \
"cmpcs\t%[__h], %[__c]\n\t" \
"ldrhi\t%Q[__v], [%[__p]]\n\t" \
"ldrhi\t%R[__v], [%[__p], #4]\n\t" \
"movls\t%Q[__v], %Q[__f]\n\t" \
"movls\t%R[__v], %R[__f]\n\t" \
".inst 0xe320f014\t@ CSDB" \
/* The value we have loaded, or failval if the condition check \
fails. */ \
: [__v] "=&r" (__nln_val) \
/* The pointer we wish to use for comparisons, and the low and \
high bounds to use in that comparison. Note that this need \
not be the same as the pointer from which we will load. */ \
: [__c] "r" (__cmpptr), [__l] "r" (__low), \
[__h] "r" (__high), \
/* The memory location from which we will load. */ \
[__p] "r" (__ptr), \
/* The value to return if the condition check fails. */ \
[__f] "r" (__fv) \
/* We always clobber the condition codes. */ \
: "cc"); \
} \
(__typeof__ (*(__ptr))) __nln_val; \
}))
#endif // __thumb2__
/* Common to ARM and Thumb2. */
#define __load_no_speculate(__ptr, __low, __high, __failval, __cmpptr) \
(__extension__ ({ \
__typeof__ (0 + *(__ptr)) __nl_val; \
\
switch (sizeof(*(__ptr))) { \
case 1: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "b"); \
break; \
case 2: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "h"); \
break; \
case 4: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, ""); \
break; \
case 8: \
__nl_val = __load_no_speculate2 (__ptr, __low, __high, \
__failval, __cmpptr); \
break; \
default: \
{ \
char __static_assert_no_speculate_load_size_too_big \
[sizeof (__nl_val) > 8 ? -1 : 1] __UNUSED; \
break; \
} \
} \
\
(__typeof__ (*(__ptr))) __nl_val; \
}))
#define load_no_speculate(__ptr, __low, __high) \
(__extension__ ({ \
__typeof__ ((__ptr)) __ptr_once = (__ptr); \
__load_no_speculate (__ptr_once, __low, __high, 0, __ptr_once); \
}))
#define load_no_speculate_fail(__ptr, __low, __high, __failval) \
(__extension__ ({ \
__typeof__ ((__ptr)) __ptr_once = (__ptr); \
__load_no_speculate (__ptr_once, __low, __high, \
__failval, __ptr_once); \
}))
#define load_no_speculate_cmp(__ptr, __low, __high, __failval, __cmpptr) \
(__load_no_speculate (__ptr, __low, __high, __failval, __cmpptr))
#elif defined(RV32) || defined(RV64)
#define __load_no_speculate1(__ptr, __low, __high, __failval, __cmpptr, __sz) \
(__extension__ ({ \
__typeof__ (0 + (*(__ptr))) __nln_val; \
asm volatile ( \
"fence\trw,rw\n\t" \
"fence.i\n\t" \
"fence\tr,r\n\t" \
"l" __sz "\t%[__v], %[__p]\n" \
/* The value we have loaded. */ \
: [__v] "=&r" (__nln_val) \
: \
/* The memory location from which we will load. */ \
[__p] "m" (*(__ptr)) \
: ); \
(__typeof__ (*(__ptr))) __nln_val; \
}))
#define __load_no_speculate(__ptr, __low, __high, __failval, __cmpptr) \
(__extension__ ({ \
__typeof__ (0 + *(__ptr)) __nl_val; \
\
switch (sizeof(*(__ptr))) { \
case 1: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "b"); \
break; \
case 2: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "h"); \
break; \
case 4: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "w"); \
break; \
case 8: \
__nl_val = __load_no_speculate1 (__ptr, __low, __high, \
__failval, __cmpptr, "d"); \
break; \
default: \
{ \
char __static_assert_no_speculate_load_size_too_big \
[sizeof (__nl_val) > 8 ? -1 : 1] __UNUSED; \
break; \
} \
} \
\
(__typeof__ (*(__ptr))) __nl_val; \
}))
#define load_no_speculate(__ptr, __low, __high) \
(__extension__ ({ \
__typeof__ ((__ptr)) __ptr_once = (__ptr); \
__load_no_speculate (__ptr_once, __low, __high, 0, __ptr_once); \
}))
#define load_no_speculate_fail(__ptr, __low, __high, __failval) \
(__extension__ ({ \
__typeof__ ((__ptr)) __ptr_once = (__ptr); \
__load_no_speculate (__ptr_once, __low, __high, __failval, __ptr_once); \
}))
#define load_no_speculate_cmp(__ptr, __low, __high, __failval, __cmpptr) \
(__load_no_speculate (__ptr, __low, __high, __failval, __cmpptr))
#else
#error "No fallback provided for load_no_speculate"
#endif
#endif
|