summaryrefslogtreecommitdiff
path: root/generic/lib/shared/clamp.inc
blob: c918f9c499e70f6a948ed0e8e0331ecd5c54afb3 (plain)
1
2
3
4
5
6
7
8
9
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE clamp(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_GENTYPE z) {
  return (x > z ? z : (x < y ? y : x));
}

#ifndef __CLC_SCALAR
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE clamp(__CLC_GENTYPE x, __CLC_SCALAR_GENTYPE y, __CLC_SCALAR_GENTYPE z) {
  return (x > (__CLC_GENTYPE)z ? (__CLC_GENTYPE)z : (x < (__CLC_GENTYPE)y ? (__CLC_GENTYPE)y : x));
}
#endif