Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:43:33

0001 // Created on: 2012-01-19
0002 // Created by: Dmitry BOBYLEV 
0003 // Copyright (c) 2012-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _Standard_DefineAlloc_HeaderFile
0017 #define _Standard_DefineAlloc_HeaderFile
0018 
0019 // Macro to override new and delete operators for arrays.
0020 // Defined to empty for old SUN compiler
0021 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
0022 #  define DEFINE_STANDARD_ALLOC_ARRAY
0023 # else
0024 #  define DEFINE_STANDARD_ALLOC_ARRAY                                  \
0025    void* operator new[] (size_t theSize)                               \
0026    {                                                                   \
0027      return Standard::Allocate (theSize);                              \
0028    }                                                                   \
0029    void  operator delete[] (void* theAddress)                          \
0030    {                                                                   \
0031      Standard::Free (theAddress);                                      \
0032    }
0033 # endif
0034 
0035 // Macro to override placement new and placement delete operators. 
0036 // For Borland C and old SUN compilers do not define placement delete
0037 // as it is not supported.
0038 # if defined(__BORLANDC__) || (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530))
0039 #  define DEFINE_STANDARD_ALLOC_PLACEMENT                              \
0040    void* operator new (size_t, void* theAddress)                       \
0041    {                                                                   \
0042      return theAddress;                                                \
0043    }
0044 # else 
0045 #  define DEFINE_STANDARD_ALLOC_PLACEMENT                              \
0046    void* operator new (size_t, void* theAddress)                       \
0047    {                                                                   \
0048      return theAddress;                                                \
0049    }                                                                   \
0050    void operator delete (void*, void*)                                 \
0051    {                                                                   \
0052    }
0053 # endif
0054 
0055 // Macro to override operators new and delete to use OCC memory manager
0056 # define DEFINE_STANDARD_ALLOC                                         \
0057   void* operator new (size_t theSize)                                  \
0058   {                                                                    \
0059     return Standard::Allocate (theSize);                               \
0060   }                                                                    \
0061   void  operator delete (void* theAddress)                             \
0062   {                                                                    \
0063     Standard::Free (theAddress);                                       \
0064   }                                                                    \
0065   DEFINE_STANDARD_ALLOC_ARRAY                                          \
0066   DEFINE_STANDARD_ALLOC_PLACEMENT
0067 
0068 // Declare operator new in global scope for old sun compiler
0069 #ifndef WORKAROUND_SUNPRO_NEW_PLACEMENT
0070 #define WORKAROUND_SUNPRO_NEW_PLACEMENT
0071 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x420)
0072 inline void* operator new(size_t,void* anAddress) 
0073 {
0074   return anAddress;
0075 }
0076 #endif
0077 #endif
0078 
0079 //! @def STANDARD_ALIGNED(theAlignment, theType, theVar)
0080 //! Declare variable with memory alignment.
0081 //! @code
0082 //!   static const STANDARD_ALIGNED(8, char, THE_ARRAY)[] = {0xFF, 0xFE, 0xFA, 0xFB, 0xFF, 0x11, 0x22, 0x33};
0083 //! @endcode
0084 #if defined(_MSC_VER)
0085   #define STANDARD_ALIGNED(theAlignment, theType, theVar) __declspec(align(theAlignment)) theType theVar
0086 #elif defined(__GNUC__)
0087   #define STANDARD_ALIGNED(theAlignment, theType, theVar) theType __attribute__ ((aligned (theAlignment))) theVar
0088 #else
0089   #define STANDARD_ALIGNED(theAlignment, theType, theVar) theType theVar
0090 #endif
0091 
0092 #endif // _Standard_DefineAlloc_HeaderFile