[newlib-cygwin/main] Cygwin: gendef: Implement _sigfe function for TLS handling on AArch64

Corinna Vinschen corinna@sourceware.org
Fri Jan 16 18:50:42 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5e86032e3e84938e61d95989e464495b5a09b043

commit 5e86032e3e84938e61d95989e464495b5a09b043
Author:     Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
AuthorDate: Sat Dec 6 19:16:21 2025 +0530
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Jan 16 19:48:53 2026 +0100

    Cygwin: gendef: Implement _sigfe function for TLS handling on AArch64
    
    Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>

Diff:
---
 winsup/cygwin/scripts/gendef | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
index 32ceb357802c..ab57739fa5e6 100755
--- a/winsup/cygwin/scripts/gendef
+++ b/winsup/cygwin/scripts/gendef
@@ -385,7 +385,44 @@ _sigfe_maybe:					# stack is aligned on entry!
 	ret
 	.seh_endproc
 
+    .seh_proc _sigfe
 _sigfe:
+    .seh_endprologue
+    ldr     x10, [x18, #0x8]		// Load TLS base into x10
+    mov     w9, #1			// constant value for lock acquisition
+0:  ldr     x11, =_cygtls.stacklock	// Load offset of stacklock
+    add     x12, x10, x11		// Compute final address of stacklock
+    ldaxr   w13, [x12]			// Load current stacklock value atomically
+    stlxr   w14, w9, [x12]		// Attempt to store 1 to stacklock atomically
+    cbnz    w14, 0b			// Retry if atomic store failed
+    cbz     w13, 1f			// If lock was free, proceed
+    yield
+    b       0b				// Retry acquiring the lock
+1:
+    ldr     x11, =_cygtls.incyg	// Load offset of incyg
+    add     x12, x10, x11		// Compute final address of incyg
+    ldr     w9, [x12]			// Load current incyg value
+    add     w9, w9, #1			// Increment incyg
+    str     w9, [x12]			// Store updated incyg value
+    mov     x9, #8			// Set stack frame size increment (8 bytes)
+2:  ldr     x11, =_cygtls.stackptr	// Load offset of stack pointer
+    add     x12, x10, x11		// Compute final address of stack pointer
+    ldaxr   x13, [x12]			// Atomically load current stack pointer
+    add     x14, x13, x9		// Compute new stack pointer value
+    stlxr   w15, x14, [x12]		// Attempt to update stack pointer atomically
+    cbnz    w15, 2b			// Retry if atomic update failed
+    str     x30, [x13]                 // Save LR(return address) on stack
+    adr     x11, _sigbe		// Load address of _sigbe
+    mov     x30, x11                   // Set LR = _sigbe
+    ldr     x11, =_cygtls.stacklock	// Load offset of stacklock TLS variable
+    add     x12, x10, x11		// Compute final address of stacklock
+    ldr     w9, [x12]			// Load current stacklock value
+    sub     w9, w9, #1			// Decrement stacklock to release lock
+    stlr    w9, [x12]			// Store stacklock value (release lock)
+    ldr     x9, [sp], #16              // Pop real func address from stack
+    br      x9				// Branch to real function
+    .seh_endproc
+
 _sigbe:
 	.global	sigdelayed
 sigdelayed:


More information about the Cygwin-cvs mailing list