[gambit-list] What is required to port gambit to a new cpu?

Frederick LeMaster fred.lemaster at gmail.com
Tue Dec 29 18:38:12 EST 2009


Thanks! It looks like the preprocessor symbol __ARMEL__ specifies
little endianness and __ARMEB__ specifies big endianness. Here's the
patch for gambit.h.in

On Tue, Dec 29, 2009 at 7:13 AM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
> I've seen exactly this behaviour when the include/gambit.h.in file determines the wrong endianness for the CPU.  Given that the ARM can either be little or big-endian, chances are good that the #ifdefs in the gambit.h.in file are not sufficient to detect the endianness on the Nokia platform.  Usually the C compiler or development environment will define a symbol that indicates the endianness of the CPU, and the gambit.h.in file needs to be modified to test this symbol.  Here is an excerpt of the gambit.h.in file which determines the endianness when the CPU is an ARM:
>
> #ifndef ___BIG_ENDIAN
> #ifndef ___LITTLE_ENDIAN
>
> ...
>
> #ifdef ___CPU_arm
> #ifdef _LITTLE_ENDIAN
> #define ___LITTLE_ENDIAN
> #endif
> #ifdef __LITTLE_ENDIAN__
> #define ___LITTLE_ENDIAN
> #endif
> #ifdef __LITTLE_ENDIAN_DATA__
> #define ___LITTLE_ENDIAN
> #endif
> #endif
>
> ...
>
> #endif
> #endif
>
> Note that by default the gambit.h.in file assumes the endianness is big-endian.  So I'm pretty sure none of the symbols _LITTLE_ENDIAN, __LITTLE_ENDIAN__, and __LITTLE_ENDIAN_DATA__ are defined and the gambit.h.in file will assume incorrectly that the endianness is big-endian.
>
> There are two solutions.
>
> #1, the clean way, is to check the compiler documentation to see which symbol is defined by the C preprocessor to indicate the endianness, and to modify the above sequence of #ifdefs to take that into account.
>
> #2, the brute force way, is to add #define ___LITTLE_ENDIAN at the top of the gambit.h.in file.
>
> I propose you try #2 first, and if that solves the problem, then try #1 and send me a patch so I can modify my source code.
>
> Note that after modifying the include/gambit.h.in file, you will have to do a ./configure and probably a "make mostlyclean" before "make".
>
> Marc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gambit.h.in.patch
Type: text/x-diff
Size: 303 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20091229/88371fcb/attachment.patch>


More information about the Gambit-list mailing list