Port the Windows atomic implementation to use QGenericAtomicOps
authorBradley T. Hughes <bradley.hughes@nokia.com>
Mon, 30 Jan 2012 14:04:06 +0000 (15:04 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 2 Feb 2012 10:10:04 +0000 (11:10 +0100)
commit307c03497301015c418d4bfe462b14ed9cdf2f1b
tree82a97cd92aa2036b75d043df32a76efb0240644a
parentf04756f3f542eeeae416724046bfec96d977701e
Port the Windows atomic implementation to use QGenericAtomicOps

First, we do not need to have the QT_INTERLOCKED_REMOVE_VOLATILE(a)
macro anymore either, since the value stored in QBasicAtomicInteger is
not volatile.

Windows provides Interlocked*Pointer() functions in some configurations,
so we provide a partial specialization of QAtomicOps for pointer types.
For integer types, QAtomicOps selects an implementation based on the
size of the type. At the moment, we only support 32-bit types, but it
will be possible to add 64-bit later.

Note that the 32-bit specialization of QAtomicOpsBySize declares the
Type typedef as long, not int, since the Windows Interlocked*() API
takes parameters as longs and long pointers. Since this typedef differs
from the type given to QBasicAtomicInteger<T> by the QBasicAtomicInt
typedef, we need to templatise the _q_value parameter separately from
the other arguments in QGenericAtomicOps.

This templatisation would be necessary to port other architectures, such
as PA_RISC, where we need to have an int[4] array in the atomic type
while the arguments do not need this array.

Change-Id: Id71fa1ae334da2023553cb402b45e6c285f1d344
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/arch/qatomic_windows.h
src/corelib/thread/qbasicatomic.h
src/corelib/thread/qgenericatomic.h