123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef COMPILER_H
- #define COMPILER_H
-
-
- #undef _H1
- #define _H1( x, y ) x ## y
- #undef _H2
- #define _H2( x, y ) _H1 ( x, y )
- #define PREFIX_OBJECT(prefix) _H2 ( prefix, OBJECT )
- #define OBJECT_SYMBOL PREFIX_OBJECT(obj_)
- #undef _STR
- #define _STR(s) #s
- #undef _XSTR
- #define _XSTR(s) _STR(s)
- #define OBJECT_SYMBOL_STR _XSTR ( OBJECT_SYMBOL )
-
- #ifdef ASSEMBLY
-
- .globl OBJECT_SYMBOL
- .equ OBJECT_SYMBOL, 0
-
- #else
-
- __asm__ ( ".globl\t" OBJECT_SYMBOL_STR )
- __asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" )
-
-
- #define REQUIRE_OBJECT(object) \
- __asm__ ( ".equ\tneed_" #object ", obj_" #object );
-
-
- #define DEBUG_SYMBOL PREFIX_OBJECT(debug_)
-
- #if DEBUG_SYMBOL
- #include "console.h"
- #define DEBUG_SYMBOL_STR _XSTR ( DEBUG_SYMBOL )
- __asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR )
- #endif
-
- #define DBG_PRINT(...) printf ( __VA_ARGS__ )
- #define DBG_DISCARD(...)
- #define DBG DBG_DISCARD
- #define DBG2 DBG_DISCARD
-
- #if DEBUG_SYMBOL >= 1
- #undef DBG
- #define DBG DBG_PRINT
- #endif
-
- #if DEBUG_SYMBOL >= 2
- #undef DBG2
- #define DBG2 DBG_PRINT
- #endif
-
-
- #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 __unused __attribute__ (( unused ))
- #define __used __attribute__ (( used ))
- #define __aligned __attribute__ (( aligned ( 16 ) ))
-
-
-
- #define __shared __asm__ ( "_shared_bss" )
-
- #endif
-
- #endif
|