Artemy Kovalyov | e69018f | 2016-11-17 16:17:29 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2016 Mellanox Technologies Ltd. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. Neither the name of the copyright holder nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived from |
| 15 | * this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 23 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | #ifndef __IBVT_ENUM_H_ |
| 30 | #define __IBVT_ENUM_H_ |
| 31 | |
| 32 | /* :'<,'>s/\v(\S+),/DEF_ENUM_ELEM(\1) \\ */ |
| 33 | |
| 34 | #define DEF_ENUM_ELEM_TO_STR(elem) \ |
| 35 | if (x == elem) \ |
| 36 | return #elem; \ |
| 37 | else |
| 38 | |
| 39 | #define DEF_ENUM_TO_STR_BEGIN(type) \ |
| 40 | const char * type ## _str (enum type x) { |
| 41 | |
| 42 | #define DEF_ENUM_TO_STR_END \ |
| 43 | return "UNKNOWN"; \ |
| 44 | } |
| 45 | |
| 46 | #endif |
| 47 | |
| 48 | |