[Mingw-w64-public] [PATCH] headers: Import ctxtcall.idl from wine

2022-10-14 Thread Biswapriyo Nath

From 99dff0cac5b73b5902cd9b78c688ec33b2c3d55c Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath 
Date: Sat, 15 Oct 2022 10:16:55 +0530
Subject: [PATCH] headers: Import ctxtcall.idl from wine

Signed-off-by: Biswapriyo Nath 
---
 mingw-w64-headers/Makefile.am| 1 +
 mingw-w64-headers/wine-import.sh | 1 +
 2 files changed, 2 insertions(+)

diff --git a/mingw-w64-headers/Makefile.am b/mingw-w64-headers/Makefile.am
index 177b495..6e026f1 100644
--- a/mingw-w64-headers/Makefile.am
+++ b/mingw-w64-headers/Makefile.am
@@ -92,6 +92,7 @@ IDL_SRCS = \
   include/control.idl \
   include/credentialprovider.idl \
   include/ctfutb.idl \
+  include/ctxtcall.idl \
   include/d3d10.idl \
   include/d3d10_1.idl \
   include/d3d10sdklayers.idl \
diff --git a/mingw-w64-headers/wine-import.sh b/mingw-w64-headers/wine-import.sh
index a9e55d4..dda1eca 100755
--- a/mingw-w64-headers/wine-import.sh
+++ b/mingw-w64-headers/wine-import.sh
@@ -141,6 +141,7 @@ for f in \
bits3_0 \
bits5_0 \
ctfutb \
+   ctxtcall \
d3d10 \
d3d10_1 \
d3d10sdklayers \
-- 
2.38.0

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH 3/3] headers: Declare UUID for IContextCallback

2022-10-14 Thread Alvin Wong via Mingw-w64-public
Wine does seem to have ctxtcall.idl, but I'm not familiar with the 
procedure of importing IDL files from Wine. Also, the current ctxtcall.h 
in mingw-w64 seems to have some extra declarations which I'm not sure of.


I suspect it may take a bit of effort to replace ours with the one from 
Wine, which I don't feel like handling right now. If someone else would 
like to look into it, please do.


On 15/10/2022 1:51, Biswapriyo Nath wrote:

Would it be better if IDL file is provided instead of writing header
file manually?



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH 3/3] headers: Declare UUID for IContextCallback

2022-10-14 Thread Biswapriyo Nath
Would it be better if IDL file is provided instead of writing header
file manually?


___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: Implement the __stpcpy_chk function

2022-10-14 Thread Martin Storsjö

On Fri, 14 Oct 2022, LIU Hao wrote:


在 2022/10/14 19:38, Martin Storsjö 写道:

Initially, it may seem like this function might not be needed in any
form, since mingw-w64 lacks the main stpcpy function.

However, third party projects may contain their own implementation of
the stpcpy function. When GCC sees a declaration of the stpcpy 
function,

it assumes that it is legal to do optimizations on strcpy+strlen into
stpcpy.

When strcpy is wrapped with fortification wrappers, so that strcpy
ends up calling __builtin___strcpy_chk (which then calls __strcpy_chk),
GCC can also transform this into __builtin___stpcpy_chk, which can
generate a call to __stpcpy_chk.

GCC's libssp does provide an implementation of __stpcpy_chk, even if
the platform itself lacks stpcpy.

Therefore, mingw-w64-crt's implementation of the ssp routines also
does need an implementation of __stpcpy_chk, even if it is hard
to practically produce calls to it.

This should fix one issue discussed at
https://github.com/msys2/MINGW-packages/issues/5803#issuecomment-1276812143.

Signed-off-by: Martin Storsjö 
---
  mingw-w64-crt/Makefile.am  |  2 +-
  mingw-w64-crt/ssp/stpcpy_chk.c | 19 +++
  2 files changed, 20 insertions(+), 1 deletion(-)
  create mode 100644 mingw-w64-crt/ssp/stpcpy_chk.c



LGTM. Thanks.


Thanks, pushed.

// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: Implement the __stpcpy_chk function

2022-10-14 Thread Kai Tietz via Mingw-w64-public
Thanks!

