Skip to content

Commit

Permalink
Merge tag 'android-7.1.1_r4' into cm-14.1
Browse files Browse the repository at this point in the history
Android 7.1.1 release 4

# gpg: Signature made Thu Dec  1 13:07:01 2016 CST
# gpg:                using DSA key E8AD3F819AB10E78
# gpg: Can't check signature: No public key
  • Loading branch information
invisiblek committed Dec 6, 2016
2 parents 6da8bae + e9f90a2 commit 1be5c83
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/core/SkRefCnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,37 @@ class SK_API SkRefCnt : public SkRefCntBase { };
null in on each side of the assignment, and ensuring that ref() is called
before unref(), in case the two pointers point to the same object.
*/

#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) || defined(SK_DEBUG)
// This version heuristically detects data races, since those otherwise result
// in redundant reference count decrements, which are exceedingly
// difficult to debug.

#define SkRefCnt_SafeAssign(dst, src) \
do { \
typedef typename std::remove_reference<decltype(dst)>::type \
SkRefCntPtrT; \
SkRefCntPtrT old_dst = *const_cast<SkRefCntPtrT volatile *>(&dst); \
if (src) src->ref(); \
if (old_dst) old_dst->unref(); \
if (old_dst != *const_cast<SkRefCntPtrT volatile *>(&dst)) { \
SkDebugf("Detected racing Skia calls at %s:%d\n", \
__FILE__, __LINE__); \
} \
dst = src; \
} while (0)

#else /* !(SK_BUILD_FOR_ANDROID_FRAMEWORK || SK_DEBUG) */

#define SkRefCnt_SafeAssign(dst, src) \
do { \
if (src) src->ref(); \
if (dst) dst->unref(); \
dst = src; \
} while (0)

#endif


/** Call obj->ref() and return obj. The obj must not be nullptr.
*/
Expand Down

0 comments on commit 1be5c83

Please sign in to comment.