devkitPro / wut

Let's try to make a Wii U Toolchain / SDK for creating rpx/rpl.
zlib License
244 stars 52 forks source link

nn_acp: Add ACPMetaXml parameter alignment check #217

Closed Maschell closed 2 years ago

Maschell commented 2 years ago

Previously getting metaXML didn't work when the ACPMetaXml ptr was not aligned to 0x40, this implementation enforces the correct alignment.

exjam commented 2 years ago

Does using WUT_ALIGNAS not work for this? We already use it on some other structures.

wut\include\wut_structsize.h:
   37: #define WUT_ALIGNAS(x) alignas(x)
   39: #define WUT_ALIGNAS(x) __attribute__((__aligned__(x)))

wut\include\coreinit\context.h:
   19: struct WUT_ALIGNAS(8) OSContext

wut\include\coreinit\spinlock.h:
   17: struct WUT_ALIGNAS(16) OSSpinLock

wut\include\coreinit\thread.h:
  120: struct WUT_ALIGNAS(8) OSThread
exjam commented 2 years ago

Oh wait is it because it needs WUT_PACKED but also align?

Might be able to use WUT_ALIGNAS on the first variable in that case.

Maschell commented 2 years ago

The advantages of this approach is that it works in all cases, cause the correct alignment will always be forced. With WUT_ALIGNAS there are still way to bypass the aligment (on the heap) and the function happily returns "success", not informing that something went wrong.