Am Fr., 14. Okt. 2022 um 15:24 Uhr schrieb Martin Storsjö :
>
> On Fri, 14 Oct 2022, Kai Tietz wrote:
>
> > Yes, look good to me.  Wouldn't it make sense to add __mingww64_stpcpy
> > function, so we could provide this function in an more compatible way?
>
> I don't see the direct need for it; mingw-w64 doesn't have it general, and
> this status quo works for most projects (if they use it, they probe for
> its existence and provide a replacement), so I don't see the potential
> gain from optionally providing it. This seemed to be the general consensus
> in https://github.com/msys2/MINGW-packages/issues/5803 too, FWIW.
>
> // Martin
>


___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: Implement the __stpcpy_chk function

2022-10-14 Thread Kai Tietz via Mingw-w64-public
Yes, look good to me.  Wouldn't it make sense to add __mingww64_stpcpy
function, so we could provide this function in an more compatible way?

Thanks,
Kai

Am Fr., 14. Okt. 2022 um 14:16 Uhr schrieb LIU Hao :
>
> 在 2022/10/14 19:38, Martin Storsjö 写道:
> > Initially, it may seem like this function might not be needed in any
> > form, since mingw-w64 lacks the main stpcpy function.
> >
> > However, third party projects may contain their own implementation of
> > the stpcpy function. When GCC sees a declaration of the stpcpy function,
> > it assumes that it is legal to do optimizations on strcpy+strlen into
> > stpcpy.
> >
> > When strcpy is wrapped with fortification wrappers, so that strcpy
> > ends up calling __builtin___strcpy_chk (which then calls __strcpy_chk),
> > GCC can also transform this into __builtin___stpcpy_chk, which can
> > generate a call to __stpcpy_chk.
> >
> > GCC's libssp does provide an implementation of __stpcpy_chk, even if
> > the platform itself lacks stpcpy.
> >
> > Therefore, mingw-w64-crt's implementation of the ssp routines also
> > does need an implementation of __stpcpy_chk, even if it is hard
> > to practically produce calls to it.
> >
> > This should fix one issue discussed at
> > https://github.com/msys2/MINGW-packages/issues/5803#issuecomment-1276812143.
> >
> > Signed-off-by: Martin Storsjö 
> > ---
> >   mingw-w64-crt/Makefile.am  |  2 +-
> >   mingw-w64-crt/ssp/stpcpy_chk.c | 19 +++
> >   2 files changed, 20 insertions(+), 1 deletion(-)
> >   create mode 100644 mingw-w64-crt/ssp/stpcpy_chk.c
> >
>
> LGTM. Thanks.
>
>
> --
> Best regards,
> LIU Hao
> ___
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: Implement the __stpcpy_chk function

2022-10-14 Thread Martin Storsjö

On Fri, 14 Oct 2022, Kai Tietz wrote:


Yes, look good to me.  Wouldn't it make sense to add __mingww64_stpcpy
function, so we could provide this function in an more compatible way?


I don't see the direct need for it; mingw-w64 doesn't have it general, and 
this status quo works for most projects (if they use it, they probe for 
its existence and provide a replacement), so I don't see the potential 
gain from optionally providing it. This seemed to be the general consensus 
in https://github.com/msys2/MINGW-packages/issues/5803 too, FWIW.


// Martin



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH 3/3] headers: Declare UUID for IContextCallback

2022-10-14 Thread Alvin Wong via Mingw-w64-public
This is needed for `__uuidof(IContextCallback)` to work.
---
 mingw-w64-headers/include/ctxtcall.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mingw-w64-headers/include/ctxtcall.h 
b/mingw-w64-headers/include/ctxtcall.h
index 9fa8ec41e..65162f33f 100644
--- a/mingw-w64-headers/include/ctxtcall.h
+++ b/mingw-w64-headers/include/ctxtcall.h
@@ -57,6 +57,9 @@ extern "C"{
   public:
 virtual HRESULT WINAPI ContextCallback(PFNCONTEXTCALL 
pfnCallback,ComCallData *pParam,REFIID riid,int iMethod,IUnknown *pUnk) = 0;
   };
+#ifdef __CRT_UUID_DECL
+  
__CRT_UUID_DECL(IContextCallback,0x01da,0x,0x,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46)
+#endif
 #else
   typedef struct IContextCallbackVtbl {
 BEGIN_INTERFACE
-- 
2.37.1



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH 2/3] headers: Add declaration of CLSID_ContextSwitcher

2022-10-14 Thread Alvin Wong via Mingw-w64-public
---
 mingw-w64-headers/include/cguid.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mingw-w64-headers/include/cguid.h 
