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

Marc Feeley feeley at iro.umontreal.ca
Tue Dec 29 10:13:05 EST 2009


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


On 2009-12-29, at 3:49 AM, Frederick LeMaster wrote:

> Thanks!
> 
> I tried it out and some things work great, such as cons and most of
> the list functions, but the reader seems to be having some serious
> issues:
> 
>> 0
> 3
>> 1
> 2
>> 2
> 1
>> 3
> 0
>> 4
> 7
>> 5
> 6
>> 6
> 5
>> 7
> 4
>> 8
> *** ERROR IN (console)@9.1 -- Unbound variable: 8
> 1>
> 
> It seems like it is failing to read the digits properly as numbers.
> The arithmetic routines seem okay though,
>> (number->string (+ (string-length "elephant") (string-length "")))
> "8"
> 
> Is the reader making an unsafe assumption?
> -Fred LeMaster
> 
> On Mon, Dec 28, 2009 at 6:40 AM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
>> 
>> On 2009-12-28, at 3:04 AM, Frederick LeMaster wrote:
>> 
>>> Hello Dr. Feeley,
>>> I am interested in using gambit on the nokia n900 tablet, which
>>> features an ARMv7 cpu. What changes would I need to make in the gambit
>>> sources to allow it to function correctly on this architecture?
>> 
>> Nothing!  It should work "out of the box".
>> 
>> Marc




More information about the Gambit-list mailing list