sm64ex-coop/include/macros.h

55 lines
1.3 KiB
C
Raw Normal View History

2019-08-25 06:46:40 +02:00
#ifndef _MACROS_H_
#define _MACROS_H_
2019-11-03 20:36:27 +01:00
#include "platform_info.h"
2020-04-03 20:57:26 +02:00
#ifndef __sgi
#define GLOBAL_ASM(...)
#endif
2019-12-02 03:52:53 +01:00
#if !defined(__sgi) && (!defined(NON_MATCHING) || !defined(AVOID_UB))
// asm-process isn't supported outside of IDO, and undefined behavior causes
// crashes.
#error Matching build is only possible on IDO; please build with NON_MATCHING=1.
#endif
2019-08-25 06:46:40 +02:00
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define GLUE(a, b) a ## b
#define GLUE2(a, b) GLUE(a, b)
// Avoid compiler warnings for unused variables
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif
// Static assertions
#ifdef __GNUC__
#define STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
#else
#define STATIC_ASSERT(cond, msg) typedef char GLUE2(static_assertion_failed, __LINE__)[(cond) ? 1 : -1]
#endif
2019-11-03 20:36:27 +01:00
// Align to 8-byte boundary for DMA requirements
#ifdef __GNUC__
#define ALIGNED8 __attribute__((aligned(8)))
#else
#define ALIGNED8
#endif
// Align to 16-byte boundary for audio lib requirements
#ifdef __GNUC__
#define ALIGNED16 __attribute__((aligned(16)))
#else
#define ALIGNED16
#endif
2020-05-07 20:21:22 +02:00
// no conversion for pc port other than cast
#define VIRTUAL_TO_PHYSICAL(addr) ((uintptr_t)(addr))
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr))
#define VIRTUAL_TO_PHYSICAL2(addr) ((void *)(addr))
2019-10-05 21:08:05 +02:00
2019-08-25 06:46:40 +02:00
#endif