ftmemsim-valgrind/none/tests/pth_stackalign.c
Tom Hughes 6e422fd573 The calculation used to round the size of a new thread's stack to a
multiple of the page size had an off by one error. Fixed it to use
the PGROUNDUP macro instead of trying to do the calculation itself
and then get it wrong.

BUG: 93309


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3030
2004-11-16 19:40:05 +00:00

35 lines
604 B
C

#include <inttypes.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void *thread_main(void *arg)
{
uintptr_t address = (uintptr_t)&arg;
printf("alignment = %" PRIuPTR "\n", address & 3U);
return NULL;
}
int main(int argc, char **argv)
{
pthread_t t;
int e;
if ((e = pthread_create(&t, NULL, thread_main, NULL)) != 0)
{
fprintf(stderr, "pthread_create: %s\n", strerror(e));
exit(1);
}
if ((e = pthread_join(t, NULL)) != 0)
{
fprintf(stderr, "pthread_join: %s\n", strerror(e));
exit(1);
}
exit(0);
}