This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC][BZ #16549] Add sanity check for condvar alignment.


On Tue, Feb 11, 2014 at 02:00:22PM +0100, Andreas Schwab wrote:
> OndÅej BÃlka <neleai@seznam.cz> writes:
> 
> > +  assert (((uintptr_t) cond) % sizeof (long) == 0);
> 
> Does it really require long alignment?  The futex syscall only requires
> 32 bit alignment.
> 
Yes, I meant int there.


diff --git a/nptl/pthread_cond_init.c b/nptl/pthread_cond_init.c
index 27efc9c..53d6170 100644
--- a/nptl/pthread_cond_init.c
+++ b/nptl/pthread_cond_init.c
@@ -16,6 +16,7 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <assert.h>
 #include <shlib-compat.h>
 #include "pthreadP.h"
 #include <stap-probe.h>
@@ -28,6 +29,7 @@ __pthread_cond_init (cond, cond_attr)
 {
   struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr;
 
+  assert (((uintptr_t) cond) % sizeof (int) == 0);
   cond->__data.__lock = LLL_LOCK_INITIALIZER;
   cond->__data.__futex = 0;
   cond->__data.__nwaiters = (icond_attr != NULL


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]