tests: Add ABI check for code_exec
authorDavid Schleef <ds@schleef.org>
Mon, 14 Jun 2010 23:20:41 +0000 (16:20 -0700)
committerDavid Schleef <ds@schleef.org>
Mon, 14 Jun 2010 23:20:41 +0000 (16:20 -0700)
testsuite/Makefile.am
testsuite/abi.c [new file with mode: 0644]

index dc19a70..3bdaa5b 100644 (file)
@@ -9,7 +9,8 @@ TESTS = \
        exec_opcodes_sys \
        exec_parse \
        perf_opcodes_sys perf_parse \
-       memcpy_speed
+       memcpy_speed \
+       abi
 
 noinst_PROGRAMS = $(TESTS) generate_xml_table generate_xml_table2 \
        generate_opcodes_sys compile_parse compile_parse_c memcpy_speed \
diff --git a/testsuite/abi.c b/testsuite/abi.c
new file mode 100644 (file)
index 0000000..f03a7b3
--- /dev/null
@@ -0,0 +1,33 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <orc/orc.h>
+
+#include <stdio.h>
+
+
+int main (int argc, char *argv[])
+{
+  int offset;
+  int expected_offset;
+  int error = 0;
+
+  offset = ((int) ((unsigned char *) &((OrcProgram*) 0)->code_exec));
+
+  if (sizeof(void *) == 4) {
+    expected_offset = 8360;
+  } else {
+    expected_offset = 9688;
+  }
+
+  if (offset != expected_offset) {
+    printf("ABI bug: OrcProgram->code_exec should be at offset %d instead of %d\n",
+        offset, expected_offset);
+    error = 1;
+  }
+
+  return error;
+}
+