13f012e29Smrg/*
23f012e29Smrg * Copyright 2014 Advanced Micro Devices, Inc.
33f012e29Smrg *
43f012e29Smrg * Permission is hereby granted, free of charge, to any person obtaining a
53f012e29Smrg * copy of this software and associated documentation files (the "Software"),
63f012e29Smrg * to deal in the Software without restriction, including without limitation
73f012e29Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
83f012e29Smrg * and/or sell copies of the Software, and to permit persons to whom the
93f012e29Smrg * Software is furnished to do so, subject to the following conditions:
103f012e29Smrg *
113f012e29Smrg * The above copyright notice and this permission notice shall be included in
123f012e29Smrg * all copies or substantial portions of the Software.
133f012e29Smrg *
143f012e29Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
153f012e29Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
163f012e29Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
173f012e29Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
183f012e29Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
193f012e29Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
203f012e29Smrg * OTHER DEALINGS IN THE SOFTWARE.
213f012e29Smrg *
223f012e29Smrg*/
233f012e29Smrg
243f012e29Smrg#ifndef _UTIL_MATH_H_
253f012e29Smrg#define _UTIL_MATH_H_
263f012e29Smrg
273f012e29Smrg#define MIN2( A, B )   ( (A)<(B) ? (A) : (B) )
283f012e29Smrg#define MAX2( A, B )   ( (A)>(B) ? (A) : (B) )
293f012e29Smrg#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
303f012e29Smrg
313f012e29Smrg#define __align_mask(value, mask)  (((value) + (mask)) & ~(mask))
3277e87e13Smrg#undef ALIGN
3306a15751Schristos#define ALIGN(value, alignment)    __align_mask(value, (__typeof__(value))((alignment) - 1))
343f012e29Smrg
353f012e29Smrg#endif /*_UTIL_MATH_H_*/
36