There is a problem with the current implementation of the atomic incr and decr functions. ...
12 years, 10 months ago
(2011-08-18 18:27:38 UTC)
#1
There is a problem with the current implementation of the atomic incr and decr
functions. A destructor of a static object from another translation unit can be
called after gAtomicMutex has been destroyed. It's then an error for the
destructor to call the atomic incr or decr function. SkRefCnt::unref calls the
atomic decr function.
These intrinsics have have been in GCC since at least 4.1.0. On my Linux box
they are 30% faster than the mutex implementation.
I'm no expert on that either. I did test it in visual studio. It treats ...
12 years, 10 months ago
(2011-08-18 20:02:36 UTC)
#4
I'm no expert on that either. I did test it in visual studio. It treats #if
UNDEFINED_MACRO as equivalent to #if 0 but that may be non-standard.
I guess to take it a step further I don't know if
#if defined(UNDEFINED_MACRO) && UNDEFINED_MACRO > 0
is legal either. So I nested them. I assume if __GNUC__ is defined then
__GNUC_MINOR__ is also defined.
On Thu, Aug 18, 2011 at 3:49 PM, <caryclark@google.com> wrote:
>
> http://codereview.appspot.com/**4894055/diff/5001/src/ports/**
>
SkThread_pthread.cpp<http://codereview.appspot.com/4894055/diff/5001/src/ports/SkThread_pthread.cpp>
> File src/ports/SkThread_pthread.cpp (right):
>
> http://codereview.appspot.com/**4894055/diff/5001/src/ports/**
>
SkThread_pthread.cpp#newcode24<http://codereview.appspot.com/4894055/diff/5001/src/ports/SkThread_pthread.cpp#newcode24>
> src/ports/SkThread_pthread.**cpp:24: #if GCC_SYNC_INTRINSIC
> Huh. I'm not sure this works, but I'm always fuzzy on preprocessor
> rules. I think that the #if expands to:
>
> #if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 1 && (__x86_64 ||
> __i386__))
>
> which may fail if __GNUC__ and friends aren't defined. To place it safe,
> I recommend:
>
> #if defined(__GNUC__) && __GNUC__ >= 4 && ...
> #define GCC_SYNC_INTRINSIC
> #endif
>
> #ifdef GCC_SYNC_INTRINSIC
>
>
>
http://codereview.appspot.com/**4894055/<http://codereview.appspot.com/4894055/>
>
Issue 4894055: Use gcc intrinsic atomic operations for incr and decr
(Closed)
Created 12 years, 10 months ago by bsalomon
Modified 12 years, 10 months ago
Reviewers: caryclark1
Base URL: http://skia.googlecode.com/svn/trunk/
Comments: 1