roo_e/shared/macros.h
2022-06-02 19:15:53 -05:00

26 lines
570 B
C

#ifndef MACROS_H
#define MACROS_H
// Should be after system headers in this file.
#define MEMORY_CHECK_ENABLED
#include "memory.h"
// Allocation helpers.
#define NEW(t,v) (v)=(t*)malloc(sizeof(t)) // Add check for NULL and die here.
#define DEL(v) {if(v) {free(v); v=NULL;}}
// Some helper defines.
#define DIVISIBLE_BY_EIGHT(x) ((((x) >> 3) << 3) == (x))
#define HIGH_BYTE(b) ((uint8_t)(((b) & 0xFF00) >> 8))
#define LOW_BYTE(b) ((uint8_t)((b) & 0x00FF))
// Return codes.
#define SUCCESS 0
#define FAIL 1
#endif // MACROS_H