safe_macros: Move SAFE_PREAD() and SAFE_PWRITE() to separate header

This fixes numerous "implicit function declaration" on slightly older
distributions where pwrite() and pread() needs to defined either of
_XOPEN_SOURCE or _GNU_SOURCE.

Adding a separate header for these two functions seems to be the only
reasonable solution since:

o These functions has to be inlined in the header because the prototype
  contains off_t whose size depends on compile time settings

o Defining _GNU_SOURCE in the safe macros header is not a solution
  either since it has to be defined before we include any libc headers
  in order to take any effect

The first solution I had in mind was to add fallback prototypes for
these two functions, but that would allow the testwrites to use these
functions without defining the corresponding macro which may possibly
break the glibc redirection magic.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
3 files changed