Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
Loading...
Searching...
No Matches
arax_assert.c
Go to the documentation of this file.
1#include "arax_assert.h"
2#include "core/arax_ptr.h"
3#include "core/arax_object.h"
4#include <stdio.h>
5#include <string.h>
6#include <stdlib.h>
7#include <execinfo.h>
8#include "system.h"
9
10#define ARAX_FILE_PREFIX_LEN (strlen(__FILE__) - 23)
11// GCOV_EXCL_START
12void _arax_assert(int fail, const char *expr, const char *file, int line)
13{
14 if (fail) {
15 fprintf(stderr, "%s <<\n\narax_assert(%s) @ %s:%d\n\n", system_backtrace(1), expr, file + ARAX_FILE_PREFIX_LEN,
16 line);
17 abort();
18 }
19}
20
21void _arax_assert_obj(void *obj, int type)
22{
23 arax_assert(obj && !"Object was null");
24 arax_assert(arax_ptr_valid(obj) && !"Object was not valid ptr");
25 arax_assert(arax_ptr_valid(obj) && !"Object was not valid ptr");
26 arax_object_s *vo = obj;
27
28 arax_assert((vo->type == type) && !"Object type was not the expected");
29}
30
31// GCOV_EXCL_STOP
#define arax_assert(EXPR)
Definition arax_assert.h:7
int arax_ptr_valid(const void *ptr)
Definition arax_ptr.c:4
const char * system_backtrace(unsigned int skip)
Definition system.c:154
#define ARAX_FILE_PREFIX_LEN
Definition arax_assert.c:10
void _arax_assert_obj(void *obj, int type)
Definition arax_assert.c:21
void _arax_assert(int fail, const char *expr, const char *file, int line)
Definition arax_assert.c:12
arax_object_type_e type
Definition arax_object.h:45