History

Update bcheck for recent atomic change

The functions fetch_and_add_arm, fetch_and_add_arm64 and fetch_and_add_riscv64 where removed with atomic change. Replace the code in bcheck.c with call to atomic_fetch_add.

herman ten brugge committed 1 year ago

Commit 32b59771 parent 7f13f241 file · +3 −24Browse files

Unified · Split

lib/bcheck.c+3−24
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include <stdarg.h>
2323 #include <string.h>
2424 #include <setjmp.h>
25+#include <stdatomic.h>
2526
2627 #if !defined(__FreeBSD__) \
2728 && !defined(__FreeBSD_kernel__) \
@@ -483,35 +484,13 @@ static void bound_not_found_warning(const char *file, const char *function, · 455 unmodified lines
483484 dprintf(stderr, "%s%s, %s(): Not found %p\n", exec, file, function, ptr);
484485 }
485486
486−static void fetch_and_add(int* variable, int value)
487−{
488−#if defined __i386__ || defined __x86_64__
489− __asm__ volatile("lock; addl %0, %1"
490− : "+r" (value), "+m" (*variable) // input+output
491− : // No input-only
492− : "memory"
493− );
494−#elif defined __arm__
495− extern void fetch_and_add_arm(int* variable, int value);
496− fetch_and_add_arm(variable, value);
497−#elif defined __aarch64__
498− extern void fetch_and_add_arm64(int* variable, int value);
499− fetch_and_add_arm64(variable, value);
500−#elif defined __riscv
501− extern void fetch_and_add_riscv64(int* variable, int value);
502− fetch_and_add_riscv64(variable, value);
503−#else
504− *variable += value;
505−#endif
506−}
507−
508487 /* enable/disable checking. This can be used in signal handlers. */
509488 void __bounds_checking (int no_check)
510489 {
511490 #if HAVE_TLS_FUNC || HAVE_TLS_VAR
512491 NO_CHECKING_SET(NO_CHECKING_GET() + no_check);
513492 #else
514− fetch_and_add (&no_checking, no_check);
493+ atomic_fetch_add (&no_checking, no_check);
515494 #endif
516495 }
517496
@@ -528,7 +507,7 @@ void __bound_checking_unlock(void) · 10 unmodified lines
528507 /* enable/disable checking. This can be used in signal handlers. */
529508 void __bound_never_fatal (int neverfatal)
530509 {
531− fetch_and_add (&never_fatal, neverfatal);
510+ atomic_fetch_add (&never_fatal, neverfatal);
532511 }
533512
534513 /* return '(p + offset)' for pointer arithmetic (a pointer can reach

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t