[generic] Backport roundup, rounddown, max and min functions.