Protect some stuff that's only needed for compiling on a system before 10.6
Fix LLVM warning about trinary alternatives not having matching types.
More missing prototypes that llvm iscomplaining about.