[cxx-abi-dev] One-time Construction API (3.3.2)
Dennis Handly
dhandly at cup.hp.com
Thu Aug 5 05:45:21 UTC 2004
>From: Jason Merrill <jason at redhat.com>
>primarily because if construction of the object throws, we need to call
>__cxa_guard_abort, but if destruction of any temporaries throws, we need to
>call __cxa_guard_release.
Hmm, we seem to do the same for both. And it is left on the atexit list
for the latter.
> To make this work, we need to do something like
>if (__cxa_guard_acquire (&guard)) {
You didn't optimize by checking the guard before calling
_cxa_guard_acquire.
>The flag is necessary to avoid non-nested overlapping EH regions.
We don't use a flag. We use try/catch:
try {
/* initialize */
__cxa_atexit(dtor);
__cxa_guard_release(&guard);
}
catch(...) {
__cxa_guard_abort(&guard);
}
>2.8 refers to "the first byte", while 3.3.2 refers to "the low-order
>byte". These are the same on little-endian targets, but not big-endian.
Are you sure? It says byte with lowest address. Not low-order byte.
First and lowest are the same for big-endian.
>I've been thinking about how to implement the actual locking, and the best
>I've come up with is to have the guard be an index into an array of mutexes
We use one mutex for all statics. The same one that synchronizes the
__cxa_atexit list.
>with magic values for uninitialized and "creating
>mutex"; in the latter case another thread that comes to it should just spin
>until it takes on another value.
We do use the second byte to handle (stop) recursion. Though this seems
flawed in that it won't wait until constructed. :-(
>Has anyone actually implemented this?
Jason
Naturally, 3 years ago.
More information about the cxx-abi-dev
mailing list