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/main] Cygwin: autoload: introduce LoadDLLfunc_pfx_only
Date: Tue,  1 Aug 2023 12:23:25 +0000 (GMT)	[thread overview]
Message-ID: <20230801122325.387433858438@sourceware.org> (raw)

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

commit 0e711d6cc9b5206335fe8562817b6d5e6cad876e
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Aug 1 14:16:40 2023 +0200
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Aug 1 14:16:40 2023 +0200

    Cygwin: autoload: introduce LoadDLLfunc_pfx_only
    
    This macro loads and defines a function just as usual, except
    that the Windows function is exposed only with the prefix
    _win32_.  So Windows select (the immediate victim) is only
    exposed as _win32_select.  That allows to autoload the windows
    function without collision with a Cygwin function of the same
    name.
    
    For a start, only define the most simple macro, setting all
    extensions to 0.
    
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/autoload.cc | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index c8909caff4b1..c9ad92530c83 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -123,6 +123,33 @@ _win32_" #name ":					\n\
   .asciz	\"" #name "\"				\n\
   .text							\n\
 ");
+
+/* Do not export function "foo" as "foo". Only export it as "_win32_foo".
+   That allows to autoload and use a Windows function having the same name
+   as a Cygwin function. Namely select. */
+#define LoadDLLfunc_pfx_only(name, dllname) \
+  LoadDLLprime (dllname, dll_func_load, 0) \
+  __asm__ ("						\n\
+  .section	." #dllname "_autoload_text,\"wx\"	\n\
+  .global	_win32_" #name "			\n\
+  .align	16					\n\
+_win32_" #name ":					\n\
+  movq		3f(%rip),%rax				\n\
+  jmp		*%rax					\n\
+1:movq		2f(%rip),%rax				\n\
+  push		%rbp		# Keep 16 byte aligned	\n\
+  push		%r9					\n\
+  push		%r8					\n\
+  push		%rdx					\n\
+  push		%rcx					\n\
+  call		*(%rax)					\n\
+2:.quad		." #dllname "_info			\n\
+  .hword	0					\n\
+  .hword	0					\n\
+3:.quad		1b					\n\
+  .asciz	\"" #name "\"				\n\
+  .text							\n\
+");
 #else
 #error unimplemented for this target
 #endif

                 reply	other threads:[~2023-08-01 12:23 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=20230801122325.387433858438@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).