4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-18 23:12:15 +08:00

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>
This commit is contained in:
Corinna Vinschen 2023-08-01 14:16:40 +02:00
parent 4f258c55e8
commit 0e711d6cc9

View File

@ -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