There are (annoyingly undocumented) assembler directives, which make
this fairly straightforward. I've manually verified that they're
setting up the expected data structures correctly. Under normal
circumstances, we don't expect these leaf functions to throw exceptions.
Note that the `endswap_block' subroutine of `rijndael_setup_x86ish_-
aesni' is not currently properly described.
// Set the function hooks.
#define FUNC_PREHOOK(_) .balign 16
// Set the function hooks.
#define FUNC_PREHOOK(_) .balign 16
+// On Windows, arrange to install stack-unwinding data.
+#if CPUFAM_AMD64 && ABI_WIN
+# define FUNC_POSTHOOK(name) .seh_proc name
+# define ENDFUNC_HOOK(_) .seh_endproc
+// Procedures are expected to invoke `.seh_setframe' if necessary, and
+// `.seh_pushreg' and friends, and `.seh_endprologue'.
+#endif
+
// Don't use the wretched AT&T syntax. It's festooned with pointless
// punctuation, and all of the data movement is backwards. Ugh!
.intel_syntax noprefix
// Don't use the wretched AT&T syntax. It's festooned with pointless
// punctuation, and all of the data movement is backwards. Ugh!
.intel_syntax noprefix
# define SAVE3 [rsp + 32]
sub rsp, 48 + 8
# define SAVE3 [rsp + 32]
sub rsp, 48 + 8
+ .seh_stackalloc 48 + 8
+ .seh_endprologue
#endif
// First job is to slurp the matrix into XMM registers. Be careful:
#endif
// First job is to slurp the matrix into XMM registers. Be careful:
// We'll need the index registers, which belong to the caller in this
// ABI.
push rsi
// We'll need the index registers, which belong to the caller in this
// ABI.
push rsi
+ .seh_pushreg rdi
+ .seh_endprologue
// Move arguments to more useful places.
mov SI, r8 // key material
// Move arguments to more useful places.
mov SI, r8 // key material
# define SRC rdx
# define DST r8
# define NR eax
# define SRC rdx
# define DST r8
# define NR eax
#endif
// Find the magic endianness-swapping table.
#endif
// Find the magic endianness-swapping table.
# define SAVE3 [rsp + 48]
sub rsp, 64 + 8
# define SAVE3 [rsp + 48]
sub rsp, 64 + 8
+ .seh_savexmm xmm7, 16
+ .seh_endprologue
#endif
// First job is to slurp the matrix into XMM registers. The words
#endif
// First job is to slurp the matrix into XMM registers. The words