Various Portability Improvements

A few patches in preparation of my (not quite ready yet) Haiku port of libsolv. The changes aren't Haiku specific, but general portability improvements, like making header C++ safe, C89 fixes, a POSIX fix, etc.