Retrieve errno directly from libc.

Don't rely on ctypes.get_errno(), as it always seems to return 0. Use
errno directly from libc.