mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-14 01:00:07 +00:00
595538976b
2000-11-20 Jakub Jelinek <jakub@redhat.com> * iconvdata/bug-iconv2.c (main): Use %zd in format string. * io/test-lfs.c (do_test): Cast statbuf.st_size to long long. * malloc/tst-valloc.c (main): Cast valloc return value to long. * malloc/tst-obstack.c (verbose_malloc): Use %zd in format string. * math/test-fpucw.c (main): Use %lx in format string, cast control words to long. * stdio-common/tst-fmemopen.c (main): Use %td in format strings. * stdlib/tst-strtol.c (tests): Avoid (bogus?) decimal constant is so large that it is unsigned warning. * sysdeps/unix/sysv/linux/sparc/bits/types.h (__ssize_t): Changing it to long on sparc64. 2000-11-20 Andreas Jaeger <aj@suse.de> * nscd/nscd.h (termination_handler): Add noreturn attribute. (receiv_print_stats): Likewise. * elf/ldconfig.c (path_hwcap): Cast -1 for proper comparison.
65 lines
1.3 KiB
C
65 lines
1.3 KiB
C
/* Test case by Alexandre Duret-Lutz <duret_g@epita.fr>. */
|
|
#include <obstack.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define obstack_chunk_alloc verbose_malloc
|
|
#define obstack_chunk_free verbose_free
|
|
#define ALIGN_BOUNDARY 64
|
|
#define ALIGN_MASK (ALIGN_BOUNDARY - 1)
|
|
#define OBJECT_SIZE 1000
|
|
|
|
static void *
|
|
verbose_malloc (size_t size)
|
|
{
|
|
void *buf = malloc (size);
|
|
printf ("malloc (%zu) => %p\n", size, buf);
|
|
return buf;
|
|
}
|
|
|
|
static void
|
|
verbose_free (void *buf)
|
|
{
|
|
free (buf);
|
|
printf ("free (%p)\n", buf);
|
|
}
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
int result = 0;
|
|
int align = 2;
|
|
|
|
while (align <= 64)
|
|
{
|
|
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;
|
|
}
|
|
|
|
/* clean up */
|
|
obstack_free (&obs, 0);
|
|
|
|
align <<= 1;
|
|
}
|
|
|
|
return result;
|
|
}
|