sun: add generic max / min functions