mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
fa20edc44d
- Remove most __ASSEMBLER__ __LINKER__ ifdefs - Rename libc/intrin/bits.h to libc/serialize.h - Block pthread cancelation in fchmodat() polyfill - Remove `clang-format off` statements in third_party
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
|
|
/* ------------------------------- Hooks -------------------------------- */
|
|
|
|
/*
|
|
PREACTION should be defined to return 0 on success, and nonzero on
|
|
failure. If you are not using locking, you can redefine these to do
|
|
anything you like.
|
|
*/
|
|
|
|
#if USE_LOCKS
|
|
#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0)
|
|
#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); }
|
|
#else /* USE_LOCKS */
|
|
|
|
#ifndef PREACTION
|
|
#define PREACTION(M) (0)
|
|
#endif /* PREACTION */
|
|
|
|
#ifndef POSTACTION
|
|
#define POSTACTION(M)
|
|
#endif /* POSTACTION */
|
|
|
|
#endif /* USE_LOCKS */
|
|
|
|
/*
|
|
CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses.
|
|
USAGE_ERROR_ACTION is triggered on detected bad frees and
|
|
reallocs. The argument p is an address that might have triggered the
|
|
fault. It is ignored by the two predefined actions, but might be
|
|
useful in custom actions that try to help diagnose errors.
|
|
*/
|
|
|
|
#if PROCEED_ON_ERROR
|
|
|
|
/* A count of the number of corruption errors causing resets */
|
|
int malloc_corruption_error_count;
|
|
|
|
/* default corruption action */
|
|
static void reset_on_error(mstate m);
|
|
|
|
#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m)
|
|
#define USAGE_ERROR_ACTION(m, p)
|
|
|
|
#else /* PROCEED_ON_ERROR */
|
|
|
|
#ifndef CORRUPTION_ERROR_ACTION
|
|
#define CORRUPTION_ERROR_ACTION(m) ABORT
|
|
#endif /* CORRUPTION_ERROR_ACTION */
|
|
|
|
#ifndef USAGE_ERROR_ACTION
|
|
#define USAGE_ERROR_ACTION(m,p) ABORT
|
|
#endif /* USAGE_ERROR_ACTION */
|
|
|
|
#endif /* PROCEED_ON_ERROR */
|
|
|