Fix build on OSX, etc. by checking whether each errno is defined.