b/mingw-w64-headers/include/cguid.h
index 497c4c5b7..0ded4b743 100644
--- a/mingw-w64-headers/include/cguid.h
+++ b/mingw-w64-headers/include/cguid.h
@@ -91,6 +91,8 @@ extern "C" {
   extern const CLSID CLSID_Picture_Dib;
   extern const GUID GUID_TRISTATE;
 
+  extern const CLSID CLSID_ContextSwitcher;
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.37.1



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH 1/3] crt: Add CLSID and IIDs for IContextCallback

2022-10-14 Thread Alvin Wong via Mingw-w64-public
Define the following GUIDs in libuuid.a:

* IID_IContextCallback
* IID_ICallbackWithNoReentrancyToApplicationSTA
* IID_IEnterActivityWithNoLock
* CLSID_ContextSwitcher
---
 mingw-w64-crt/Makefile.am|  1 +
 mingw-w64-crt/libsrc/ctxtcall-uuid.c | 18 ++
 2 files changed, 19 insertions(+)
 create mode 100644 mingw-w64-crt/libsrc/ctxtcall-uuid.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 053eab3cf..52b2a06f0 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -140,6 +140,7 @@ src_adsiid=libsrc/activeds-uuid.c
 
 src_libuuid=\
   libsrc/ativscp-uuid.c   libsrc/atsmedia-uuid.clibsrc/bth-uuid.c 
libsrc/cguid-uuid.c libsrc/comcat-uuid.c   \
+  libsrc/ctxtcall-uuid.c \
   libsrc/devguid.clibsrc/docobj-uuid.c  libsrc/dxva-uuid.c
libsrc/exdisp-uuid.clibsrc/extras-uuid.c   \
   libsrc/fwp-uuid.c   libsrc/guid_nul.c libsrc/hlguids-uuid.c 
libsrc/hlink-uuid.c libsrc/mlang-uuid.c\
   libsrc/msctf-uuid.c libsrc/mshtmhst-uuid.clibsrc/mshtml-uuid.c  
