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.
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
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. |
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. |