From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 387433858438; Tue, 1 Aug 2023 12:23:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 387433858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690892605; bh=G/AcCEQMLwl0O5HrhB7AnqNkb8dqVx5uQULf4T75G94=; h=From:To:Subject:Date:From; b=kTr3nNiY4pUe9ZgODVsFSOrOwVm5IbCTw/Q2X0MnojUHo2t4PdH3moqYvnZvXZu99 anMfFWqrb6WbSTFeRdK+Urcc1aV/oaiNJ88OO4HcRRjXjgZISt0qoDNXdaa3+SPk/m z6L1ruvJXqpGFIX7L/gMo6mpYEcnac3YNUDVqe1k= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: autoload: introduce LoadDLLfunc_pfx_only X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 4f258c55e87fe4c0ea7d5703c32890b63295bc23 X-Git-Newrev: 0e711d6cc9b5206335fe8562817b6d5e6cad876e Message-Id: <20230801122325.387433858438@sourceware.org> Date: Tue, 1 Aug 2023 12:23:25 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D0e711d6cc9b= 5206335fe8562817b6d5e6cad876e commit 0e711d6cc9b5206335fe8562817b6d5e6cad876e Author: Corinna Vinschen AuthorDate: Tue Aug 1 14:16:40 2023 +0200 Commit: Corinna Vinschen CommitDate: Tue Aug 1 14:16:40 2023 +0200 Cygwin: autoload: introduce LoadDLLfunc_pfx_only =20 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. =20 For a start, only define the most simple macro, setting all extensions to 0. =20 =20 Signed-off-by: Corinna Vinschen 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