ROHC compression/decompression library
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 2 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * This program is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 * GNU General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU General Public License 00013 * along with this program; if not, write to the Free Software 00014 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00015 */ 00016 00017 /** 00018 * @file rohc_traces.h 00019 * @brief ROHC macros for traces 00020 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00021 */ 00022 00023 #ifndef ROHC_TRACES_H 00024 #define ROHC_TRACES_H 00025 00026 #include <stdio.h> 00027 #include <assert.h> 00028 #include "config.h" /* for ROHC_DEBUG_LEVEL */ 00029 00030 /// @brief Print information depending on the debug level and prefixed 00031 /// with the function name 00032 #define rohc_debugf(level, format, ...) \ 00033 rohc_debugf_(level, "%s[%s:%d %s()] " format, \ 00034 (level == 0 ? "[ERROR] " : ""), \ 00035 __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__) 00036 00037 /// Print information depending on the debug level 00038 #define rohc_debugf_(level, format, ...) \ 00039 do { \ 00040 if((level) <= ROHC_DEBUG_LEVEL) { \ 00041 printf(format, ##__VA_ARGS__); \ 00042 } \ 00043 } while(0) 00044 00045 /** 00046 * @brief Stop processing if the given condition is false 00047 * 00048 * In non-debug mode (ie. NDEBUG set): if the given condition fails, prints 00049 * the given message then jump to the given label. 00050 * 00051 * In debug mode (ie. NDEBUG not set): if the given condition fails, prints 00052 * the given message then asserts. 00053 */ 00054 #define rohc_assert(condition, label, format, ...) \ 00055 do { \ 00056 if(!(condition)) { \ 00057 rohc_debugf(0, format "\n", ##__VA_ARGS__); \ 00058 assert(condition); \ 00059 goto label; \ 00060 } \ 00061 } while(0) 00062 00063 00064 #endif 00065