You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compiler.h 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef COMPILER_H
  2. #define COMPILER_H
  3. /* We export the symbol obj_OBJECT (OBJECT is defined on command-line)
  4. * as a global symbol, so that the linker can drag in selected object
  5. * files from the library using -u obj_OBJECT.
  6. *
  7. * Not quite sure why cpp requires two levels of macro call in order
  8. * to actually expand OBJECT...
  9. */
  10. #undef _H1
  11. #define _H1( x, y ) x ## y
  12. #undef _H2
  13. #define _H2( x, y ) _H1 ( x, y )
  14. #define OBJECT_SYMBOL _H2 ( obj_, OBJECT )
  15. #undef _STR
  16. #define _STR(s) #s
  17. #undef _XSTR
  18. #define _XSTR(s) _STR(s)
  19. #define OBJECT_SYMBOL_STR _XSTR ( OBJECT_SYMBOL )
  20. #ifdef ASSEMBLY
  21. .globl OBJECT_SYMBOL
  22. .equ OBJECT_SYMBOL, 0
  23. #else /* ASSEMBLY */
  24. __asm__ ( ".globl\t" OBJECT_SYMBOL_STR );
  25. __asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" );
  26. /*
  27. * Macro to allow objects to explicitly drag in other objects by
  28. * object name. Used by config.c.
  29. *
  30. */
  31. #define REQUIRE_OBJECT(object) \
  32. __asm__ ( ".equ\tneed_" #object ", obj_" #object );
  33. /*
  34. * If debug_OBJECT is set to a true value, the macro DBG(...) will
  35. * expand to printf(...) when compiling OBJECT, and the symbol
  36. * WITH_DEBUG_MESSAGES will be inserted into the object file.
  37. *
  38. */
  39. #define DEBUG_SYMBOL _H2 ( debug_, OBJECT )
  40. #if DEBUG_SYMBOL
  41. #define DBG(...) printf ( __VA_ARGS__ )
  42. #define DEBUG_SYMBOL_STR _XSTR ( DEBUG_SYMBOL )
  43. __asm__ ( ".equ\tWITH_DEBUG_MESSAGES, 0" );
  44. #else
  45. #define DBG(...)
  46. #endif
  47. #define PACKED __attribute__((packed))
  48. #define __unused __attribute__((unused))
  49. #define __used __attribute__((used))
  50. #endif /* ASSEMBLY */
  51. #endif /* COMPILER_H */