Function Pointer Declaration Untangling

March 3rd, 2010

Last week, on Monday, I started writing my own C compiler with JastAdd, JFlex and Beaver.

To check that the compiler parses various declarations and types correctly, I wrote some attributes to spit out a human-readable representation of how the compiler interprets it’s input. This turned out to be a quite useful tool for reading difficult function pointer declarations. For example

int (*fpfi(int (*)(long), int))(int, ...);

becomes

fpfi has type ‘function of (pointer to function of (long int) returning int, int) returning pointer to function of (int, …) returning int’

The future of Gaming & Technology

February 24th, 2010

I stumbled across this mind-blowing talk with Jesse Schell today:

http://g4tv.com/videos/44277/DICE-2010-Design-Outside-the-Box-Presentation/

He’s got some really interesting future-visions at the end.

The Space-Turd Accelerator

February 7th, 2010

This is my first attempt at fiction. You have been warned.

Already in the early half the twenty-second century USA and China had started waging war in the orbital space around planet Earth. It had started with then communist USA shooting down some of fascist China’s spy satellites, and from there the conflicts had spiraled. On each side of the battle, engineers tried to out-smart their opponents with new and better ways to take down the enemy’s orbital spying capabilities.

In the beginning small nukes were used against the satellites. The main effective component of the nukes was radiation, knocking out the electronics of a target satellite. Of course regular bombs were utterly useless out in space since they are weapons based on gas expansion. Any gas explosion in space simply disperses too fast to be effective.

Soon the satellites were given defensive weaponry to ward off oncoming rockets. The first generation of countermeasures installed on the spy satellites were huge lasers. However, laser-based weapons proved to consume way too much energy even when when fired only in short pulses. They were soon replace with kinetic impactors — weapons firing small slugs of metal which were propelled at ever greater speeds against the incoming rockets. These slugs knocked the rockets off their course and wreaked massive destruction to the warheads, often totally disabling them.

As more and more costly weaponry was installed on these spy satellites it became quite hard, not to say impossible, to target them effectively from the surface of Earth. Instead some ingenious engineers had the bright idea to use the kinetic impactors which was already present on board the satellites to target enemy craft. Through an ever increasing arms race between the nations, with the goal of wiping out all the enemy’s orbital spying capabilities, these satellites had soon become full-fledged battle stations.

The space battle stations were huge objects with attitude rockets protruding on long, spike-like, booms from a spherical core. They were large enough to house a full crew of twenty men. The outer parts of the ship were mostly covered in protective shielding, with no windows or observation decks. Navigation was performed by a cluster of computers near the core. The crew was there simply to service the machinery which could not service itself. In the very middle of these spiked balls of doom was the gyroscope. The gyro, together with the attitude rockets, aided in turning the ship around, aiming one of the eight main cannons at some hostile target. The cannons were the most expensive parts on these ships. They were machines capable of accelerating small pellets up to speeds nearing that of light. When one of these pellets hit an unshielded target it would completely rip through it, shredding anything in proximity with force equal to any atomic bomb.

Now the interesting thing about these battle stations was that they did not fire metal slugs as kinetic impactors. They fired super-compressed organic material. Often human excrement. With no other waste disposal options than burning or evacuating into space, it should be an honor for any turd to be fired out of a twelve billion dollar weapon at 98% the speed of light. Not to mention the humorous fact that these space wars were quite literally orbital shit-flinging battles.

L2Stack is Open Source

January 19th, 2010

I’ve been putting it off more and more, but I finally got around to setting up autoconf/automake to compile L2Stack on Linux. It was a lot less hassle than I had expected. Once I got through the bewildering structure of automake I only had a couple compile errors to correct, and then it just worked! Amazing.

Bottom line is that it compiles on Linux now and although the project has been uploaded on Launchpad well over a month now I didn’t feel comfortable making an announcement since the code was in a such an untested state.

Read the instructions on how to get it running on Linux.

I haven't got hardware acceleration for OpenGL on my laptop yet, so this ran slow as syrup.

Compiler optimizations: SSAPRE

December 26th, 2009

Manfred Dellkrantz and I took a course on compiler optimizations at Lund University this autumn. The course consisted of lectures, an exam and a course project in which the students, in groups of two, got to implement some of the optimizations which Jonas Skeppstedt went through during the lectures.

For the course project we had a simple C compiler with a simulator to run a certain benchmark in. After we’d handed in our optimizing compilers the groups were ranked by how many clock cycles the benchmark took after optimization. The top three groups from each year are listed at the course webpage (under “Exam”). Manfred and I were not originally thinking about putting serious effort into this contest, but as we started to work on our project we soon became very enthusiastic and spent nearly all of our free time implementing various optimization algorithms. We placed in at all-time 1st place for the course and our particular benchmark – a result we vere very pleased with, to say the least!

One of the optimizations that I implemented in our project is described in the paper Partial Redundancy Elimination in SSA Form by Robert Kennedy et al. in TOPLAS, May 1999.

Read the rest of this entry »

Show me the Changelog!

December 21st, 2009

This blog uses Wordpress. You might have heard of it. It’s a pretty nice blogging system. I have only one gripe with it, and that is the automatic update screen. The automatic updating system was added a few versions back and made my life a lot easier, but one really crucial feature it lacks is a link to the changelog!

upgrade

How should I know if I really want to apply an update if I can’t see what it changes? Sure some people might be OK with changing their software without knowing what changes are being made, but I am not.

Changelogs and release notes are important. The user needs to be able to see them, and they should be available before installing any kind of update. If it’s a bugfix update, I want to know which bugs were eliminated. If it’s a security update, I want to know which vulnerabilities were fixed. If it’s a feature update, I want to know which features have been added!

The most logical thing would be to have a link to the changelog right next to the “Upgrade Automatically” button in Wordpress.

Update: After writing this rant, I went to Wordpress’ changelog for version 2.9. Apparently one of the new things of version 2.9 is that it requires a higher version of MySQL! This is a big change! Imagine a Wordpress user clicking that Upgrade Automatically” button and subsequently finding out that Wordpress no longer works on his server!

Requires MySQL 4.1.2 or greater (old requirement was 4.0).

Update 2: I took a look at WordPress’ update code and saw that it automatically checks that you have a compatible MySQL and PHP install before updating, so I guess that nullifies my last complaint but from a usability perspective it would be nice for the user to know that WordPress has actually checked if PHP and MySQL are compatible.