1/* 2 * Copyright 2014, NICTA 3 * 4 * This software may be distributed and modified according to the terms of 5 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 6 * See "LICENSE_BSD2.txt" for details. 7 * 8 * @TAG(NICTA_BSD) 9 */ 10 11#define UINT_MAX (-1u) 12 13/* 14 * Simple pure functions. 15 */ 16 17unsigned min(unsigned a, unsigned b) { 18 if (a <= b) { 19 return a; 20 } else { 21 return b; 22 } 23} 24 25unsigned max(unsigned a, unsigned b) { 26 return UINT_MAX - ( 27 min(UINT_MAX - a, UINT_MAX - b)); 28} 29 30