Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: include/core/SkTypes.h

Issue 1503423003: ubsan shift fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add cast to work around win compiler Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkFixed.h ('k') | src/core/SkBitmapProcState_matrixProcs.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkTypes_DEFINED 8 #ifndef SkTypes_DEFINED
9 #define SkTypes_DEFINED 9 #define SkTypes_DEFINED
10 10
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 static inline bool SkIsS16(long x) { 299 static inline bool SkIsS16(long x) {
300 return (int16_t)x == x; 300 return (int16_t)x == x;
301 } 301 }
302 302
303 /** Returns true if the value can be represented with unsigned 16bits 303 /** Returns true if the value can be represented with unsigned 16bits
304 */ 304 */
305 static inline bool SkIsU16(long x) { 305 static inline bool SkIsU16(long x) {
306 return (uint16_t)x == x; 306 return (uint16_t)x == x;
307 } 307 }
308 308
309 static inline int32_t SkLeftShift(int32_t value, int32_t shift) {
310 return (int32_t) ((uint32_t) value << shift);
311 }
312
313 static inline int64_t SkLeftShift(int64_t value, int32_t shift) {
314 return (int64_t) ((uint64_t) value << shift);
315 }
316
309 ////////////////////////////////////////////////////////////////////////////// 317 //////////////////////////////////////////////////////////////////////////////
310 318
311 /** Returns the number of entries in an array (not a pointer) */ 319 /** Returns the number of entries in an array (not a pointer) */
312 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N]; 320 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N];
313 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array))) 321 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array)))
314 322
315 // Can be used to bracket data types that must be dense, e.g. hash keys. 323 // Can be used to bracket data types that must be dense, e.g. hash keys.
316 #if defined(__clang__) // This should work on GCC too, but GCC diagnostic pop d idn't seem to work! 324 #if defined(__clang__) // This should work on GCC too, but GCC diagnostic pop d idn't seem to work!
317 #define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \ 325 #define SK_BEGIN_REQUIRE_DENSE _Pragma("GCC diagnostic push") \
318 _Pragma("GCC diagnostic error \"-Wpadded\"") 326 _Pragma("GCC diagnostic error \"-Wpadded\"")
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 private: 701 private:
694 void* fPtr; 702 void* fPtr;
695 size_t fSize; // can be larger than the requested size (see kReuse) 703 size_t fSize; // can be larger than the requested size (see kReuse)
696 uint32_t fStorage[(kSize + 3) >> 2]; 704 uint32_t fStorage[(kSize + 3) >> 2];
697 }; 705 };
698 // Can't guard the constructor because it's a template class. 706 // Can't guard the constructor because it's a template class.
699 707
700 #endif /* C++ */ 708 #endif /* C++ */
701 709
702 #endif 710 #endif
OLDNEW
« no previous file with comments | « include/core/SkFixed.h ('k') | src/core/SkBitmapProcState_matrixProcs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698