mirror of
https://github.com/ipxe/ipxe
synced 2025-12-30 13:11:11 +03:00
Added ASSERT() macro
This commit is contained in:
@@ -3,8 +3,6 @@
|
|||||||
#include "memsizes.h"
|
#include "memsizes.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
|
|
||||||
#define ASSERT(...)
|
|
||||||
|
|
||||||
struct heap_block {
|
struct heap_block {
|
||||||
size_t size;
|
size_t size;
|
||||||
char data[0];
|
char data[0];
|
||||||
@@ -102,7 +100,7 @@ void * emalloc ( size_t size, unsigned int align ) {
|
|||||||
physaddr_t addr;
|
physaddr_t addr;
|
||||||
struct heap_block *block;
|
struct heap_block *block;
|
||||||
|
|
||||||
ASSERT ( ! ( align & ( align - 1 ) ) );
|
ASSERT ( ( align & ( align - 1 ) ) == 0 );
|
||||||
|
|
||||||
addr = ( ( ( heap_ptr - size ) & ~( align - 1 ) )
|
addr = ( ( ( heap_ptr - size ) & ~( align - 1 ) )
|
||||||
- sizeof ( struct heap_block ) );
|
- sizeof ( struct heap_block ) );
|
||||||
@@ -132,7 +130,7 @@ void * emalloc_all ( size_t *size ) {
|
|||||||
void efree ( void *ptr ) {
|
void efree ( void *ptr ) {
|
||||||
struct heap_block *block;
|
struct heap_block *block;
|
||||||
|
|
||||||
ASSERT ( ptr == ( heap_ptr + sizeof ( size_t ) ) );
|
ASSERT ( ptr == phys_to_virt ( heap_ptr + sizeof ( size_t ) ) );
|
||||||
|
|
||||||
block = ( struct heap_block * )
|
block = ( struct heap_block * )
|
||||||
( ptr - offsetof ( struct heap_block, data ) );
|
( ptr - offsetof ( struct heap_block, data ) );
|
||||||
|
|||||||
@@ -67,6 +67,23 @@ __asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR );
|
|||||||
#define DBG2 DBG_PRINT
|
#define DBG2 DBG_PRINT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASSERT() macros
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define ASSERT(x)
|
||||||
|
|
||||||
|
#if DEBUG_SYMBOL >= 1
|
||||||
|
#undef ASSERT
|
||||||
|
#define ASSERT(x) \
|
||||||
|
do { \
|
||||||
|
if ( ! (x) ) { \
|
||||||
|
DBG ( "ASSERT(%s) failed at %s line %d [%s]\n", #x, \
|
||||||
|
__FILE__, __LINE__, __FUNCTION__ ); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PACKED __attribute__((packed))
|
#define PACKED __attribute__((packed))
|
||||||
#define __unused __attribute__((unused))
|
#define __unused __attribute__((unused))
|
||||||
#define __used __attribute__((used))
|
#define __used __attribute__((used))
|
||||||
|
|||||||
Reference in New Issue
Block a user