/**********************\************************************************* * * Copyright (C) 2006 Novell, Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; version 2.1 * of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, Novell, Inc. * * To contact Novell about this file by physical or electronic mail, * you may find current contact information at www.novell.com. * * Author: Juan Carlos Luciani * ***********************************************************************/ #ifndef _IPCINT_ #define _IPCINT_ //===[ Include files ]===================================================== #include #include #include #include #include using namespace std; extern "C" { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Ensure that NDEBUG is defined for release builds! #include } //===[ External data ]===================================================== extern int DebugLevel; extern bool UseSyslog; extern char *pAppName; extern pthread_mutex_t interlockedMutex; //===[ Macro definitions ]================================================= // // DbgTrace macro define // #define MAX_FORMAT_STRING_LEN 1024 #define DbgTrace(LEVEL, X, Y) { \ if (LEVEL == 0) { \ char *pFormatString = new char[MAX_FORMAT_STRING_LEN]; \ if (pFormatString) { \ snprintf(pFormatString, MAX_FORMAT_STRING_LEN, X, Y); \ if (UseSyslog) \ syslog(LOG_USER | LOG_INFO, "%s -%s", pAppName, pFormatString); \ else \ fprintf(stderr, "%s -%s", pAppName, pFormatString); \ delete[] pFormatString; \ } \ } else if (DebugLevel >= LEVEL) { \ char *pFormatString = new char[MAX_FORMAT_STRING_LEN]; \ if (pFormatString) { \ snprintf(pFormatString, MAX_FORMAT_STRING_LEN, X, Y); \ if (UseSyslog) \ syslog(LOG_USER | LOG_DEBUG, "%s -%s", pAppName, pFormatString); \ else \ fprintf(stderr, "%s -%s", pAppName, pFormatString); \ delete[] pFormatString; \ } \ } \ } // // Interlocked Increment and Decrement macros // // Well, kind of interlocked :-). // __inline static unsigned long InterlockedIncrement(unsigned long *pValue) { pthread_mutex_lock(&interlockedMutex); *pValue ++; pthread_mutex_unlock(&interlockedMutex); } __inline static unsigned long InterlockedDecrement(unsigned long *pValue) { pthread_mutex_lock(&interlockedMutex); *pValue --; pthread_mutex_unlock(&interlockedMutex); } __inline static uint32_t InterlockedIncrement(uint32_t *pValue) { pthread_mutex_lock(&interlockedMutex); *pValue ++; pthread_mutex_unlock(&interlockedMutex); } __inline static uint32_t InterlockedDecrement(uint32_t *pValue) { pthread_mutex_lock(&interlockedMutex); *pValue --; pthread_mutex_unlock(&interlockedMutex); } //===[ Include files ]===================================================== #include "smartptr.h" #include "channelproto.h" //===[ External prototypes ]=============================================== //===[ Manifest constants ]================================================ //===[ Type definitions ]================================================== //===[ Function prototypes ]=============================================== #endif // _IPCINT_ //========================================================================= //=========================================================================