Updated: 11/5/2005; 6:04:02 PM.
Chris Double's Radio Weblog
        

Tuesday, April 08, 2003

I struggled over the weekend to get Chicken Scheme to call some X and OpenGL libraries. The problem I was having was my program would hang for no apparent reason. After much debugging I tracked it down to the garbage collecting infinitely looping through minor garbage collections.

I should have followed my Corman Lisp advice posted previously...look to your code not the implementation.

I was using SWIG to automatically generate wrappers to the C code but there is a caveat. Chicken requires special code if the C code you are calling calls back into C. I use scheme callbacks to implement drawing routines, etc for windows. SWIG doesn't generate this special code as it doesn't know what what call back into Scheme and what won't. The fix was to write my own wrapper for that specific function using FOREIGN-CALLBACK-LAMBDA:

(define wrapper-do-event
  (foreign-callback-lambda void "do_event" c_pointer))

And now I have multiple OpenGL windows displaying and changable from the Chicken Scheme read-eval-print loop interactively. Neat.


2:26:42 AM      

They've been a few questions on the Corman Lisp newsgroup lately about FFI issues. In particular, when and how you allocate memory for accessing C structures and passing that information to other functions. Here are some messages I posted to that list that help explain how to do this safely:

  1. http://groups.yahoo.com/group/cormanlisp/message/1408
  2. http://groups.yahoo.com/group/cormanlisp/message/1404
  3. http://groups.yahoo.com/group/cormanlisp/message/1385

Incorrect use of the FFI can completely crash Corman Lisp, including the IDE. It's exactly the same as incorrecting managing memory from C - because that's what you are basically doing. C level management. If the IDE seems flakey and your programs are crashing on you, look into your FFI code.


2:17:29 AM      

TopologiLinux version 3.0.0 has been released. TopologiLinux is based on Slackware 9.0 with a few additions.

Most notably it is built to install into a file on a Windows filesystem. This means you can install Linux without re-partitioning your drive. I have used the previous version, 2.0.2, with no problems and it runs very well. I plan to upgrade to 3.0.0 in the near future.

TopologiLinux 3.0.0 includes Alsa sound drivers out-of-the-box which is a bonus. I've never had good sound support frmo Slackware after initial installation so hopefully this resolves that issue.


2:12:41 AM      

© Copyright 2005 Chris Double.
 
April 2003
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
Mar   May



Click here to visit the Radio UserLand website.

Listed on BlogShares

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.