src: Replace macros with util functions

Just what it says on the tin.