Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Global_Macros.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Global_Macros.h
00006  *
00007  *  $Id: Global_Macros.h,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Jesper S. M|ller<stophph@diku.dk>
00011  *  @author and a cast of thousands...
00012  *  @This one is split from the famous OS.h
00013  */
00014 //=============================================================================
00015 
00016 #ifndef ACE_GLOBAL_MACROS_H
00017 #define ACE_GLOBAL_MACROS_H
00018 
00019 #include "ace/pre.h"
00020 
00021 // Included just keep compilers that see #pragma dierctive first
00022 // happy.
00023 #include "ace/OS_Export.h"
00024 
00025 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00026 # pragma once
00027 #endif /* ACE_LACKS_PRAGMA_ONCE */
00028 
00029 // Start Global Macros
00030 # define ACE_BEGIN_DUMP ACE_LIB_TEXT ("\n====\n(%P|%t|%x)")
00031 # define ACE_END_DUMP ACE_LIB_TEXT ("====\n")
00032 
00033 # if defined (ACE_NDEBUG)
00034 #   define ACE_DB(X)
00035 # else
00036 #   define ACE_DB(X) X
00037 # endif /* ACE_NDEBUG */
00038 
00039 // ACE_NO_HEAP_CHECK macro can be used to suppress false report of
00040 // memory leaks. It turns off the built-in heap checking until the
00041 // block is left. The old state will then be restored Only used for
00042 // Win32 (in the moment).
00043 # if defined (ACE_WIN32)
00044 
00045 #   if defined (_DEBUG) && !defined (ACE_HAS_WINCE) && !defined (__BORLANDC__)
00046 # include /**/ <crtdbg.h>
00047 
00048 class ACE_OS_Export ACE_No_Heap_Check
00049 {
00050 public:
00051   ACE_No_Heap_Check (void)
00052     : old_state (_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG))
00053   { _CrtSetDbgFlag (old_state & ~_CRTDBG_ALLOC_MEM_DF);}
00054   ~ACE_No_Heap_Check (void) { _CrtSetDbgFlag (old_state);}
00055 private:
00056   int old_state;
00057 };
00058 #     define ACE_NO_HEAP_CHECK ACE_No_Heap_Check ____no_heap;
00059 #   else /* !_DEBUG */
00060 #     define ACE_NO_HEAP_CHECK
00061 #   endif /* _DEBUG */
00062 # else /* !ACE_WIN32 */
00063 #   define ACE_NO_HEAP_CHECK
00064 # endif /* ACE_WIN32 */
00065 
00066 // Turn a number into a string.
00067 # define ACE_ITOA(X) #X
00068 
00069 // Create a string of a server address with a "host:port" format.
00070 # define ACE_SERVER_ADDRESS(H,P) H":"P
00071 
00072 // A couple useful inline functions for checking whether bits are
00073 // enabled or disabled.
00074 
00075 // Efficiently returns the least power of two >= X...
00076 # define ACE_POW(X) (((X) == 0)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X)))
00077 # define ACE_EVEN(NUM) (((NUM) & 1) == 0)
00078 # define ACE_ODD(NUM) (((NUM) & 1) == 1)
00079 # define ACE_BIT_ENABLED(WORD, BIT) (((WORD) & (BIT)) != 0)
00080 # define ACE_BIT_DISABLED(WORD, BIT) (((WORD) & (BIT)) == 0)
00081 # define ACE_BIT_CMP_MASK(WORD, BIT, MASK) (((WORD) & (BIT)) == MASK)
00082 # define ACE_SET_BITS(WORD, BITS) (WORD |= (BITS))
00083 # define ACE_CLR_BITS(WORD, BITS) (WORD &= ~(BITS))
00084 
00085 # if !defined (ACE_ENDLESS_LOOP)
00086 #  define ACE_ENDLESS_LOOP
00087 # endif /* ! ACE_ENDLESS_LOOP */
00088 
00089 # if defined (ACE_NEEDS_FUNC_DEFINITIONS)
00090     // It just evaporated ;-)  Not pleasant.
00091 #   define ACE_UNIMPLEMENTED_FUNC(f)
00092 # else
00093 #   define ACE_UNIMPLEMENTED_FUNC(f) f;
00094 # endif /* ACE_NEEDS_FUNC_DEFINITIONS */
00095 
00096 // Easy way to designate that a class is used as a pseudo-namespace.
00097 // Insures that g++ "friendship" anamolies are properly handled.
00098 # define ACE_CLASS_IS_NAMESPACE(CLASSNAME) \
00099 private: \
00100 CLASSNAME (void); \
00101 CLASSNAME (const CLASSNAME&); \
00102 friend class ace_dewarn_gplusplus
00103 
00104 // ----------------------------------------------------------------
00105 
00106 # define ACE_TRACE_IMPL(X) ACE_Trace ____ (ACE_LIB_TEXT (X), __LINE__, ACE_LIB_TEXT (__FILE__))
00107 
00108 # if (ACE_NTRACE == 1)
00109 #   define ACE_TRACE(X)
00110 # else
00111 #   define ACE_TRACE(X) ACE_TRACE_IMPL(X)
00112 # endif /* ACE_NTRACE */
00113 
00114 // ----------------------------------------------------------------
00115 
00116 // Convenient macro for testing for deadlock, as well as for detecting
00117 // when mutexes fail.
00118 #define ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ACTION, REACTION) \
00119    ACE_Guard< MUTEX > OBJ (LOCK); \
00120    if (OBJ.locked () != 0) { ACTION; } \
00121    else { REACTION; }
00122 #define ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, REACTION) \
00123   ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ;, REACTION)
00124 #define ACE_GUARD(MUTEX, OBJ, LOCK) \
00125   ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return)
00126 #define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN) \
00127   ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return RETURN)
00128 # define ACE_WRITE_GUARD(MUTEX,OBJ,LOCK) \
00129   ACE_Write_Guard< MUTEX > OBJ (LOCK); \
00130     if (OBJ.locked () == 0) return;
00131 # define ACE_WRITE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
00132   ACE_Write_Guard< MUTEX > OBJ (LOCK); \
00133     if (OBJ.locked () == 0) return RETURN;
00134 # define ACE_READ_GUARD(MUTEX,OBJ,LOCK) \
00135   ACE_Read_Guard< MUTEX > OBJ (LOCK); \
00136     if (OBJ.locked () == 0) return;
00137 # define ACE_READ_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
00138   ACE_Read_Guard< MUTEX > OBJ (LOCK); \
00139     if (OBJ.locked () == 0) return RETURN;
00140 
00141 // ----------------------------------------------------------------
00142 
00143 # define ACE_DES_NOFREE(POINTER,CLASS) \
00144    do { \
00145         if (POINTER) \
00146           { \
00147             (POINTER)->~CLASS (); \
00148           } \
00149       } \
00150    while (0)
00151 
00152 # define ACE_DES_ARRAY_NOFREE(POINTER,SIZE,CLASS) \
00153    do { \
00154         if (POINTER) \
00155           { \
00156             for (size_t i = 0; \
00157                  i < SIZE; \
00158                  ++i) \
00159             { \
00160               (&(POINTER)[i])->~CLASS (); \
00161             } \
00162           } \
00163       } \
00164    while (0)
00165 
00166 # define ACE_DES_FREE(POINTER,DEALLOCATOR,CLASS) \
00167    do { \
00168         if (POINTER) \
00169           { \
00170             (POINTER)->~CLASS (); \
00171             DEALLOCATOR (POINTER); \
00172           } \
00173       } \
00174    while (0)
00175 
00176 # define ACE_DES_ARRAY_FREE(POINTER,SIZE,DEALLOCATOR,CLASS) \
00177    do { \
00178         if (POINTER) \
00179           { \
00180             for (size_t i = 0; \
00181                  i < SIZE; \
00182                  ++i) \
00183             { \
00184               (&(POINTER)[i])->~CLASS (); \
00185             } \
00186             DEALLOCATOR (POINTER); \
00187           } \
00188       } \
00189    while (0)
00190 
00191 # if defined (ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR)
00192 #   define ACE_DES_NOFREE_TEMPLATE(POINTER,T_CLASS,T_PARAMETER) \
00193      do { \
00194           if (POINTER) \
00195             { \
00196               (POINTER)->~T_CLASS (); \
00197             } \
00198         } \
00199      while (0)
00200 #   define ACE_DES_ARRAY_NOFREE_TEMPLATE(POINTER,SIZE,T_CLASS,T_PARAMETER) \
00201      do { \
00202           if (POINTER) \
00203             { \
00204               for (size_t i = 0; \
00205                    i < SIZE; \
00206                    ++i) \
00207               { \
00208                 (&(POINTER)[i])->~T_CLASS (); \
00209               } \
00210             } \
00211         } \
00212      while (0)
00213 #if defined(__IBMCPP__) && (__IBMCPP__ >= 400)
00214 #   define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
00215      do { \
00216           if (POINTER) \
00217             { \
00218               (POINTER)->~T_CLASS T_PARAMETER (); \
00219               DEALLOCATOR (POINTER); \
00220             } \
00221         } \
00222      while (0)
00223 #else
00224 #   define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
00225      do { \
00226           if (POINTER) \
00227             { \
00228               (POINTER)->~T_CLASS (); \
00229               DEALLOCATOR (POINTER); \
00230             } \
00231         } \
00232      while (0)
00233 #endif /* defined(__IBMCPP__) && (__IBMCPP__ >= 400) */
00234 #   define ACE_DES_ARRAY_FREE_TEMPLATE(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAMETER) \
00235      do { \
00236           if (POINTER) \
00237             { \
00238               for (size_t i = 0; \
00239                    i < SIZE; \
00240                    ++i) \
00241               { \
00242                 (&(POINTER)[i])->~T_CLASS (); \
00243               } \
00244               DEALLOCATOR (POINTER); \
00245             } \
00246         } \
00247      while (0)
00248 #if defined(__IBMCPP__) && (__IBMCPP__ >= 400)
00249 #   define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
00250      do { \
00251           if (POINTER) \
00252             { \
00253               (POINTER)->~T_CLASS <T_PARAM1, T_PARAM2> (); \
00254               DEALLOCATOR (POINTER); \
00255             } \
00256         } \
00257      while (0)
00258 #else
00259 #   define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
00260      do { \
00261           if (POINTER) \
00262             { \
00263               (POINTER)->~T_CLASS (); \
00264               DEALLOCATOR (POINTER); \
00265             } \
00266         } \
00267      while (0)
00268 #endif /* defined(__IBMCPP__) && (__IBMCPP__ >= 400) */
00269 #   define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \
00270      do { \
00271           if (POINTER) \
00272             { \
00273               (POINTER)->~T_CLASS (); \
00274               DEALLOCATOR (POINTER); \
00275             } \
00276         } \
00277      while (0)
00278 #   define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3, T_PARAM4) \
00279      do { \
00280           if (POINTER) \
00281             { \
00282               (POINTER)->~T_CLASS (); \
00283               DEALLOCATOR (POINTER); \
00284             } \
00285         } \
00286      while (0)
00287 #   define ACE_DES_ARRAY_FREE_TEMPLATE2(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
00288      do { \
00289           if (POINTER) \
00290             { \
00291               for (size_t i = 0; \
00292                    i < SIZE; \
00293                    ++i) \
00294               { \
00295                 (&(POINTER)[i])->~T_CLASS (); \
00296               } \
00297               DEALLOCATOR (POINTER); \
00298             } \
00299         } \
00300      while (0)
00301 # else /* ! ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR */
00302 #   define ACE_DES_NOFREE_TEMPLATE(POINTER,T_CLASS,T_PARAMETER) \
00303      do { \
00304           if (POINTER) \
00305             { \
00306               (POINTER)->T_CLASS T_PARAMETER::~T_CLASS (); \
00307             } \
00308         } \
00309      while (0)
00310 #   define ACE_DES_ARRAY_NOFREE_TEMPLATE(POINTER,SIZE,T_CLASS,T_PARAMETER) \
00311      do { \
00312           if (POINTER) \
00313             { \
00314               for (size_t i = 0; \
00315                    i < SIZE; \
00316                    ++i) \
00317               { \
00318                 (POINTER)[i].T_CLASS T_PARAMETER::~T_CLASS (); \
00319               } \
00320             } \
00321         } \
00322      while (0)
00323 #   if defined (__Lynx__) && __LYNXOS_SDK_VERSION == 199701L
00324   // LynxOS 3.0.0's g++ has trouble with the real versions of these.
00325 #     define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER)
00326 #     define ACE_DES_ARRAY_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER)
00327 #     define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2)
00328 #     define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2)
00329 #     define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2)
00330 #     define ACE_DES_ARRAY_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2)
00331 #   else
00332 #     define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
00333        do { \
00334             if (POINTER) \
00335               { \
00336                 POINTER->T_CLASS T_PARAMETER::~T_CLASS (); \
00337                 DEALLOCATOR (POINTER); \
00338               } \
00339           } \
00340        while (0)
00341 #     define ACE_DES_ARRAY_FREE_TEMPLATE(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAMETER) \
00342        do { \
00343             if (POINTER) \
00344               { \
00345                 for (size_t i = 0; \
00346                      i < SIZE; \
00347                      ++i) \
00348                 { \
00349                   POINTER[i].T_CLASS T_PARAMETER::~T_CLASS (); \
00350                 } \
00351                 DEALLOCATOR (POINTER); \
00352               } \
00353           } \
00354        while (0)
00355 #     define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
00356        do { \
00357             if (POINTER) \
00358               { \
00359                 POINTER->T_CLASS <T_PARAM1, T_PARAM2>::~T_CLASS (); \
00360                 DEALLOCATOR (POINTER); \
00361               } \
00362           } \
00363        while (0)
00364 #     define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \
00365        do { \
00366             if (POINTER) \
00367               { \
00368                 POINTER->T_CLASS <T_PARAM1, T_PARAM2, T_PARAM3>::~T_CLASS (); \
00369                 DEALLOCATOR (POINTER); \
00370               } \
00371           } \
00372        while (0)
00373 #     define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3,T_PARAM4) \
00374        do { \
00375             if (POINTER) \
00376               { \
00377                 POINTER->T_CLASS <T_PARAM1, T_PARAM2, T_PARAM3, T_PARAM4>::~T_CLASS (); \
00378                 DEALLOCATOR (POINTER); \
00379               } \
00380           } \
00381        while (0)
00382 #     define ACE_DES_ARRAY_FREE_TEMPLATE2(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
00383        do { \
00384             if (POINTER) \
00385               { \
00386                 for (size_t i = 0; \
00387                      i < SIZE; \
00388                      ++i) \
00389                 { \
00390                   POINTER[i].T_CLASS <T_PARAM1, T_PARAM2>::~T_CLASS (); \
00391                 } \
00392                 DEALLOCATOR (POINTER); \
00393               } \
00394           } \
00395        while (0)
00396 #   endif /* defined (__Lynx__) && __LYNXOS_SDK_VERSION == 199701L */
00397 # endif /* defined ! ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR */
00398 
00399 #include "ace/post.h"
00400 
00401 #endif /*ACE_GLOBAL_MACROS_H*/

Generated on Mon Jun 16 11:19:45 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002