1 // Created on: 2012-01-19
2 // Created by: Dmitry BOBYLEV
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Standard_DefineAlloc_HeaderFile
17 #define _Standard_DefineAlloc_HeaderFile
19 // Macro to override new and delete operators for arrays.
20 // Defined to empty for old SUN compiler
21 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
22 # define DEFINE_STANDARD_ALLOC_ARRAY
24 # define DEFINE_STANDARD_ALLOC_ARRAY \
25 void* operator new[] (size_t theSize) \
27 return Standard::Allocate (theSize); \
29 void operator delete[] (void* theAddress) \
31 Standard::Free (theAddress); \
35 // Macro to override placement new and placement delete operators.
36 // For Borland C and old SUN compilers do not define placement delete
37 // as it is not supported.
38 # if defined(__BORLANDC__) || (defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530))
39 # define DEFINE_STANDARD_ALLOC_PLACEMENT \
40 void* operator new (size_t, void* theAddress) \
45 # define DEFINE_STANDARD_ALLOC_PLACEMENT \
46 void* operator new (size_t, void* theAddress) \
50 void operator delete (void*, void*) \
55 // Macro to override operators new and delete to use OCC memory manager
56 # define DEFINE_STANDARD_ALLOC \
57 void* operator new (size_t theSize) \
59 return Standard::Allocate (theSize); \
61 void operator delete (void* theAddress) \
63 Standard::Free (theAddress); \
65 DEFINE_STANDARD_ALLOC_ARRAY \
66 DEFINE_STANDARD_ALLOC_PLACEMENT
68 // Declare operator new in global scope for old sun compiler
69 #ifndef WORKAROUND_SUNPRO_NEW_PLACEMENT
70 #define WORKAROUND_SUNPRO_NEW_PLACEMENT
71 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x420)
72 inline void* operator new(size_t,void* anAddress)
79 //! @def STANDARD_ALIGNED(theAlignment, theType, theVar)
80 //! Declare variable with memory alignment.
82 //! static const STANDARD_ALIGNED(8, char, THE_ARRAY)[] = {0xFF, 0xFE, 0xFA, 0xFB, 0xFF, 0x11, 0x22, 0x33};
85 #define STANDARD_ALIGNED(theAlignment, theType, theVar) __declspec(align(theAlignment)) theType theVar
86 #elif defined(__GNUC__)
87 #define STANDARD_ALIGNED(theAlignment, theType, theVar) theType __attribute__ ((aligned (theAlignment))) theVar
89 #define STANDARD_ALIGNED(theAlignment, theType, theVar) theType theVar
92 #endif // _Standard_DefineAlloc_HeaderFile