This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: struct statfs/statfs64 in linux-generic


On 13/11/12 äå1:48, Joseph S. Myers wrote:
> On Sun, 10 Nov 2013, Chung-Lin Tang wrote:
> 
>> I think I found my problem, which is more simpler than I thought: unlike
>> the majority of targets, 64-bit types are 4-byte aligned under Nios II,
>> which causes a 4-byte difference between the glibc/kernel structure
>> definitions because the kernel one doesn't have
>> __attribute__((aligned(8))) forced on to it.
>>
>> Stack alignment is 4-bytes as well in nios2, so I'll probably be
>> maintaining that and using a specific nios2/bits/statfs.h header without
>> the double-word alignment bits.
> 
> Are you sure this is the only place in the kernel/userspace ABI where 
> linux-generic is assuming natural alignment?
> 

generic/bits/stat.h also has use of __attribute__(aligned()), though the
field elements happen to amount to an even number of words, so no such
inconsistency there; just that user code will enforce additional alignment.

The problem I think is the use of the hard coded "8", so instead of
requiring ports like nios2 to possess nearly identical header files
(without the alignment attributes), how about the attached patch that
changes it to use __alignof__(type64) instead?

Thanks,
Chung-Lin

2013-11-13  Chung-Lin Tang  <cltang@codesourcery.com>

	ports/
	* sysdeps/unix/sysv/linux/generic/bits/stat.h (__field64): Use
	__alignof__(type64) in alignment attribute instead of 8.
	* sysdeps/unix/sysv/linux/generic/bits/statfs.h (__field64): Use
	__alignof__(type64) in alignment attribute instead of 8.
	(struct statfs): Use __alignof__(__u64) in alignment attribute
	instead of 8.
	(struct statfs64): Likewise.

Attachment: x.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]