math: define _GNU_SOURCE when implementing non-standard math functions

this makes the prototypes in math.h are visible so they are checked agaist
the function definitions
remove an unnecessary check in inet_pton

at most 4 hexadecimal digits are processed in one field so the
value cannot overflow. the netdb.h header was not used.
include cleanups: remove unused headers and add feature test macros
use 0 instead of NULL for null pointer constants

and thereby remove otherwise-unnecessary inclusion of stddef.h
optimize get_current_dir_name to reduce stack bloat

our getcwd already (as an extension) supports allocation of a buffer
when the buffer argument is a null pointer, so there's no need to
duplicate the allocation logic in this wrapper function. duplicating
it is actually harmful in that it doubles the stack usage from
PATH_MAX to 2*PATH_MAX.