/home/hillier_g/checkout/most4linux/libnetservices/include/linux/debug.h

00001 /*
00002  *  Copyright(c) Siemens AG, Muenchen, Germany, 2005, 2006, 2007
00003  *                           Bernhard Walle <bernhard.walle@gmx.de>
00004  *                           Gernot Hillier <gernot.hillier@siemens.com>
00005  *                           All rights reserved.
00006  *
00007  * ----------------------------------------------------------------------------
00008  * The contents of this file are subject to the Mozilla Public License
00009  * Version 1.1 (the "License"); you may not use this file except in
00010  * compliance with the License. You may obtain a copy of the License at
00011  * http://www.mozilla.org/MPL/
00012  * 
00013  * Software distributed under the License is distributed on an "AS IS"
00014  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
00015  * License for the specific language governing rights and limitations
00016  * under the License.
00017  *
00018  * The Original Code is Siemens code.
00019  * 
00020  * The Initial Developer of the Original Code is Siemens AG.
00021  * Portions created by the Initial Developer are Copyright (C) 2005-06
00022  * the Initial Developer. All Rights Reserved.
00023  * ----------------------------------------------------------------------------
00024  */
00025 #ifndef DEBUG_H
00026 #define DEBUG_H
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config/config.h>
00030 #endif
00031 
00032 #include <stdio.h>
00033 
00034 #if !defined(DOXYGEN) && (defined(DEBUG) || defined(TRACE))
00035 
00036 #if defined(__NetBSD__) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
00037 #define __DBG_FUNC__    __func__
00038 #elif defined(__GNUC__) && __GNUC__ >= 3
00039 #define __DBG_FUNC__    __FUNCTION__
00040 #else
00041 #define __DBG_FUNC__    "??"
00042 #endif
00043 
00044 #endif // !defined(DOXYGEN) && (defined(DEBUG) || defined(TRACE))
00045 
00046 
00047 #ifdef DEBUG
00048 #    define PRINT_DBG(fmt, ...) {                                               \
00049          fprintf(stderr, " DEBUG[%s:%d] %s(): "fmt"\n", __FILE__, __LINE__,     \
00050                 __DBG_FUNC__, ## __VA_ARGS__);                                  \
00051      }
00052 #    define PERR_DEBUG(msg)                                                     \
00053          do {                                                                   \
00054               char buffer[1024];                                                \
00055               snprintf(buffer, 1024, " PERROR [%s:%d] %s %s",                   \
00056                        __FILE__, __LINE__, __DBG_FUNC__, msg);                  \
00057               perror(buffer);                                                   \
00058          } while (0);
00059     
00060 #else  
00061 #    define PRINT_DBG(fmt, ...)   { do {} while(0); }
00062 #    define PERR_DEBUG(msg)       { do {} while(0); }
00063 #endif
00064 
00065 
00066 #ifdef TRACE
00067 #    define PRINT_TRACE(fmt, ...) {                                              \
00068          fprintf(stderr, "  TRACE[%s:%d] %s(): "fmt"\n", __FILE__, __LINE__,     \
00069                 __DBG_FUNC__, ## __VA_ARGS__);                                   \
00070      }
00071 #else  
00072 #    define PRINT_TRACE(fmt, ...)   { do {} while(0); }
00073 #endif
00074 
00075 #endif /* DEBUG_H */
00076 
00077 /* vim: set ts=4 et sw=4: */

Generated on Fri Mar 9 14:48:58 2007 for MOST Adaption Layer for Netservices Library by  doxygen 1.5.0