summary refs log tree commit diff
path: root/malloc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-24 08:30:36 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-24 08:30:36 +0000
commita60275764729607262421e78255aea27a75dc569 (patch)
tree2bf9f0d50c3e52a335cc3f2c882a3bd6abafc965 /malloc
parentf3e7f6080f916b051b309a44fef68a045a3aad3b (diff)
downloadglibc-a60275764729607262421e78255aea27a75dc569.tar.gz
glibc-a60275764729607262421e78255aea27a75dc569.tar.xz
glibc-a60275764729607262421e78255aea27a75dc569.zip
(main): Run tests for different alignments.
Diffstat (limited to 'malloc')
-rw-r--r--malloc/tst-obstack.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/malloc/tst-obstack.c b/malloc/tst-obstack.c
index bd00a0ab7b..cd19431bb9 100644
--- a/malloc/tst-obstack.c
+++ b/malloc/tst-obstack.c
@@ -28,27 +28,37 @@ verbose_free (void *buf)
 int
 main (void)
 {
-  struct obstack obs;
-  int i;
   int result = 0;
+  int align = 2;
 
-  obstack_init (&obs);
-  obstack_alignment_mask (&obs) = ALIGN_MASK;
-  /* finish an empty object to take alignment into account */
-  obstack_finish (&obs);
-
-  /* let's allocate some objects and print their addresses */
-  for (i = 15; i > 0; --i)
+  while (align <= 64)
     {
-      void *obj = obstack_alloc (&obs, OBJECT_SIZE);
+      struct obstack obs;
+      int i;
+      int align_mask = align - 1;
+
+      printf ("\n Alignment mask: %d\n", align_mask);
+
+      obstack_init (&obs);
+      obstack_alignment_mask (&obs) = align_mask;
+      /* finish an empty object to take alignment into account */
+      obstack_finish (&obs);
+
+      /* let's allocate some objects and print their addresses */
+      for (i = 15; i > 0; --i)
+	{
+	  void *obj = obstack_alloc (&obs, OBJECT_SIZE);
+
+	  printf ("obstack_alloc (%u) => %p \t%s\n", OBJECT_SIZE, obj,
+		  ((uintptr_t) obj & align_mask) ? "(not aligned)" : "");
+	  result |= ((uintptr_t) obj & align_mask) != 0;
+	}
 
-      printf ("obstack_alloc (%u) => %p \t%s\n", OBJECT_SIZE, obj,
-	      ((uintptr_t) obj & ALIGN_MASK) ? "(not aligned)" : "");
-      result |= ((uintptr_t) obj & ALIGN_MASK) != 0;
-  }
+      /* clean up */
+      obstack_free (&obs, 0);
 
-  /* clean up */
-  obstack_free (&obs, 0);
+      align <<= 1;
+    }
 
   return result;
 }