I've been doing lots of good hacking on cparse, a Lisp program for generating foreign function interface declarations from C header files. In my last entry I breezily stated that handling sizeof() would be easy. Hah!! Anyway, getting that all right turned up parts of the C grammer that I had "forgotten" to handle. So, after much ripping apart and putting things back together, the parser is in much better shape. It now processes all of Xlib.h except for stdarg "..." function arguments, which aren't supported in CMUCL anyway. Things really are looking good for a public release later this week.
Celebrated my 35th birthday yesterday. When I was a teenager I could never imagine being so old.
Hacked some more on cparse, my Lisp program for parsing C headers and generating FFI declarations. I've been feeding it Xlib.h, which is a good, complicated test case. Turns out I forgot to parse sizeof(). Doh! It won't be hard to add as I already have the support in the C types code to figure out the size of everything.
Saw the best, funniest special on VH1 ever last night: a biography of Iggy Pop. Usually those things are so pompous that they suck incredibly, but in this case it was impossible for VH1 to overwhelm the wit and genius of Iggy himself. The ad for the rap compilation "Monster Booty" was an added bonus.
I've set the garbage collector work aside for a week and have been hacking on another home project. I've written a C header file parser for Common Lisp. This code digests header files that have been run through the C preprocessor and parses the subset of C that is likely to be in a header file i.e., most things other than function bodies. Constant expressions are supported. A parse tree, with each element of C grammer represented as a CLOS object, is produced. I've also written some code that walks that parse tree and emits the def-alien declarations for CMU CommonLisp. So, maybe we're a little bit closer to automatically interfacing with C? Maybe. I hope to make an initial release by the end of the week.
I'd like to get all the ports of CMUCL to use this collector; there's no advantage of the old stop/copy collector that I can see, other than simplicity and possible lack of support for write protecting pages on some platforms.
So, last night I did some hacking on CMUCL's garbage collector, as advertised. The work I've done is pretty minimal at this point: just adding some additional statistics such as time spent collecting, page faults incurred, etc. I have a plan to tune up the garbage collector and these are the first baby steps in that direction. I think it'd be cool to let the user choose one of several GC policies: fast (generally short pauses), real time (very short pauses, 5-8ms in general), throughput (reasonable pauses but minimizing the total time spent collecting rather than the length of any one GC), and a spiffy auto GC policy that figures out which policy would be best for the current session.
CMUCL's garbage collector is written in C, and I was somewhat resigned to doing this tuning work in C too. Last night I had an "Aha!" about this: don't implement the policy code in C, which would be a drag, but export statistics and tunable parameters from the C implementation into Lisp. Lisp code that runs in an after-gc-hook then analyzes the statistics from previous GCs and diddles the parameters appropriately. Much better; after all, if I wanted to program in C I'd be hacking on the Gimp or something :)
A motivating factor for going in this direction is the fact that working on CMUCL's C code is a pain in the rear. CMUCL is a combination of a small C/assembly program providing some primitive services (such as memory allocation and garbage collection) and a much larger image of Lisp code and data. The Lisp code knows the addresses of important routines in the C code so they can be called from Lisp, but when the C code changes the addresses of those functions change too and the Lisp image has to be rebuilt. How that's done is a subject for another time, but it's somewhat more involved than just typing "make".
New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!