Implemented assert()
This commit is contained in:
8
photon/libc/include/assert.h
Normal file
8
photon/libc/include/assert.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef PHOTON_ASSERT_H_
|
||||||
|
#define PHOTON_ASSERT_H_
|
||||||
|
|
||||||
|
#define assert(x) if (!(x)) { __assert_fail(#x, __FUNCTION__, __FILE__, __LINE__); }
|
||||||
|
|
||||||
|
extern void _Noreturn __assert_fail(const char *, const char *, const char *, int);
|
||||||
|
|
||||||
|
#endif
|
||||||
8
photon/libc/stdlib/assert.c
Normal file
8
photon/libc/stdlib/assert.c
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern void _Noreturn __assert_fail(const char *exp, const char *func, const char *file, int line)
|
||||||
|
{
|
||||||
|
printf("Assertion failed: (%s), function %s, file %s, line %d\n", exp, func, file, line);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user