Follow on from that, it turns out (unsurprisingly) that it's the
alignment of the returned pointer that matters; and that since we only
know the size, not the type, we have to guess what the maximum possible
alignment must be.
Code (and comments) in glibc suggest:
max (sizeof (size_t) * 2, __alignof__ (long long))
This is the alignment size we want for NihAllocCtx, thus
#define NIH_ALLOC_CTX_ALIGN nih_max (sizeof (size_t) * 2, __alignof__ (long
long))
#define NIH_ALLOC_CTX_SIZE (NIH_ALLOC_CTX_ALIGN * (sizeof (NihAllocCtx) /
NIH_ALLOC_CTX_ALIGN + 1))
is probably right.
On the bright side, it means there's a spare 4 bytes in the NihAllocCtx
structure ;-)
** Changed in: upstart (Ubuntu)
Status: Incomplete => Triaged
** Changed in: upstart (Ubuntu)
Assignee: Michael Casadevall (mcasadevall) => (unassigned)
** Summary changed:
- upstart doesn't boot on sparc
+ nih: nih_alloc() doesn't align returned pointer for picky platforms like sparc
** Also affects: upstart
Importance: Undecided
Status: New
** Also affects: libnih
Importance: Undecided
Status: New
** Changed in: upstart
Status: New => Triaged
** Changed in: upstart
Importance: Undecided => Low
** Changed in: libnih
Importance: Undecided => Low
** Changed in: libnih
Status: New => Triaged
--
nih: nih_alloc() doesn't align returned pointer for picky platforms like sparc
https://bugs.launchpad.net/bugs/436758
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs