(file) Return to PegasusAssert.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 martin 1.11 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.12 //
  3 martin 1.11 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.12 //
 10 martin 1.11 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.12 //
 17 martin 1.11 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.12 //
 20 martin 1.11 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.12 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.11 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.12 //
 28 martin 1.11 //////////////////////////////////////////////////////////////////////////
 29 jim.wunderlich 1.1  //
 30                     //%/////////////////////////////////////////////////////////////////////////////
 31                     #ifndef Pegasus_Assert_h
 32                     #define Pegasus_Assert_h
 33                     
 34 thilo.boehm    1.10 #ifdef PEGASUS_OS_ZOS
 35                       // zOS specific implementation of assert macros.
 36                     # include <Pegasus/Common/PegasusAssertZOS.h>
 37 kumpf          1.7  
 38 kumpf          1.13 #else
 39 kumpf          1.7  // NOTE:
 40 jim.wunderlich 1.2  //
 41 thilo.boehm    1.10 //  This is the common implementation for the assert macros.
 42 kumpf          1.13 //  If platform specific implementation are needed they have to
 43 thilo.boehm    1.10 //  be placed in a platform specific include file and included before.
 44                     //
 45 kumpf          1.7  // All built and tested OK with <assert.h>
 46 jim.wunderlich 1.2  // but <cassert> is more appropriate for c++ files
 47 kumpf          1.7  // however if this should be a problem for any c fileswithin the tree
 48                     // it is possible to revert back to assert.h
 49 jim.wunderlich 1.2  //     J Wunderlich 11/21/2005
 50                     //
 51 jim.wunderlich 1.4  
 52                     #if (__cplusplus)
 53 jim.wunderlich 1.2  #include <cassert>
 54 jim.wunderlich 1.4  #else
 55                     #include <assert.h>
 56                     #endif
 57 jim.wunderlich 1.1  
 58 jim.wunderlich 1.3  /** define PEGASUS_ASSERT assertion statement.  This statement tests the
 59                         condition defined by the parameters and if not True executes an
 60                     
 61 kumpf          1.7     It only generates code if NDEBUG is not defined.
 62 jim.wunderlich 1.3     See also the man page for assert().
 63                     
 64 kumpf          1.7     NOTE: if NDEBUG is set then the assert() macro will generate no code,
 65                              and hence do nothing at all.
 66 jim.wunderlich 1.3  
 67                         <pre>
 68                         assert()
 69                         </pre>
 70                     
 71                         defining the file, line and condition that was tested.
 72                     */
 73                     
 74 marek          1.9  #define PEGASUS_ASSERT(COND) assert(COND)
 75                     
 76 jim.wunderlich 1.1  
 77                     /* define PEGASUS_DEBUG_ASSERT() assertion statement. This statement tests the
 78 kumpf          1.7     condition defined by the parameters and if not True executes an assert.
 79 jim.wunderlich 1.1     It only generates code if PEGASUS_DEBUG is defined and NDEBUG is not
 80 kumpf          1.7     defined.
 81 jim.wunderlich 1.1     See also the man page for assert().
 82                     
 83 kumpf          1.7     NOTE: if NDEBUG is set then the assert() macro will generate no code,
 84                              and hence do nothing at all.
 85 jim.wunderlich 1.1  
 86                     */
 87                     
 88                     #ifdef PEGASUS_DEBUG
 89 marek          1.9  # define PEGASUS_DEBUG_ASSERT(COND) assert(COND)
 90 jim.wunderlich 1.1  #else
 91 kumpf          1.7  # define PEGASUS_DEBUG_ASSERT(COND)
 92 jim.wunderlich 1.1  #endif
 93                     
 94                     
 95 kumpf          1.7  #define PEGASUS_TEST_ASSERT(COND)                                         \
 96                         do                                                                    \
 97                         {                                                                     \
 98                             if (!(COND))                                                      \
 99                             {                                                                 \
100                                 printf("PEGASUS_TEST_ASSERT failed in file %s at line %d\n",  \
101                                     __FILE__, __LINE__);                                      \
102                                 abort();                                                      \
103                             }                                                                 \
104                         } while (0)
105 jim.wunderlich 1.2  
106 thilo.boehm    1.10 # endif /* Common Pegasus Assert implementation */
107 jim.wunderlich 1.1  #endif  /* Pegasus_Assert_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2