Loading include/cutils/native_handle.h +7 −0 Original line number Diff line number Diff line Loading @@ -26,7 +26,14 @@ typedef struct native_handle int version; /* sizeof(native_handle_t) */ int numFds; /* number of file-descriptors at &data[0] */ int numInts; /* number of ints at &data[numFds] */ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wzero-length-array" #endif int data[0]; /* numFds + numInts ints */ #if defined(__clang__) #pragma clang diagnostic pop #endif } native_handle_t; /* Loading include/utils/Flattenable.h +8 −8 Original line number Diff line number Diff line Loading @@ -31,32 +31,32 @@ namespace android { class FlattenableUtils { public: template<int N> template<size_t N> static size_t align(size_t size) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); return (size + (N-1)) & ~(N-1); } template<int N> template<size_t N> static size_t align(void const*& buffer) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); intptr_t b = intptr_t(buffer); buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1)); return size_t(intptr_t(buffer) - b); uintptr_t b = uintptr_t(buffer); buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1)); return size_t(uintptr_t(buffer) - b); } template<int N> template<size_t N> static size_t align(void*& buffer) { return align<N>( const_cast<void const*&>(buffer) ); } static void advance(void*& buffer, size_t& size, size_t offset) { buffer = reinterpret_cast<void*>( intptr_t(buffer) + offset ); buffer = reinterpret_cast<void*>( uintptr_t(buffer) + offset ); size -= offset; } static void advance(void const*& buffer, size_t& size, size_t offset) { buffer = reinterpret_cast<void const*>( intptr_t(buffer) + offset ); buffer = reinterpret_cast<void const*>( uintptr_t(buffer) + offset ); size -= offset; } Loading include/utils/KeyedVector.h +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ template<typename KEY, typename VALUE> inline VALUE& KeyedVector<KEY,VALUE>::editValueFor(const KEY& key) { ssize_t i = this->indexOfKey(key); LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); return mVector.editItemAt(i).value; return mVector.editItemAt(static_cast<size_t>(i)).value; } template<typename KEY, typename VALUE> inline Loading include/utils/RefBase.h +13 −1 Original line number Diff line number Diff line Loading @@ -206,17 +206,29 @@ inline bool operator _op_ (const U* o) const { \ // --------------------------------------------------------------------------- // RefererenceRenamer is pure abstract, there is no virtual method // implementation to put in a translation unit in order to silence the // weak vtables warning. #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wweak-vtables" #endif class ReferenceRenamer { protected: // destructor is purposedly not virtual so we avoid code overhead from // subclasses; we have to make it protected to guarantee that it // cannot be called from this base class (and to make strict compilers // happy). ~ReferenceRenamer(); ~ReferenceRenamer() { } public: virtual void operator()(size_t i) const = 0; }; #if defined(__clang__) #pragma clang diagnostic pop #endif // --------------------------------------------------------------------------- class RefBase Loading include/utils/TypeHelpers.h +15 −10 Original line number Diff line number Diff line Loading @@ -151,17 +151,22 @@ void destroy_type(TYPE* p, size_t n) { } } template<typename TYPE> inline void copy_type(TYPE* d, const TYPE* s, size_t n) { if (!traits<TYPE>::has_trivial_copy) { template<typename TYPE> typename std::enable_if<traits<TYPE>::has_trivial_copy>::type inline copy_type(TYPE* d, const TYPE* s, size_t n) { memcpy(d,s,n*sizeof(TYPE)); } template<typename TYPE> typename std::enable_if<!traits<TYPE>::has_trivial_copy>::type inline copy_type(TYPE* d, const TYPE* s, size_t n) { while (n > 0) { n--; new(d) TYPE(*s); d++, s++; } } else { memcpy(d,s,n*sizeof(TYPE)); } } template<typename TYPE> inline Loading Loading
include/cutils/native_handle.h +7 −0 Original line number Diff line number Diff line Loading @@ -26,7 +26,14 @@ typedef struct native_handle int version; /* sizeof(native_handle_t) */ int numFds; /* number of file-descriptors at &data[0] */ int numInts; /* number of ints at &data[numFds] */ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wzero-length-array" #endif int data[0]; /* numFds + numInts ints */ #if defined(__clang__) #pragma clang diagnostic pop #endif } native_handle_t; /* Loading
include/utils/Flattenable.h +8 −8 Original line number Diff line number Diff line Loading @@ -31,32 +31,32 @@ namespace android { class FlattenableUtils { public: template<int N> template<size_t N> static size_t align(size_t size) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); return (size + (N-1)) & ~(N-1); } template<int N> template<size_t N> static size_t align(void const*& buffer) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); intptr_t b = intptr_t(buffer); buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1)); return size_t(intptr_t(buffer) - b); uintptr_t b = uintptr_t(buffer); buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1)); return size_t(uintptr_t(buffer) - b); } template<int N> template<size_t N> static size_t align(void*& buffer) { return align<N>( const_cast<void const*&>(buffer) ); } static void advance(void*& buffer, size_t& size, size_t offset) { buffer = reinterpret_cast<void*>( intptr_t(buffer) + offset ); buffer = reinterpret_cast<void*>( uintptr_t(buffer) + offset ); size -= offset; } static void advance(void const*& buffer, size_t& size, size_t offset) { buffer = reinterpret_cast<void const*>( intptr_t(buffer) + offset ); buffer = reinterpret_cast<void const*>( uintptr_t(buffer) + offset ); size -= offset; } Loading
include/utils/KeyedVector.h +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ template<typename KEY, typename VALUE> inline VALUE& KeyedVector<KEY,VALUE>::editValueFor(const KEY& key) { ssize_t i = this->indexOfKey(key); LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); return mVector.editItemAt(i).value; return mVector.editItemAt(static_cast<size_t>(i)).value; } template<typename KEY, typename VALUE> inline Loading
include/utils/RefBase.h +13 −1 Original line number Diff line number Diff line Loading @@ -206,17 +206,29 @@ inline bool operator _op_ (const U* o) const { \ // --------------------------------------------------------------------------- // RefererenceRenamer is pure abstract, there is no virtual method // implementation to put in a translation unit in order to silence the // weak vtables warning. #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wweak-vtables" #endif class ReferenceRenamer { protected: // destructor is purposedly not virtual so we avoid code overhead from // subclasses; we have to make it protected to guarantee that it // cannot be called from this base class (and to make strict compilers // happy). ~ReferenceRenamer(); ~ReferenceRenamer() { } public: virtual void operator()(size_t i) const = 0; }; #if defined(__clang__) #pragma clang diagnostic pop #endif // --------------------------------------------------------------------------- class RefBase Loading
include/utils/TypeHelpers.h +15 −10 Original line number Diff line number Diff line Loading @@ -151,17 +151,22 @@ void destroy_type(TYPE* p, size_t n) { } } template<typename TYPE> inline void copy_type(TYPE* d, const TYPE* s, size_t n) { if (!traits<TYPE>::has_trivial_copy) { template<typename TYPE> typename std::enable_if<traits<TYPE>::has_trivial_copy>::type inline copy_type(TYPE* d, const TYPE* s, size_t n) { memcpy(d,s,n*sizeof(TYPE)); } template<typename TYPE> typename std::enable_if<!traits<TYPE>::has_trivial_copy>::type inline copy_type(TYPE* d, const TYPE* s, size_t n) { while (n > 0) { n--; new(d) TYPE(*s); d++, s++; } } else { memcpy(d,s,n*sizeof(TYPE)); } } template<typename TYPE> inline Loading