qcommon: define MIN and MAX functions