@navi @Gottox yeah at low levels errno is good; at higher levels I sometimes use errno as well when the codes map relatively well to the semantics I want. Sometimes it's just not possible, in which case I need to define specific error codes, but this is annoying to do and even more annoying to document; I try to avoid that out of sheer laziness.
Note that LIBFOO_ERROR_SYSTEM is exactly what getaddrinfo() does: it has an EAI_SYSTEM error value. I think it's fine for this kind of function; impractical, yes, but about the best you can do.