public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: add local machine/asm.h header
Date: Tue, 20 Dec 2022 21:54:41 +0000 (GMT)	[thread overview]
Message-ID: <20221220215441.EA2643858000@sourceware.org> (raw)

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

commit 8e83ca675f522d132ca35d847aa35f310951702e
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Dec 20 09:56:39 2022 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Dec 20 10:13:59 2022 +0100

    Cygwin: add local machine/asm.h header
    
    This header supports including BSD assembler sources.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/local_includes/machine/asm.h | 78 ++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/winsup/cygwin/local_includes/machine/asm.h b/winsup/cygwin/local_includes/machine/asm.h
new file mode 100644
index 000000000000..12b0285396ff
--- /dev/null
+++ b/winsup/cygwin/local_includes/machine/asm.h
@@ -0,0 +1,78 @@
+#ifndef _MACHINE_ASM_H
+#define _MACHINE_ASM_H
+
+/* Macros for importing FreeBSD/OpenBSD/NetBSD assembler code. */
+
+#ifdef __x86_64__
+
+#define _ALIGN_TEXT		.p2align 4,0x90
+
+/* The NATIVE_ENTRY macro just adds the required gas macros.  It can be
+   used stand-alone if the code is so short that it's better to change the
+   argument registeres rather than adding the code overhead. */
+
+#define NATIVE_ENTRY(__sym)		 \
+		.text			;\
+		.p2align 4		;\
+		.globl __sym		;\
+		.seh_proc __sym		;\
+	__sym:				 \
+
+/* The ENTRY macros cover the difference in argument passing between
+   MS-ABI and SysV ABI.  Note especially that RSI/RDI are always saved
+   in the stack shadow space defined by the MS_ABI, and restored when
+   calling ret (see the "ret" macro below). */
+
+#define __ENTRY(__sym)			 \
+		NATIVE_ENTRY(__sym)	 \
+		movq	%rsi,8(%rsp)	;\
+		movq	%rdi,16(%rsp)	;
+
+/* ENTRY1 for functions with 1 arg */
+#define ENTRY1(__sym)			 \
+		__ENTRY(__sym)		 \
+		movq	%rcx,%rdi	;\
+		.seh_endprologue	;
+
+/* ENTRY2 for functions with 2 args */
+#define ENTRY2(__sym)			 \
+		__ENTRY(__sym)		 \
+		movq	%rcx,%rdi	;\
+		movq	%rdx,%rsi	;\
+		.seh_endprologue	;
+
+/* ENTRY3 for functions with 3 args */
+#define ENTRY3(__sym)			 \
+		__ENTRY(__sym)		 \
+		movq	%rcx,%rdi	;\
+		movq	%rdx,%rsi	;\
+		movq	%r8,%rdx	;\
+		.seh_endprologue	;
+
+/* ENTRY4 for functions with 4 args */
+#define ENTRY4(__sym)			 \
+		__ENTRY(__sym)		 \
+		movq	%rcx,%rdi	;\
+		movq	%rdx,%rsi	;\
+		movq	%r8,%rdx	;\
+		movq	%r9,%rcx	;\
+		.seh_endprologue	;
+
+#define ret				 \
+		movq	8(%rsp),%rsi	;\
+		movq	16(%rsp),%rdi	;\
+		retq			;\
+
+#define END(__sym)			 \
+		.seh_endproc
+
+#endif /* __x86_64__ */
+
+#define __FBSDID(s)			 \
+		.ident s
+
+#define STRONG_ALIAS(__a,__s)		 \
+		.globl	__a		;\
+		__a = __s		;
+
+#endif /* _MACHINE_ASM_H */

                 reply	other threads:[~2022-12-20 21:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221220215441.EA2643858000@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).