about summary refs log tree commit diff
path: root/nptl/tst-sem11.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-10-30 09:35:20 -0700
committerUlrich Drepper <drepper@redhat.com>2009-10-30 09:35:20 -0700
commit9c04f7c155fb799fa7757b5c8bb52400d0dc2ec5 (patch)
tree0683255c817e5b300c63ae660d41057f36cca02f /nptl/tst-sem11.c
parent3005703bb9aff3b2a1b2cf6bbbc92e7eaf91d9a5 (diff)
downloadglibc-9c04f7c155fb799fa7757b5c8bb52400d0dc2ec5.tar.gz
glibc-9c04f7c155fb799fa7757b5c8bb52400d0dc2ec5.tar.xz
glibc-9c04f7c155fb799fa7757b5c8bb52400d0dc2ec5.zip
Fix aliasing problem in tst-sem11.
Diffstat (limited to 'nptl/tst-sem11.c')
-rw-r--r--nptl/tst-sem11.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/nptl/tst-sem11.c b/nptl/tst-sem11.c
index 6633ddd1f3..5248eba05d 100644
--- a/nptl/tst-sem11.c
+++ b/nptl/tst-sem11.c
@@ -23,23 +23,25 @@ main (void)
 {
   int tries = 5;
   pthread_t th;
-  sem_t s;
+  union
+  {
+    sem_t s;
+    struct new_sem ns;
+  } u;
  again:
-  if (sem_init (&s, 0, 0) != 0)
+  if (sem_init (&u.s, 0, 0) != 0)
     {
       puts ("sem_init failed");
       return 1;
     }
 
-  struct new_sem *is = (struct new_sem *) &s;
-
-  if (is->nwaiters != 0)
+  if (u.ns.nwaiters != 0)
     {
       puts ("nwaiters not initialized");
       return 1;
     }
 
-  if (pthread_create (&th, NULL, tf, &s) != 0)
+  if (pthread_create (&th, NULL, tf, &u.s) != 0)
     {
       puts ("pthread_create failed");
       return 1;
@@ -62,11 +64,11 @@ main (void)
   if (r != PTHREAD_CANCELED && --tries > 0)
     {
       /* Maybe we get the scheduling right the next time.  */
-      sem_destroy (&s);
+      sem_destroy (&u.s);
       goto again;
     }
 
-  if (is->nwaiters != 0)
+  if (u.ns.nwaiters != 0)
     {
       puts ("nwaiters not reset");
       return 1;