[gambit-list] Strange Gambit error problems DS

Marc Feeley feeley at iro.umontreal.ca
Tue Oct 24 11:02:00 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 24-Oct-06, at 8:39 AM, Andrew Lentvorski wrote:

> Marc Feeley wrote:
>> Can you explain how you fixed the problem?  The file include/ 
>> gambit.h contains ifdefs to automatically figure out what the  
>> endianness is.  In particular it contains:
>
> I simply did:
>
>> #ifdef ___CPU_arm
> #define _LITTLE_ENDIAN
>> #ifdef _LITTLE_ENDIAN
>> #define ___LITTLE_ENDIAN
>> #endif
>> #ifdef __LITTLE_ENDIAN__
>> #define ___LITTLE_ENDIAN
>> #endif
>> #ifdef __LITTLE_ENDIAN_DATA__
>> #define ___LITTLE_ENDIAN
>> #endif
>> #endif
>
> For some reason, nothing sets a _LITTLE_ENDIAN flag in the DS  
> development environment.  <shrug>
>
> It also probably doesn't help that I'm cross compiling from OS X  
> PPC which is big endian.  So, all of the configure and makefiles  
> run under that to produce the C code.  My scons files then handle  
> the cross compiling to the DS.
>
> As of now, I have a 3 Mibibyte binary which produces a repl with a  
> console and emulated keyboard on the screen and touchscreen.  It  
> works on both hardware and under the no$gba emulator.

That's great!  It makes me want to buy a Nintendo DS just to try it  
out!  3MB seems a bit big though.  Did you try any of my suggestions  
to cut down on code size?

>   It's still a little strange in that it evaluates before I hit  
> return if there is a parenthesis, eg.:
>
> Gambit Version 4.0 beta 20
>
> > (+ 1 2 3)6
> > (cons 'a '(1 2))(a 1 2)
> > 1
> 1
> > 'a
> a
> >

This is normal because your "stdin" is directly reading from the  
keyboard, and the "read" procedure will know the expression is  
complete when it reads the closing parenthesis or the whitespace  
after a symbol, number, etc.

Gambit's line editing feature is implemented in lib/os_tty.c and it  
is enabled by a "#define USE_LINEEDITOR" in lib/os.h (which is the  
default).  But for this to work on a non-POSIX/non-WIN32 system you  
have to complete the implementation of the functions  
___device_tty_read_raw_no_lineeditor and ___device_tty_write in lib/ 
os_tty.c so that they read/write to the "console" with no buffering.   
You also have to change ___os_device_stream_open_predefined in lib/ 
os_io.c so that when index==-4 it opens the console with a call to  
___device_tty_setup_console (like for POSIX and WIN32).

Where does the output of the "console" go?  Does it go to the  
screen?  Does it support cursor movement and xterm/vt100 escape  
codes?  If not you have to complete the implementation of the  
function lineeditor_output_terminal_op in lib/os_tty.c .

>
> So, my next step is to try to bring networking up.  Is the fact  
> that I have no native threading system going to impact that?

Of course once you have networking, you can just use remote debugging  
with emacs and it will take care of the line-editing.

I assume you know about DS Wifi (http://akkit.org/dswifi/) and lwIP  
(http://masscat.afraid.org/ninds/lwip.php).

For the threading system to work, you will need a heartbeat interrupt  
(complete the implementation of setup_heartbeat_interrupt_handling  
and friends in lib/os_time.c) and non-blocking I/O, at least for  
networking (I think lwIP support non-blocking sockets).  You will  
have to "#define USE_NETWORKING" in lib/os.h and complete the  
implementation of the sections "TCP client stream device" and "TCP  
server device" in lib/os_io.c .

This is not an easy task but I can help you figure out what needs to  
be done.  In the interest of keeping the mailing-list traffic down I  
will stop cross-posting to the mailing-list.

Marc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD0DBQFFPirp//V9Zc2T/v4RAj4pAJjHFS0nb9ANwNYEuAPD9BkUD50lAJj76iCL
bZfmdj88NNEsBBN+/hCT
=YoHM
-----END PGP SIGNATURE-----



More information about the Gambit-list mailing list