moved assert to platform layer

This commit is contained in:
Martin Fouilleul 2023-04-18 18:36:06 +02:00
parent 794f47b141
commit ff4dddc0b7
7 changed files with 40 additions and 28 deletions

View File

@ -17,6 +17,7 @@
#include"stb_image.h"
#include"platform_log.h"
#include"platform_assert.h"
#include"graphics_internal.h"
typedef struct mg_glyph_map_entry

View File

@ -6,7 +6,7 @@
* @revision:
*
*****************************************************************/
#include"platform_assert.h"
#include"mp_app_internal.h"
mp_app __mpApp = {0};

View File

@ -0,0 +1,35 @@
/************************************************************//**
*
* @file: platform_assert.h
* @author: Martin Fouilleul
* @date: 18/04/2023
*
*****************************************************************/
#ifndef __PLATFORM_ASSERT_H_
#define __PLATFORM_ASSERT_H_
#include"platform.h"
//NOTE: assert macros
#ifndef NO_ASSERT
#ifdef PLATFORM_ORCA
extern int orca_assert(const char* file, const char* function, int line, const char* src, const char* msg);
#define _ASSERT_(x, msg) ((x) || orca_assert(__FILE__, __FUNCTION__, __LINE__, #x, msg))
#else
#include<assert.h>
#define _ASSERT_(x, msg) assert(x && msg)
#endif
#define ASSERT(x, ...) _ASSERT_(x, #__VA_ARGS__)
#ifdef DEBUG
#define DEBUG_ASSERT(x, ...) ASSERT(x, ##__VA_ARGS__ )
#else
#define DEBUG_ASSERT(x, ...)
#endif
#else
#define ASSERT(x, ...)
#define DEBUG_ASSERT(x, ...)
#endif
#endif //__PLATFORM_ASSERT_H_

View File

@ -7,6 +7,7 @@
*
*****************************************************************/
#include"platform.h"
#include"platform_assert.h"
#include"memory.h"
#include"hash.h"
#include"platform_clock.h"

View File

@ -10,6 +10,7 @@
#define __CONTAINERS_H_
#include"macro_helpers.h"
#include"platform_assert.h"
#ifdef __cplusplus
extern "C" {

View File

@ -120,30 +120,4 @@ static inline u64 next_pow2_u64(u64 x)
#define defer_loop(begin, end) begin; for(int __i__=0; __i__<1; __i__++, end)
//NOTE: assert macros
#ifndef NO_ASSERT
#ifdef PLATFORM_ORCA
extern int orca_assert(const char* file, const char* function, int line, const char* src, const char* msg);
#define ORCA_ASSERT(x, msg) ((x) || orca_assert(__FILE__, __FUNCTION__, __LINE__, #x, msg))
#define _ASSERT_(x, msg) ORCA_ASSERT(x, msg)
#else
#include<assert.h>
#define _ASSERT_(x, msg) assert(x && msg)
#endif
#define ASSERT(x, ...) _ASSERT_(x, #__VA_ARGS__)
#ifdef DEBUG
#define DEBUG_ASSERT(x, ...) ASSERT(x, ##__VA_ARGS__ )
#else
#define DEBUG_ASSERT(x, ...)
#endif
#else
#define ASSERT(x, ...)
#define DEBUG_ASSERT(x, ...)
#endif
#endif //__MACRO_HELPERS_H_

View File

@ -6,7 +6,7 @@
* @revision:
*
*****************************************************************/
#include"macro_helpers.h"
#include"platform_assert.h"
#include"strings.h"
//----------------------------------------------------------------------------------