Only look up original libc functions once

Cache the result in the static variable, and factorize the logic.

https://github.com/martinpitt/umockdev/issues/21