gre: Move utility functions to common headers