rlog: common.h Source File

- Main Page
- Modules
- Classes
- Files
- Related Pages

# common.h

    00001 /*****************************************************************************
    00002  * Author:   Valient Gough <vgough@pobox.com>
    00003  *
    00004  *****************************************************************************
    00005  * Copyright (c) 2002-2004, Valient Gough
    00006  *
    00007  * This library is free software; you can distribute it and/or modify it under
    00008  * the terms of the GNU Lesser General Public License (LGPL), as published by
    00009  * the Free Software Foundation; either version 2.1 of the License, or (at your
    00010  * option) any later version.
    00011  *
    00012  * This library is distributed in the hope that it will be useful, but WITHOUT
    00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00014  * FITNESS FOR A PARTICULAR PURPOSE.  See the LGPL in the file COPYING for more
    00015  * details.
    00016  *
    00017  */
    00018
    00019 #ifndef _rlogconfig_incl_
    00020 #define _rlogconfig_incl_
    00021
    00027 /*
    00028     Defined by configure if our compiler allows us to specify printf attributes
    00029     on a function pointer..  Newer versions of GCC allow this, but older ones
    00030     do not..
    00031 */
    00032 #define HAVE_PRINTF_FP 1
    00033
    00034 /*
    00035     Defined by configure if our compiler understands VARIADAC macros.
    00036 */
    00037 #define C99_VARIADAC_MACROS 1
    00038 #define PREC99_VARIADAC_MACROS 1
    00039
    00040 #define RLOG_TIME_TSC 1
    00041
    00042 /*
    00043     We use __printf__ attribute to allow gcc to inspect printf style arguments
    00044     and give warnings if the rDebug(), rWarning(), etc macros are misused.
    00045
    00046     We use __builtin_expect on GCC 2.96 and above to allow optimization of
    00047     publication activation check.  We tell the compiler that the branch is
    00048     unlikely to occur, allowing GCC to push unecessary code out of the main
    00049     path.
    00050 */
    00051 #ifdef __GNUC__
    00052
    00053 # define PRINTF(FMT,X) __attribute__ (( __format__ ( __printf__, FMT, X)))
    00054 # define HAVE_PRINTF_ATTR 1
    00055
    00056 # if !defined( __builtin_expect )
    00057 #  define __builtin_expect(x,expected_value) (x)
    00058 # endif
    00059
    00060 # define   likely(x)  __builtin_expect((x),1)
    00061 # define unlikely(x)  __builtin_expect((x),0)
    00062
    00063 #else
    00064
    00065 // Not using the gcc compiler, make the macros do nothing..  They are
    00066 // documented as the last instance of the macros..
    00067
    00075 # define PRINTF(FMT,X)
    00076 # define HAVE_PRINTF_ATTR 0
    00077
    00079 # define   likely(x)  (x)
    00080
    00086 # define unlikely(x)  (x)
    00087
    00088 #endif
    00089
    00090 #if HAVE_PRINTF_FP
    00091 # define PRINTF_FP(FMT,X) PRINTF(FMT,X)
    00092 #else
    00093 # define PRINTF_FP(FMT,X)
    00094 #endif
    00095
    00104 #ifndef RLOG_COMPONENT
    00105 #  warning RLOG_COMPONENT not defined - setting to UNKNOWN
    00106 #define RLOG_COMPONENT "[unknown]"
    00107 #endif // RLOG_COMPONENT not defined
    00108
    00109 // Use somewhat unique names (doesn't matter if they aren't as they are used in
    00110 // a private context, so the compiler will make them unique if it must)
    00111 #  define LOGID CONCAT(_rL_, __LINE__)
    00112
    00113 #define RLOG_DECL
    00114
    00115 #endif // _rlogconfig_incl_
    00116