Mac OS X Support

These are my changes for the Darwin platform. I have only been able to test it on two machines, which unfortunately have the same architecture and OS version. I've also made sure the I didn't break anything too major; it still compiles and runs under Linux (Ubuntu).