aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/compiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/compiler.h')
-rw-r--r--src/include/compiler.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/include/compiler.h b/src/include/compiler.h
new file mode 100644
index 000000000..401d4e458
--- /dev/null
+++ b/src/include/compiler.h
@@ -0,0 +1,41 @@
+#ifndef COMPILER_H
+#define COMPILER_H
+
+/* We export the symbol obj_OBJECT (OBJECT is defined on command-line)
+ * as a global symbol, so that the linker can drag in selected object
+ * files from the library using -u obj_OBJECT.
+ *
+ * Not quite sure why cpp requires two levels of macro call in order
+ * to actually expand OBJECT...
+ */
+#undef _H1
+#define _H1( x, y ) x ## y
+#undef _H2
+#define _H2( x, y ) _H1 ( x, y )
+#define OBJECT_SYMBOL _H2 ( obj_, OBJECT )
+#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 /* ASSEMBLY */
+
+__asm__ ( ".globl\t" OBJECT_SYMBOL_STR );
+__asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" );
+
+#define REQUIRE_OBJECT(object) \
+ __asm__ ( ".equ\tneed_" #object ", obj_" #object );
+
+#define PACKED __attribute__((packed))
+#define __unused __attribute__((unused))
+#define __used __attribute__((used))
+
+#endif /* ASSEMBLY */
+
+#endif /* COMPILER_H */