[PATCH V2] Cygwin: Aarch64: Add inline assembly pthread wrapper
Jeremy Drake
cygwin@jdrake.com
Thu Jun 19 20:22:00 GMT 2025
On Thu, 19 Jun 2025, Thirumalai Nagalingam wrote:
> Hi,
>
> Thanks for the feedback.
> As per your request, I've included the updated patch v2 both inline below and as an attachment for easier review.
>
> Q1 - 32-byte shadow area on AArch64
> You're correct - unlike x64 Windows, the AArch64 (ARM64) calling convention does not mandate a 32-byte shadow space. In my original patch, I included it to maintain parity with x64 behaviour. I re-tested without it and Cygwin `pthread` tests pass on ARM64.
> So, in this version, I've removed the shadow space allocation to better align with standard AArch64 conventions.
>
> Q2 - `mov x0, sp` to `mov x0, [x19, #16]`
> You're right again. For the `VirtualFree` call, `x0` should point to the original OS-provided stack (`stackaddr`), not the current `sp`.
> I've corrected it as suggested. Thanks again for catching that.
I caught myself after sending that message, and figured that it should
actually be ldr rather than mov. Now I'm curious and will have to examine
the aarch64 docs and assembler output to see what 'mov' would do in that
case vs ldr. :)
Also, probably not important as far as saving a few cycles, but maybe it
could be
+ ldp x0, x10, [x19, #16] // x0 = wrapper_arg.stackaddr\n\
+ // x10 = wrapper_arg.stackbase \n\
In addition, please include a Signed-off-by trailer in the commit message.
More information about the Cygwin-patches
mailing list