Adding DECLSPEC_ALIGN(4) to structs for atomic DWORD access
Joerg-Cyril.Hoehle at t-systems.com
Joerg-Cyril.Hoehle at t-systems.com
Mon Jan 21 11:52:23 CST 2013
Hi,
there are some places in Wine where I believe atomic access to 32bit entities
is expected by the programmer, yet I see little or no measures to ensure this.
DWORD-Alignment is essential when several threads can access
the same DWORD variable outside of a mutex (or within the implementation of the mutex).
DECLSPEC_ALIGN(4) is the declaration that could be used to enforce
it within a struct, assuming the struct itself is somehow aligned.
E.g. shouldn't CRITICAL_SECTION objects be aligned when used within other (non-public) structs?
(Presumably public MS structs cannot be augmented with alignment declarations)
DECLSPEC_ALIGN is hardly used in Wine
http://source.winehq.org/ident?i=RTL_CRITICAL_SECTION
Other examples where I'm considering adding DWORD-alignment
to read DWORD-sized objects atomically:
- MCI position values (for MCI_STATUS_POSITION)
- MIDI end_thread control variable
- mmdevapi GetCurrentPadding (as part of lock-less patch)
Would such patches be welcome? Are they superfluous, assuming
that DWORD-alignment is granted and using DECLSPEC_ALIGN() only
for larger alignments, e.g. 8 or 16 (that seems to be the current use)?
One benefit I see is to highlight those variables shared among several threads.
Regards,
Jörg Höhle
More information about the wine-devel
mailing list