Augment `OBJCODE_COOKIE' to detect wrong endianness or word size.
authorLudovic Courtès <ludo@gnu.org>
Tue, 14 Jul 2009 22:55:33 +0000 (00:55 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 14 Jul 2009 22:55:33 +0000 (00:55 +0200)
* libguile/objcodes.c (OBJCODE_ENDIANNESS, _OBJCODE_STRINGIFY,
  OBJCODE_STRINGIFY, OBJCODE_WORD_SIZE): New macros.
  (OBJCODE_COOKIE): Use them.  The intent is that `.go' files compiled
  for a different endianness or word size are detected.

libguile/objcodes.c

index 4f21971..d5d6695 100644 (file)
 #include "programs.h"
 #include "objcodes.h"
 
+/* The endianness marker in objcode.  */
+#ifdef WORDS_BIGENDIAN
+# define OBJCODE_ENDIANNESS "BE"
+#else
+# define OBJCODE_ENDIANNESS "LE"
+#endif
+
+#define _OBJCODE_STRINGIFY(x)  # x
+#define OBJCODE_STRINGIFY(x)   _OBJCODE_STRINGIFY (x)
+
+/* The word size marker in objcode.  */
+#define OBJCODE_WORD_SIZE  OBJCODE_STRINGIFY (SIZEOF_VOID_P)
+
 /* nb, the length of the header should be a multiple of 8 bytes */
-#define OBJCODE_COOKIE "GOOF-0.6"
+#define OBJCODE_COOKIE                                         \
+  "GOOF-0.6-" OBJCODE_ENDIANNESS "-" OBJCODE_WORD_SIZE "---"
 
 \f
 /*