kernel.h: split out min()/max() et al. helpers