Support for LLVM/clang 3.5 HEAD and some Mac fixes

I know 3.5 is a moving target, but this should make Terra work with the Clang 3.5 HEAD as of 3 days ago. It passes all tests except for the ones with includec.

The "lcurses" and "__APPLE__" changes make Terra build successfully on OS X 10.9. Unfortunately, all versions of Terra and LLVM (>= 3.3) segfault on my 2012 Macbook Air deep down in Clang in any attempt to use "includec".

I have burnt over 50 hours trying to fix the segfault on Mac, and I can't afford any more time on this (or to test my changes on Linux at this point). I'm 90% sure the problem is due to LuaJit's required image_base and page_zero changes, but someone far more familiar with LLVM than I would have to fix it.

I cleaned up my work and made this pull request because it still fixes more than it breaks, and support for llvm 3.5 final will be easier with this progress.

Unfortunately for my project I need llvm 3.5 and mac support basically now (long story, but I need the Polly improvements in 3.5), so I am going to have to base my project on Julia instead of Terra, which is not segfaulting on my machine.