From: John Hodge Date: Sun, 8 Jun 2014 13:23:51 +0000 (+0800) Subject: Usermode/libc++ - Override allocators to remove placement new call for primitive... X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=3a277e214a7bb9977143bf5ac3c8f623c1037319;p=tpg%2Facess2.git Usermode/libc++ - Override allocators to remove placement new call for primitive types --- diff --git a/Usermode/Libraries/libc++.so_src/include_exp/allocator b/Usermode/Libraries/libc++.so_src/include_exp/allocator index 6057eb3d..0ed1bcde 100644 --- a/Usermode/Libraries/libc++.so_src/include_exp/allocator +++ b/Usermode/Libraries/libc++.so_src/include_exp/allocator @@ -16,7 +16,12 @@ namespace std { -template class allocator +template class allocator; + +namespace _bits { + +template +class allocator_real { public: typedef T value_type; @@ -33,14 +38,14 @@ public: typedef allocator other; }; - allocator() throw() { + allocator_real() throw() { } - allocator(const allocator& alloc __attribute__((unused))) throw() { + allocator_real(const allocator_real& alloc __attribute__((unused))) throw() { } template - allocator(const allocator& alloc) throw() { + allocator_real(const allocator_real& alloc) throw() { } - ~allocator() throw() { + ~allocator_real() throw() { } pointer address(reference x) const { @@ -75,6 +80,87 @@ public: } }; +template +class allocator_noconstruct: + public ::std::_bits::allocator_real +{ +public: +/* + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef const T* const_pointer; + typedef const T& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + template + struct rebind + { + typedef allocator other; + }; + + allocator_noconstruct() throw() { + } + allocator_noconstruct(const allocator_noconstruct& alloc __attribute__((unused))) throw() { + } + template + allocator_noconstruct(const allocator_noconstruct& alloc) throw() { + } + ~allocator_noconstruct() throw() { + } + + pointer address(reference x) const { + return &x; + } + const_pointer address(const_reference x) const { + return &x; + } + pointer allocate(size_type n, const void* hint=0) { + hint = hint; + return static_cast( ::operator new (n * sizeof(value_type)) ); + } + void deallocate(pointer p, size_type n) { + n=n; + ::operator delete(p); + } + size_type max_size() { + return ((size_type)-1) / sizeof(value_type); + } +*/ + + void construct( typename allocator_real::pointer p, typename allocator_real::const_reference val ) { + *p = val; + } + // C++11 + #if _CXX11_AVAIL + template + void construct( U* p, Args&&... args ) { + } + #endif + void destroy(typename allocator_real::pointer p) { + } +}; + +}; + +template +class allocator: + public _bits::allocator_real +{ +}; + +template <> +class allocator: + public _bits::allocator_noconstruct +{ +}; +template <> +class allocator: + public _bits::allocator_noconstruct +{ +}; + }; #endif