![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 /* 00002 Copyright 2005-2010 Intel Corporation. All Rights Reserved. 00003 00004 This file is part of Threading Building Blocks. 00005 00006 Threading Building Blocks is free software; you can redistribute it 00007 and/or modify it under the terms of the GNU General Public License 00008 version 2 as published by the Free Software Foundation. 00009 00010 Threading Building Blocks is distributed in the hope that it will be 00011 useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00012 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with Threading Building Blocks; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 As a special exception, you may use this file as part of a free software 00020 library without restriction. Specifically, if other files instantiate 00021 templates or use macros or inline functions from this file, or you compile 00022 this file and link it with other files to produce an executable, this 00023 file does not by itself cause the resulting executable to be covered by 00024 the GNU General Public License. This exception does not however 00025 invalidate any other reasons why the executable file might be covered by 00026 the GNU General Public License. 00027 */ 00028 00029 #ifndef __TBB_scalable_allocator_H 00030 #define __TBB_scalable_allocator_H 00031 00033 #include <stddef.h> /* Need ptrdiff_t and size_t from here. */ 00034 00035 #if !defined(__cplusplus) && __ICC==1100 00036 #pragma warning (push) 00037 #pragma warning (disable: 991) 00038 #endif 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif /* __cplusplus */ 00043 00044 #if _MSC_VER >= 1400 00045 #define __TBB_EXPORTED_FUNC __cdecl 00046 #else 00047 #define __TBB_EXPORTED_FUNC 00048 #endif 00049 00052 void * __TBB_EXPORTED_FUNC scalable_malloc (size_t size); 00053 00056 void __TBB_EXPORTED_FUNC scalable_free (void* ptr); 00057 00060 void * __TBB_EXPORTED_FUNC scalable_realloc (void* ptr, size_t size); 00061 00064 void * __TBB_EXPORTED_FUNC scalable_calloc (size_t nobj, size_t size); 00065 00068 int __TBB_EXPORTED_FUNC scalable_posix_memalign (void** memptr, size_t alignment, size_t size); 00069 00072 void * __TBB_EXPORTED_FUNC scalable_aligned_malloc (size_t size, size_t alignment); 00073 00076 void * __TBB_EXPORTED_FUNC scalable_aligned_realloc (void* ptr, size_t size, size_t alignment); 00077 00080 void __TBB_EXPORTED_FUNC scalable_aligned_free (void* ptr); 00081 00086 size_t __TBB_EXPORTED_FUNC scalable_msize (void* ptr); 00087 00088 #ifdef __cplusplus 00089 } /* extern "C" */ 00090 #endif /* __cplusplus */ 00091 00092 #ifdef __cplusplus 00093 00094 #include <new> /* To use new with the placement argument */ 00095 00096 /* Ensure that including this header does not cause implicit linkage with TBB */ 00097 #ifndef __TBB_NO_IMPLICIT_LINKAGE 00098 #define __TBB_NO_IMPLICIT_LINKAGE 1 00099 #include "tbb_stddef.h" 00100 #undef __TBB_NO_IMPLICIT_LINKAGE 00101 #else 00102 #include "tbb_stddef.h" 00103 #endif 00104 00105 00106 namespace tbb { 00107 00108 #if _MSC_VER && !defined(__INTEL_COMPILER) 00109 // Workaround for erroneous "unreferenced parameter" warning in method destroy. 00110 #pragma warning (push) 00111 #pragma warning (disable: 4100) 00112 #endif 00113 00115 00118 template<typename T> 00119 class scalable_allocator { 00120 public: 00121 typedef typename internal::allocator_type<T>::value_type value_type; 00122 typedef value_type* pointer; 00123 typedef const value_type* const_pointer; 00124 typedef value_type& reference; 00125 typedef const value_type& const_reference; 00126 typedef size_t size_type; 00127 typedef ptrdiff_t difference_type; 00128 template<class U> struct rebind { 00129 typedef scalable_allocator<U> other; 00130 }; 00131 00132 scalable_allocator() throw() {} 00133 scalable_allocator( const scalable_allocator& ) throw() {} 00134 template<typename U> scalable_allocator(const scalable_allocator<U>&) throw() {} 00135 00136 pointer address(reference x) const {return &x;} 00137 const_pointer address(const_reference x) const {return &x;} 00138 00140 pointer allocate( size_type n, const void* /*hint*/ =0 ) { 00141 return static_cast<pointer>( scalable_malloc( n * sizeof(value_type) ) ); 00142 } 00143 00145 void deallocate( pointer p, size_type ) { 00146 scalable_free( p ); 00147 } 00148 00150 size_type max_size() const throw() { 00151 size_type absolutemax = static_cast<size_type>(-1) / sizeof (value_type); 00152 return (absolutemax > 0 ? absolutemax : 1); 00153 } 00154 void construct( pointer p, const value_type& value ) {::new((void*)(p)) value_type(value);} 00155 void destroy( pointer p ) {p->~value_type();} 00156 }; 00157 00158 #if _MSC_VER && !defined(__INTEL_COMPILER) 00159 #pragma warning (pop) 00160 #endif // warning 4100 is back 00161 00163 00164 template<> 00165 class scalable_allocator<void> { 00166 public: 00167 typedef void* pointer; 00168 typedef const void* const_pointer; 00169 typedef void value_type; 00170 template<class U> struct rebind { 00171 typedef scalable_allocator<U> other; 00172 }; 00173 }; 00174 00175 template<typename T, typename U> 00176 inline bool operator==( const scalable_allocator<T>&, const scalable_allocator<U>& ) {return true;} 00177 00178 template<typename T, typename U> 00179 inline bool operator!=( const scalable_allocator<T>&, const scalable_allocator<U>& ) {return false;} 00180 00181 } // namespace tbb 00182 00183 #if _MSC_VER 00184 #if __TBB_BUILD && !defined(__TBBMALLOC_NO_IMPLICIT_LINKAGE) 00185 #define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1 00186 #endif 00187 00188 #if !__TBBMALLOC_NO_IMPLICIT_LINKAGE 00189 #ifdef _DEBUG 00190 #pragma comment(lib, "tbbmalloc_debug.lib") 00191 #else 00192 #pragma comment(lib, "tbbmalloc.lib") 00193 #endif 00194 #endif 00195 00196 00197 #endif 00198 00199 #endif /* __cplusplus */ 00200 00201 #if !defined(__cplusplus) && __ICC==1100 00202 #pragma warning (pop) 00203 #endif // ICC 11.0 warning 991 is back 00204 00205 #endif /* __TBB_scalable_allocator_H */
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.