public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix tst-getpid{1,2} on ia64
@ 2005-03-08 16:04 Jakub Jelinek
  2005-03-08 16:21 ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2005-03-08 16:04 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers

Hi!

When glibc is built with gcc-4_0-branch on IA-64, tst-getpid{1,2}
fails.  The problem is that while older GCCs always aligned
buffer as big as char st[256 * 1024]; to 16 bytes, GCC 4 only
aligns this to 8 bytes.
Now, either we require direct clone/__clone2 users to make sure
the stack passed to it is sufficiently aligned (as done e.g. in
the patch below, 64 is just a guess for all arches out there,
I think e.g. IA-64 needs just 16 bytes alingment), or we make sure
that glibc's __clone2 and clone align things themselves, or we
make sure the kernel aligns it.

2005-03-08  Jakub Jelinek  <jakub@redhat.com>

	* tst-getpid1.c: Include stdint.h.
	(do_test): Align stack passed to clone{2,} to 64 bytes.

--- libc/nptl/tst-getpid1.c.jj	2004-12-15 12:16:06.000000000 +0100
+++ libc/nptl/tst-getpid1.c	2005-03-08 16:54:43.947924210 +0100
@@ -1,6 +1,7 @@
 #include <sched.h>
 #include <signal.h>
 #include <string.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -44,11 +45,13 @@ do_test (void)
   extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
 		       size_t __child_stack_size, int __flags,
 		       void *__arg, ...);
-  char st[256 * 1024];
-  pid_t p = __clone2 (f, st, sizeof (st), TEST_CLONE_FLAGS, 0);
+  char st[256 * 1024 + 64];
+  char *stp = (char *) ((uintptr_t) (st + 64) & -64);
+  pid_t p = __clone2 (f, stp, sizeof (st) - 64, TEST_CLONE_FLAGS, 0);
 #else
-  char st[128 * 1024];
-  pid_t p = clone (f, st + sizeof (st), TEST_CLONE_FLAGS, 0);
+  char st[128 * 1024 + 64];
+  char *stp = (char *) ((uintptr_t) (st + 64) & -64);
+  pid_t p = clone (f, stp + sizeof (st) - 64, TEST_CLONE_FLAGS, 0);
 #endif
   if (p == -1)
     {

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-03-10 11:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-08 16:04 [PATCH] Fix tst-getpid{1,2} on ia64 Jakub Jelinek
2005-03-08 16:21 ` Andreas Schwab
2005-03-08 16:27   ` Jakub Jelinek
2005-03-08 16:40     ` Andreas Schwab
2005-03-10 11:18       ` [PATCH] Fix tst-getpid{1,2} on ia64 (take 2) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).