Loading...
Searching...
No Matches
debug.h
Go to the documentation of this file.
1#pragma once
2
12
13#include <stdio.h>
14#include <inttypes.h>
15#include <stdlib.h>
16
17#include <nut/modular_math.h>
18
20NUT_ATTR_ACCESS(read_write, 1)
21static inline void cleanup_free(void *_p){
22 free(*(void**)_p);
23 *(void**)_p = NULL;
24}
25
27NUT_ATTR_ACCESS(read_only, 1)
28NUT_ATTR_ACCESS(none, 2)
29static inline void check_alloc(const char *restrict what, const void *restrict buf){
30 if(!buf){
31 fprintf(stderr, "\e[1;31mAllocation failed for %s!\e[0m\n", what);
32 exit(0);
33 }
34}
35
37NUT_ATTR_ACCESS(read_only, 1)
38static inline void print_summary(const char *what, uint64_t correct, uint64_t total){
39 fprintf(stderr, "%s (found %s for %"PRIu64"/%"PRIu64" numbers correctly)\e[0m\n", correct == total ? "\e[1;32mPASSED" : "\e[1;31mFAILED", what, correct, total);
40}
41
#define NUT_ATTR_ACCESS(...)
Wrapper for gcc's access function annotation - no clang equivalent, and currently disabled because it...
#define NUT_ATTR_ARTIFICIAL
Wrapper for gnu::artificial attr - hint that the function should be ignored in debuggers.
#define NUT_ATTR_NONNULL(...)
Wrapper for gnu::nonnull attr.