From: Ludovic Courtès Date: Tue, 14 Jul 2009 22:55:33 +0000 (+0200) Subject: Augment `OBJCODE_COOKIE' to detect wrong endianness or word size. X-Git-Url: https://git.hcoop.net/bpt/guile.git/commitdiff_plain/9e1a18db9fd34a6156007c7db563f46095989b62 Augment `OBJCODE_COOKIE' to detect wrong endianness or word size. * 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. --- diff --git a/libguile/objcodes.c b/libguile/objcodes.c index 4f219717a..d5d66952c 100644 --- a/libguile/objcodes.c +++ b/libguile/objcodes.c @@ -33,8 +33,22 @@ #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 "---" /*