libsrc/msxml-uuid.c libsrc/netcfg-uuid.c   \
diff --git a/mingw-w64-crt/libsrc/ctxtcall-uuid.c 
b/mingw-w64-crt/libsrc/ctxtcall-uuid.c
new file mode 100644
index 0..0274b4868
--- /dev/null
+++ b/mingw-w64-crt/libsrc/ctxtcall-uuid.c
@@ -0,0 +1,18 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#define INITGUID
+#include 
+
+// These IIDs are used for IContextCallback::ContextCallback (ctxtcall.h)
+// according to various sources.
+
+DEFINE_GUID(IID_IContextCallback,0x01da,0x,0x,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
+DEFINE_GUID(IID_ICallbackWithNoReentrancyToApplicationSTA,0x0a299774,0x3e4e,0xfc42,0x1d,0x9d,0x72,0xce,0xe1,0x05,0xca,0x57);
+DEFINE_GUID(IID_IEnterActivityWithNoLock,0xd7174f82,0x36b8,0x4aa8,0x80,0x0a,0xe9,0x63,0xab,0x2d,0xfa,0xb9);
+
+// This CLSID is used to create IContextCallback.
+DEFINE_GUID(CLSID_ContextSwitcher,0x034e,0x,0x,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
-- 
2.37.1



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: Implement the __stpcpy_chk function

2022-10-14 Thread LIU Hao

在 2022/10/14 19:38, Martin Storsjö 写道:

Initially, it may seem like this function might not be needed in any
form, since mingw-w64 lacks the main stpcpy function.

However, third party projects may contain their own implementation of
the stpcpy function. When GCC sees a declaration of the stpcpy function,
it assumes that it is legal to do optimizations on strcpy+strlen into
stpcpy.

When strcpy is wrapped with fortification wrappers, so that strcpy
ends up calling __builtin___strcpy_chk (which then calls __strcpy_chk),
GCC can also transform this into __builtin___stpcpy_chk, which can
generate a call to __stpcpy_chk.

GCC's libssp does provide an implementation of __stpcpy_chk, even if
the platform itself lacks stpcpy.

Therefore, mingw-w64-crt's implementation of the ssp routines also
does need an implementation of __stpcpy_chk, even if it is hard
to practically produce calls to it.

This should fix one issue discussed at
https://github.com/msys2/MINGW-packages/issues/5803#issuecomment-1276812143.

Signed-off-by: Martin Storsjö 
---
  mingw-w64-crt/Makefile.am  |  2 +-
  mingw-w64-crt/ssp/stpcpy_chk.c | 19 +++
  2 files changed, 20 insertions(+), 1 deletion(-)
  create mode 100644 mingw-w64-crt/ssp/stpcpy_chk.c



LGTM. Thanks.


--
Best regards,
LIU Hao


OpenPGP_signature
Description: OpenPGP digital signature
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: Move xmllite to lib-common

2022-10-14 Thread Martin Storsjö

On Thu, 13 Oct 2022, Alvin Wong via Mingw-w64-public wrote:


Signed-off-by: Alvin Wong 
---
Quick-tested on x86 and x64.

mingw-w64-crt/{libarm32 => lib-common}/xmllite.def |  2 +-
mingw-w64-crt/lib32/Makefile.am|  1 +
mingw-w64-crt/lib32/xmllite.def| 13 +
mingw-w64-crt/lib64/Makefile.am|  1 +
mingw-w64-crt/libarm64/Makefile.am |  1 +
5 files changed, 17 insertions(+), 1 deletion(-)
rename mingw-w64-crt/{libarm32 => lib-common}/xmllite.def (89%)
create mode 100644 mingw-w64-crt/lib32/xmllite.def


LGTM, pushed. Thanks!

// Martin



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] [PATCH] crt: Implement the __stpcpy_chk function

2022-10-14 Thread Martin Storsjö
Initially, it may seem like this function might not be needed in any
form, since mingw-w64 lacks the main stpcpy function.

However, third party projects may contain their own implementation of
the stpcpy function. When GCC sees a declaration of the stpcpy function,
it assumes that it is legal to do optimizations on strcpy+strlen into
stpcpy.

When strcpy is wrapped with fortification wrappers, so that strcpy
ends up calling __builtin___strcpy_chk (which then calls __strcpy_chk),
GCC can also transform this into __builtin___stpcpy_chk, which can
generate a call to __stpcpy_chk.

GCC's libssp does provide an implementation of __stpcpy_chk, even if
the platform itself lacks stpcpy.

Therefore, mingw-w64-crt's implementation of the ssp routines also
does need an implementation of __stpcpy_chk, even if it is hard
to practically produce calls to it.

This should fix one issue discussed at
https://github.com/msys2/MINGW-packages/issues/5803#issuecomment-1276812143.

Signed-off-by: Martin Storsjö 
---
 mingw-w64-crt/Makefile.am  |  2 +-
 mingw-w64-crt/ssp/stpcpy_chk.c | 19 +++
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 mingw-w64-crt/ssp/stpcpy_chk.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 053eab3cf..1dff68409 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -566,7 +566,7 @@ src_libmingwex=\
   \
   ssp/chk_fail.c ssp/memcpy_chk.c   ssp/memmove_chk.c   
ssp/mempcpy_chk.c \
   ssp/memset_chk.c   ssp/stack_chk_fail.c   ssp/stack_chk_guard.c   
ssp/strcat_chk.c \
-  ssp/strcpy_chk.c   ssp/strncat_chk.c  ssp/strncpy_chk.c \
+  ssp/stpcpy_chk.c   ssp/strcpy_chk.c   ssp/strncat_chk.c   
ssp/strncpy_chk.c \
   \
   stdio/mingw_pformat.h\
   stdio/scanf2-argcount-char.c stdio/scanf2-argcount-wchar.c \
diff --git a/mingw-w64-crt/ssp/stpcpy_chk.c b/mingw-w64-crt/ssp/stpcpy_chk.c
new file mode 100644
index 0..aaa387680
--- /dev/null
+++ b/mingw-w64-crt/ssp/stpcpy_chk.c
@@ -0,0 +1,19 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include 
+
+void __cdecl __chk_fail(void) __attribute__((__noreturn__));
+
+char *__cdecl __stpcpy_chk(char *dst, const char *src, size_t bufsize);
+
+char *__cdecl __stpcpy_chk(char *dst, const char *src, size_t bufsize)
+{
+  size_t n = strlen(src);
+  if (n >= bufsize)
+__chk_fail();
+  return memcpy(dst, src, n + 1) + n;
+}
-- 
2.25.1



___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public