Jon Cruz | 35b2eaa | 2015-06-15 15:37:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2015 Samsung Electronics Co., Ltd |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | * a copy of this software and associated documentation files (the |
| 6 | * "Software"), to deal in the Software without restriction, including |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | * permit persons to whom the Software is furnished to do so, subject to |
| 10 | * the following conditions: |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 16 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 17 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 | * SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | #ifndef WESTON_HELPERS_H |
| 23 | #define WESTON_HELPERS_H |
| 24 | |
| 25 | #ifdef __cplusplus |
| 26 | extern "C" { |
| 27 | #endif |
| 28 | |
| 29 | /** |
| 30 | * @file |
| 31 | * Simple misc helper macros. |
| 32 | */ |
| 33 | |
| 34 | /** |
| 35 | * Compile-time computation of number of items in a hardcoded array. |
| 36 | * |
| 37 | * @param a the array being measured. |
| 38 | * @return the number of items hardcoded into the array. |
| 39 | */ |
| 40 | #ifndef ARRAY_LENGTH |
| 41 | #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) |
| 42 | #endif |
| 43 | |
Jon Cruz | d618f68 | 2015-06-15 15:37:09 -0700 | [diff] [blame^] | 44 | /** |
| 45 | * Returns the smaller of two values. |
| 46 | * |
| 47 | * @param x the first item to compare. |
| 48 | * @param y the second item to compare. |
| 49 | * @return the value that evaluates to lesser than the other. |
| 50 | */ |
| 51 | #ifndef MIN |
| 52 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) |
| 53 | #endif |
| 54 | |
Jon Cruz | 35b2eaa | 2015-06-15 15:37:08 -0700 | [diff] [blame] | 55 | #ifdef __cplusplus |
| 56 | } |
| 57 | #endif |
| 58 | |
| 59 | #endif /* WESTON_HELPERS_H */ |