stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Liviu Nicoara <>
Subject STDCXX-1072 SPARC V8 mutex alignment requirements
Date Fri, 28 Sep 2012 12:29:28 GMT
I have created the above and linked it to the closed STDCXX-1066.

In short, my reading about this issue is that the kernel patch changed the alignment of the
userland mutex objects from a machine word to a double-word boundary. No changes are required
of the users who use such objects in their programs unless users create mutex objects in buffers
which may not be aligned on a proper boundary. E.g., the following are safe:

mutex_t lock;

struct S {
     char misalign;
     mutex_t lock;

whereas the following is not:

union {
     void* align;
     char buf [sizeof mutex_t];
} u;

new (&u) mutex_t;

because the alignment requirements for void pointer are less strict than for mutex_t. A few
places in the library use the latter for all sorts of static objects (mostly local statics).
I looked esp. for places where we build objects that contain mutex sub-objects inside a union-aligned

struct S {
     char c;
     mutex_t m;


union {
     void* align; // <- incorrect
     char buf [sizeof (S)];
} u;

new (&u) S ();

The alignment must be changed to a value equal or greater than the mutex alignment requirements.

IMO, the patch I attached does not break binary compatibility. It uses a one size fits all
long double for alignment -- like we use in rw/_mutex.h -- but in doing so dispenses with
all sorts of preprocessor conditionals.

I still don't have access to a SPARC machine. Any feed-back and/or SPARC build results are
more than welcome!



View raw message