mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
af645fcbec
- Add Lua backtraces to redbean! - Wipe serving keys after redbean forks - Audit redbean to remove free via exit - Log SSL client ciphersuite preferences - Increase ASAN malloc() backtrace depth - Make GetSslRoots() behave as a singleton - Move leaks.c from LIBC_TESTLIB to LIBC_LOG - Add undocumented %n to printf() for newlines - Fix redbean memory leak reindexing inode change - Fix redbean memory leak with Fetch() DNS object - Restore original environ after __cxa_finalize() - Make backtrace always work after __cxa_finalize() - Introduce COUNTEXPR() diagnostic / benchmark tool - Fix a few more instances of errno being clobbered - Consolidate the ANSI color disabling internal APIs
58 lines
2.7 KiB
C
58 lines
2.7 KiB
C
#ifndef COSMOPOLITAN_LIBC_LOG_COUNTBRANCH_H_
|
|
#define COSMOPOLITAN_LIBC_LOG_COUNTBRANCH_H_
|
|
#include "libc/macros.internal.h"
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
|
|
#define COUNTBRANCH(x) COUNTBRANCH_(x, #x, STRINGIFY(__FILE__), __LINE__)
|
|
#define COUNTBRANCH_(x, xs, file, line) \
|
|
COUNTBRANCH__(x, STRINGIFY(xs), STRINGIFY(xs), file, line)
|
|
#define COUNTBRANCH__(x, xs, xss, file, line) \
|
|
({ \
|
|
bool Cond; \
|
|
struct countbranch *Info; \
|
|
asm(".section .rodata.str1.1,\"aMS\",@progbits,1\n\t" \
|
|
".align\t1\n" \
|
|
"31338:\t" \
|
|
".asciz\t" xs "\n" \
|
|
"31339:\t" \
|
|
".asciz\t" xss "\n" \
|
|
"31340:\t" \
|
|
".asciz\t" file "\n\t" \
|
|
".previous\n\t" \
|
|
".section .yoink\n\t" \
|
|
"nopl\tcountbranch_data(%%rip)\n\t" \
|
|
".previous\n\t" \
|
|
".section .sort.data.countbranch.2,\"a\",@progbits\n\t" \
|
|
".align\t8\n31337:\t" \
|
|
".quad\t0\n\t" \
|
|
".quad\t0\n\t" \
|
|
".quad\t31338b\n\t" \
|
|
".quad\t31339b\n\t" \
|
|
".quad\t31340b\n\t" \
|
|
".quad\t" #line "\n\t" \
|
|
".previous\n\t" \
|
|
"lea\t31337b(%%rip),%0" \
|
|
: "=r"(Info)); \
|
|
Cond = (x); \
|
|
++Info->total; \
|
|
if (Cond) ++Info->taken; \
|
|
Cond; \
|
|
})
|
|
|
|
struct countbranch {
|
|
long total;
|
|
long taken;
|
|
const char *code;
|
|
const char *xcode;
|
|
const char *file;
|
|
long line;
|
|
};
|
|
|
|
extern struct countbranch countbranch_data[];
|
|
|
|
void countbranch_report(void);
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_LOG_COUNTBRANCH_H_ */
|