split macros and ulities out and modernize

Useful gcc extensions are useful
move safe_asprintf to utils.c