cleanup diffs against upstream, use builtin __APPLE__ for specific macosx dependent code