Page MenuHomeFreeBSD

Align FILE to 8 byte boundary.
ClosedPublic

Authored by imp on Dec 25 2015, 11:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 3, 6:59 AM
Unknown Object (File)
Fri, Nov 1, 3:17 AM
Unknown Object (File)
Oct 19 2024, 5:17 AM
Unknown Object (File)
Oct 14 2024, 1:58 AM
Unknown Object (File)
Sep 30 2024, 12:26 PM
Unknown Object (File)
Sep 30 2024, 2:11 AM
Unknown Object (File)
Sep 15 2024, 3:59 AM
Unknown Object (File)
Sep 15 2024, 3:59 AM
Subscribers

Details

Summary

The FILE structure has a mbstate_t in it. This structure needs to be
aligned on a int64_t boundary. However, when we allocate the array of
these structures, we use ALIGNBYTES which defaults to sizeof(int) on
arm, i386 and others. The i386 stuff can handle unaligned accesses
seemlessly. However, arm cannot. Take this into account when creating
the array of FILEs, and add some comments about why.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp retitled this revision from to Align FILE to 8 byte boundary..
imp updated this object.
imp edited the test plan for this revision. (Show Details)
ian added inline comments.
lib/libc/stdio/findfp.c
112 ↗(On Diff #11692)

I think

align = __alignof__(FILE);

should be all that's needed, without worrying about ALIGNBYTES. alignof is supported on gcc >= 3 and all clang versions.

Also, as long as things are changing here, might as well get rid of the superfluous cast.

This revision was automatically updated to reflect the committed changes.

Looks like I missed Ian's comment before pushing the original change in. Will incorporate it and redo.

Updated, per Ian's suggestion.

lib/libc/stdio/findfp.c
111 ↗(On Diff #11732)

I'm giving a pass on the suggestion to remove unnecessary casts. I didn't add any new ones, so far as I can tell, and would rather not break something by removing too many...

lib/libc/stdio/findfp.c
111 ↗(On Diff #11732)

I was referring just to the cast of the malloc return value. I don't know why that particular uneeded cast bugs me more than others. :)

Bruce's ranting about missing manpages causing undefined behavior notwithstanding, I think __alignof() is probably the right spelling for what I originally spelled the native gcc way.

This revision was automatically updated to reflect the committed changes.