This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: sparc 32-bit dirent broken
- From: David Miller <davem at davemloft dot net>
- To: fweimer at redhat dot com
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 10 Oct 2013 17:17:16 -0400 (EDT)
- Subject: Re: sparc 32-bit dirent broken
- Authentication-results: sourceware.org; auth=none
- References: <52570475 dot 2050107 at redhat dot com> <20131010 dot 164308 dot 103134182855731464 dot davem at davemloft dot net> <20131010 dot 170628 dot 144428253182134045 dot davem at davemloft dot net>
From: David Miller <davem@davemloft.net>
Date: Thu, 10 Oct 2013 17:06:28 -0400 (EDT)
> I'll test out this theory.
Indeed, the following patch fixes the bug. We were just being lucky
beforehand in that the off_t was 64-bit and therefore making the
data[] array be 64-bit aligned as well. Once you add the errcode
there it is only 4-byte aligned.
On powerpc/x86-32 there are no alignment traps, so you wouldn't notice
this problem on those platforms.
The critical element is whatever alignment d_off/d_ino need, that can
be either __off_t/__ino_t or __off64_t/__ino64_t.
Any suggestions for a better alignof or is this good enough to fix
the problem? We probably should have a per-sysdep definition of
"largest C type alignment" so we can use it in situations like this.
diff --git a/sysdeps/posix/dirstream.h b/sysdeps/posix/dirstream.h
index 8e8570d..bf221db 100644
--- a/sysdeps/posix/dirstream.h
+++ b/sysdeps/posix/dirstream.h
@@ -42,7 +42,7 @@ struct __dirstream
int errcode; /* Delayed error code. */
/* Directory block. */
- char data[0] __attribute__ ((aligned (__alignof__ (void*))));
+ char data[0] __attribute__ ((aligned (__alignof__ (unsigned long long))));
};
#define _DIR_dirfd(dirp) ((dirp)->fd)