Re: [Mingw-w64-public] [PATCH] headers: Add coclasses in rdpencomapi.idl

2021-04-28 Thread Liu Hao

在 2021-04-29 01:47, Biswapriyo Nath 写道:

It seems that lh_mouse misses my previous updated patch of
rdpencomapi.idl. I should have sent full patch at once. But no
problem. Here is the addition to that rdpencomapi.idl. Also
Makefile.in was not regenerated last time.



Oops, apologies. Updated and pushed. 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: Increase precision of gettimeofday() if possible.

2021-04-28 Thread Vincent Torri
On Wed, Apr 28, 2021 at 9:35 PM Christian Franke
 wrote:
>
> Liu Hao wrote:
> > 在 4/27/21 2:00 AM, Christian Franke 写道:
> >>
> >> Which complexity do you mean - the extra cost of the system call or
> >> the extra 15 lines of code?
> >>
> >
> > It's actually both.
> >
> > Wall clocks are not meant to be steady, because they are free to jump
> > back and forth due to NTP synchronization, and arithmetic operations
> > aren't predicable either due to leap seconds.
>
> That's all correct. But there are several use cases where a higher than
> this ~15.6ms (1/64s) resolution is needed and where occasional clock
> jumps are acceptable - for example debug logs.
>
> If there were no use cases, the evolution
>time() -> ftime(...) -> gettimeofday(...) ->
> clock_gettime(CLOCK_REALTIME,...)
> would possibly never have happened :-)
>
> BTW.1: Hack:
> Do this once in the program
>#ifdef _WIN32
>  timeBeginPeriod(1);

https://docs.microsoft.com/fr-fr/windows/win32/api/timeapi/nf-timeapi-timebeginperiod?redirectedfrom=MSDN

"Setting a higher resolution can improve the accuracy of time-out
intervals in wait functions. However, it can also reduce overall
system performance, because the thread scheduler switches tasks more
often. High resolutions can also prevent the CPU power management
system from entering power-saving modes. "

also, just for more information about this discussion:
https://devblogs.microsoft.com/oldnewthing/20170921-00/?p=97057

Vincent Torri


___
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: Increase precision of gettimeofday() if possible.

2021-04-28 Thread Christian Franke

Liu Hao wrote:

在 4/27/21 2:00 AM, Christian Franke 写道:


Which complexity do you mean - the extra cost of the system call or 
the extra 15 lines of code?




It's actually both.

Wall clocks are not meant to be steady, because they are free to jump 
back and forth due to NTP synchronization, and arithmetic operations 
aren't predicable either due to leap seconds. 


That's all correct. But there are several use cases where a higher than 
this ~15.6ms (1/64s) resolution is needed and where occasional clock 
jumps are acceptable - for example debug logs.


If there were no use cases, the evolution
  time() -> ftime(...) -> gettimeofday(...) -> 
clock_gettime(CLOCK_REALTIME,...)

would possibly never have happened :-)

BTW.1: Hack:
Do this once in the program
  #ifdef _WIN32
    timeBeginPeriod(1);
  #endif
or start another program which does: Playback a video, run a VM in VBox, 
run VS 2019, ...
... and the resolution of GetSystemTimeAsFileTime() increases from 1/64s 
to 1-2ms.


BTW.2: The *ftime*() functions from newer versions of MSVC CRT also use 
GetSystemTimePreciseAsFileTime() if available.



Introduction of more overhead upon each call, for some unpredictable 
and unreliable accuracy, is futile.


I guess then it is not worth the effort to provide a related patch for 
clock_gettime(CLOCK_REALTIME, ...) ?-)





There are also some issues in this patch. You can't assign a `void*` 
to a pointer-to-function.


The 'void *' was a hack to silence this warning from gcc 10.2.0:

get_time = (GetSystemTimeAsFileTime_t) GetProcAddress (...)
"warning: cast between incompatible function types from ‘FARPROC’ {aka 
‘long long int (*)()’} to ‘void (*)(struct _FILETIME *)’ 
[-Wcast-function-type]"


A detour via 'intptr_t' would also help but might be considered as ugly 
as 'void *':


get_time = (GetSystemTimeAsFileTime_t)(intptr_t) GetProcAddress (...)


And you can't use `volatile` variables for synchronization; you have 
to use `_Atomic` which yet adds more complexity in code.


That's right, in theory, 'volatile' would still allow to read the 
pointer in two halves or so. Using '_Atomic' instead actually changes 
the code generated by gcc 10.2.0 -O2, but only few register assignments 
but no memory accesses.








AFAICS, my patch would switch the Mingw-w64 column to '2'.

BTW: None of the above provide an extra high_resolution_clock:
GNU Libstdc++ Headers: using high_resolution_clock = system_clock;
Cygwin (Clang headers), MSVC16: using high_resolution_clock = 
steady_clock;




`high_resolution_clock` should call `QueryPerformanceCounter()` on 
Windows or `clock_gettime()` on POSIX systems. `gettimeofday()` is 
apparently not an option, as it is not suitable for measurement. The 
libstdc++ implementation should be considered faulty. I suggest people 
avoid its use.




Several issues accumulate here:
- The Mingw-w64 implementations of 'gettimeofday()' and 
'clock_gettime(CLOCK_REALTIME,...)' provide only 1/64s resolution.
- Mingw-w64 libstdc++ packages are usually configured with 
_GLIBCXX_USE_GETTIMEOFDAY set and _GLIBCXX_USE_CLOCK_REALTIME and 
..._MONOTONIC unset.
- Libstdc++ sets 'using high_resolution_clock = system_clock'. This 
should be configurable.
As a consequence, the steady_clock is not steady and the 
high_resolution_clock has no high resolution.


- Defining _GLIBCXX_USE_CLOCK_MONOTONIC would fix the steady_clock. 
Drawback: Without '-static', the 'libwinpthreads-1.dll' is required.
- And then  'using high_resolution_clock = steady_clock' would fix the 
high_resolution clock. Drawback: same as above + fix is outside 
Mingw-w64 source tree.


--
Best regards,
Christian Franke



___
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: Increase precision of gettimeofday() if possible.

2021-04-28 Thread sotrdg sotrdg
https://github.com/expnkx/fast_io/blob/725695664091bc4e8fbb05df446aaad93642bbf5/include/fast_io_hosted/time.h#L406
This is my implementation for clock_gettime

Sent from Mail for Windows 10

From: Corinna Vinschen
Sent: Wednesday, April 28, 2021 15:05
To: 
mingw-w64-public@lists.sourceforge.net
Subject: Re: [Mingw-w64-public] [PATCH] crt: Increase precision of 
gettimeofday() if possible.

On Apr 26 20:00, Christian Franke wrote:
> System calls and resolutions of C++11 clocks:
>
>Mingw-w64 MSVC16  Cygwin
> system_clock::now()   12   2
> steady_clock::now()   13   3
> high_resolution_clock::now()  13   3
>
> where
> 1: GetSystemTimeAsFileTime: >15ms to 1ms (unpredictable)
> 2: GetSystemTimePreciseAsFileTime: <1us
> 3: QueryPerformanceCounter: <500ns

Not quite.  Newer Windows versions support better alternatives compared
to QueryPerformanceCounter.  Thus on newer systems Cygwin uses

  QueryUnbiasedInterruptTimePrecise for CLOCK_MONOTONIC{_RAW}
  QueryUnbiasedInterruptTimefor CLOCK_MONOTONIC_COARSE
  QueryInterruptTimePrecise for CLOCK_BOOTTIME{_ALARM}

and, of course

  GetSystemTimePreciseAsFileTimefor CLOCK_REALTIME
  GetSystemTimeAsFileTime   for CLOCK_REALTIME_COARSE

Apart from style issues, I vote for using GetSystemTimePreciseAsFileTime
for CLOCK_REALTIME and only fall back to GetSystemTimeAsFileTime for
CLOCK_REALTIME_COARSE or if the OS doesn't support the precise call.

Please do keep in mind that there are assumptions of a minimum
precision of gettimeofday in the wild, which are not really in our
hands.  If we can avoid upstream code to #ifdef time computations
for Mingw separately, rather than just using gettimeofday on all
supported platforms, it's certainly a win-win, isn't it?


Corinna



___
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: Increase precision of gettimeofday() if possible.

2021-04-28 Thread Corinna Vinschen
On Apr 26 20:00, Christian Franke wrote:
> System calls and resolutions of C++11 clocks:
> 
>    Mingw-w64 MSVC16  Cygwin
> system_clock::now()   1    2   2
> steady_clock::now()   1    3   3
> high_resolution_clock::now()  1    3   3
> 
> where
> 1: GetSystemTimeAsFileTime: >15ms to 1ms (unpredictable)
> 2: GetSystemTimePreciseAsFileTime: <1us
> 3: QueryPerformanceCounter: <500ns

Not quite.  Newer Windows versions support better alternatives compared
to QueryPerformanceCounter.  Thus on newer systems Cygwin uses

  QueryUnbiasedInterruptTimePrecise for CLOCK_MONOTONIC{_RAW}
  QueryUnbiasedInterruptTimefor CLOCK_MONOTONIC_COARSE
  QueryInterruptTimePrecise for CLOCK_BOOTTIME{_ALARM}

and, of course

  GetSystemTimePreciseAsFileTimefor CLOCK_REALTIME
  GetSystemTimeAsFileTime   for CLOCK_REALTIME_COARSE

Apart from style issues, I vote for using GetSystemTimePreciseAsFileTime
for CLOCK_REALTIME and only fall back to GetSystemTimeAsFileTime for
CLOCK_REALTIME_COARSE or if the OS doesn't support the precise call.

Please do keep in mind that there are assumptions of a minimum 
precision of gettimeofday in the wild, which are not really in our
hands.  If we can avoid upstream code to #ifdef time computations
for Mingw separately, rather than just using gettimeofday on all
supported platforms, it's certainly a win-win, isn't it?


Corinna



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


[Mingw-w64-public] [PATCH] headers: Add coclasses in rdpencomapi.idl

2021-04-28 Thread Biswapriyo Nath
It seems that lh_mouse misses my previous updated patch of
rdpencomapi.idl. I should have sent full patch at once. But no
problem. Here is the addition to that rdpencomapi.idl. Also
Makefile.in was not regenerated last time.
From aa44619f81115fab1cc41804d9531295a87db7f0 Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath 
Date: Wed, 28 Apr 2021 23:12:56 +0530
Subject: [PATCH] headers: Add coclasses in rdpencomapi.idl

Signed-off-by: Biswapriyo Nath 
---
 mingw-w64-headers/include/rdpencomapi.idl | 318 ++
 1 file changed, 318 insertions(+)

diff --git a/mingw-w64-headers/include/rdpencomapi.idl 
b/mingw-w64-headers/include/rdpencomapi.idl
index 121f29d..0dbc4ef 100644
--- a/mingw-w64-headers/include/rdpencomapi.idl
+++ b/mingw-w64-headers/include/rdpencomapi.idl
@@ -617,4 +617,322 @@ interface IRDPSRAPITransportStreamBuffer : IUnknown
   HRESULT Context([in] IUnknown *pContext);
 }
 
+[object, uuid(ea81c254-f5af-4e40-982e-3e63bb595276), local, 
pointer_default(unique)]
+interface IRDPSRAPITransportStreamEvents : IUnknown
+{
+  [id(DISPID_RDPSRAPI_EVENT_ON_STREAM_SENDCOMPLETED)]
+  void OnWriteCompleted([in] IRDPSRAPITransportStreamBuffer *pBuffer);
+
+  [id(DISPID_RDPSRAPI_EVENT_ON_STREAM_DATARECEIVED)]
+  void OnReadCompleted([in] IRDPSRAPITransportStreamBuffer *pBuffer);
+
+  [id(DISPID_RDPSRAPI_EVENT_ON_STREAM_CLOSED)]
+  void OnStreamClosed([in] HRESULT hrReason);
+}
+
+[object, uuid(36cfa065-43bb-4ef7-aed7-9b88a5053036), pointer_default(unique)]
+interface IRDPSRAPITransportStream : IUnknown
+{
+  [id(DISPID_RDPSRAPI_METHOD_STREAM_ALLOCBUFFER)]
+  HRESULT AllocBuffer([in] long maxPayload, [out, retval] 
IRDPSRAPITransportStreamBuffer **ppBuffer);
+
+  [id(DISPID_RDPSRAPI_METHOD_STREAM_FREEBUFFER)]
+  HRESULT FreeBuffer([in] IRDPSRAPITransportStreamBuffer *pBuffer);
+
+  [id(DISPID_RDPSRAPI_METHOD_STREAMSENDDATA)]
+  HRESULT WriteBuffer([in] IRDPSRAPITransportStreamBuffer *pBuffer);
+
+  [id(DISPID_RDPSRAPI_METHOD_STREAMREADDATA)]
+  HRESULT ReadBuffer([in] IRDPSRAPITransportStreamBuffer *pBuffer);
+
+  [id(DISPID_RDPSRAPI_METHOD_STREAMOPEN)]
+  HRESULT Open([in] IRDPSRAPITransportStreamEvents *pCallbacks);
+
+  [id(DISPID_RDPSRAPI_METHOD_STREAMCLOSE)]
+  HRESULT Close(void);
+}
+
+[object, uuid(eeb20886-e470-4cf6-842b-2739c0ec5cfb), dual, 
pointer_default(unique)]
+interface IRDPSRAPISharingSession : IDispatch
+{
+  [id(DISPID_RDPSRAPI_METHOD_OPEN)]
+  HRESULT Open(void);
+
+  [id(DISPID_RDPSRAPI_METHOD_CLOSE)]
+  HRESULT Close(void);
+
+  [propput, id(DISPID_RDPSRAPI_PROP_SESSION_COLORDEPTH)]
+  HRESULT ColorDepth([in] long colorDepth);
+
+  [propget, id(DISPID_RDPSRAPI_PROP_SESSION_COLORDEPTH)]
+  HRESULT ColorDepth([out, retval] long *pColorDepth);
+
+  [propget, id(DISPID_RDPSRAPI_PROP_SESSION_PROPERTIES)]
+  HRESULT Properties([out, retval] IRDPSRAPISessionProperties **ppVal);
+
+  [propget, id(DISPID_RDPSRAPI_PROP_ATTENDEES)]
+  HRESULT Attendees([out, retval] IRDPSRAPIAttendeeManager **ppVal);
+
+  [propget, id(DISPID_RDPSRAPI_PROP_INVITATIONS)]
+  HRESULT Invitations([out, retval] IRDPSRAPIInvitationManager **ppVal);
+
+  [propget, id(DISPID_RDPSRAPI_PROP_APPLICATION_FILTER)]
+  HRESULT ApplicationFilter([out, retval] IRDPSRAPIApplicationFilter **ppVal);
+
+  [propget, id(DISPID_RDPSRAPI_PROP_CHANNELMANAGER)]
+  HRESULT VirtualChannelManager([out, retval] IRDPSRAPIVirtualChannelManager 
**ppVal);
+
+  [id(DISPID_RDPSRAPI_METHOD_PAUSE)]
+  HRESULT Pause(void);
+
+  [id(DISPID_RDPSRAPI_METHOD_RESUME)]
+  HRESULT Resume(void);
+
+  [id(DISPID_RDPSRAPI_METHOD_CONNECTTOCLIENT)]
+  HRESULT ConnectToClient([in] BSTR bstrConnectionString);
+
+  [id(DISPID_RDPSRAPI_METHOD_SETSHAREDRECT)]
+  HRESULT SetDesktopSharedRect([in] long left, [in] long top, [in] long right, 
[in] long bottom);
+
+  [id(DISPID_RDPSRAPI_METHOD_GETSHAREDRECT)]
+  HRESULT GetDesktopSharedRect([out] long *pleft, [out] long *ptop, [out] long 
*pright, [out] long *pbottom);
+}
+
+[object, uuid(fee4ee57-e3e8-4205-8fb0-8fd1d0675c21), dual, 
pointer_default(unique)]
+interface IRDPSRAPISharingSession2 : IRDPSRAPISharingSession
+{
+  [id(DISPID_RDPSRAPI_METHOD_CONNECTUSINGTRANSPORTSTREAM)]
+  HRESULT ConnectUsingTransportStream([in] IRDPSRAPITransportStream *pStream, 
[in] BSTR bstrGroup, [in] BSTR bstrAuthenticatedAttendeeName);
+
+  [propget, id(DISPID_RDPSRAPI_PROP_FRAMEBUFFER)]
+  HRESULT FrameBuffer([out, retval] IRDPSRAPIFrameBuffer **ppVal);
+
+  [id(DISPID_RDPSRAPI_METHOD_SENDCONTROLLEVELCHANGERESPONSE)]
+  HRESULT SendControlLevelChangeResponse([in] IRDPSRAPIAttendee *pAttendee, 
[in] CTRL_LEVEL RequestedLevel, [in] long ReasonCode);
+}
+
+[uuid(cc802d05-ae07-4c15-b496-db9d22aa0a84), version(1.0)]
+library RDPCOMAPILib
+{
+  importlib("stdole32.tlb");
+  importlib("stdole2.tlb");
+
+  typedef enum
+  {
+CONST_MAX_CHANNEL_MESSAGE_SIZE = 1024,
+CONST_MAX_CHANNEL_NAME_LEN = 8,
+CONST_MAX_LEGACY_CHANNEL_MESSAGE_SIZE = 409600,
+CONST_ATTENDEE_ID_EVERYONE = -1,
+CONST_ATTENDEE_ID_HOST = 0,
+CONST_

Re: [Mingw-w64-public] Add missing function declarations to mingw-w64-headers/include/shlwapi.h

2021-04-28 Thread DAVID MAY
Thank you for your feedback.

I removed those changes.  Updated patch attached.

--
David May

On 28/04/2021 5:59 pm, Liu Hao wrote:
> 在 4/28/21 12:50 PM, DAVID MAY 写道:
>> Thanks for the feedback.
>>
>> Regarding points 1 and 2: While changing the #ifdefs and adding comments
>> (actually just labels) was not necessary, keeping track of the
>> unlabelled #ifdefs and #ifs gave me headaches.  The labels helped.
>> Anyway, all labels are now removed.
>>
>> Regarding point 3:  I have changed the code to C89 style and added a
>> check for C89 conformance to my tests.
>>
>> An updated patch is attached.
>>
> 
> The reason why sometimes `#ifndef ...` is preferred to `#if
> !defined(...)` is that the former is aligned with `#define ...` in an
> editor, like this:
> 
>   ```
>   #ifndef SOME_MACRO
>   #define SOME_MACRO 1
>   #endif
>   ```
> 
> And please submit an isolated and atomic patch - not one that changes
> `#ifndef` to `#if !defined`, and adds other stuff at the same time. If
> it is really necessary for you, please send a distinct patch.
> 
> 
--- doc/mingw64-shlwapi.h   2021-04-28 21:40:36.145098000 +0800
+++ shlwapi.h   2021-04-28 22:01:14.220795200 +0800
@@ -14,6 +14,7 @@
 #include 
 #include 
 
+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) 
 #ifndef WINSHLWAPI
 #if !defined(_SHLWAPI_)
 #define LWSTDAPI EXTERN_C DECLSPEC_IMPORT HRESULT WINAPI
@@ -28,8 +29,6 @@
 #endif
 #endif
 
-#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-
 #ifndef _WINRESRC_
 #ifndef _WIN32_IE
 #define _WIN32_IE 0x0601
@@ -38,6 +37,11 @@
 
 #include 
 
+#ifndef __IBindCtx_FWD_DEFINED__
+#define __IBindCtx_FWD_DEFINED__
+  typedef interface IBindCtx IBindCtx;
+#endif 
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -47,10 +51,23 @@
   LWSTDAPI_(LPWSTR) StrChrW(LPCWSTR lpStart,WCHAR wMatch);
   LWSTDAPI_(LPSTR) StrChrIA(LPCSTR lpStart,WORD wMatch);
   LWSTDAPI_(LPWSTR) StrChrIW(LPCWSTR lpStart,WCHAR wMatch);
+  LWSTDAPI_(PCWSTR) StrChrNW(PCWSTR pszStart, WCHAR wMatch, UINT cchMax);
+  LWSTDAPI_(PCWSTR) StrChrNIW(PCWSTR pszStart, WCHAR wMatch, UINT cchMax);
   LWSTDAPI_(int) StrCmpNA(LPCSTR lpStr1,LPCSTR lpStr2,int nChar);
   LWSTDAPI_(int) StrCmpNW(LPCWSTR lpStr1,LPCWSTR lpStr2,int nChar);
   LWSTDAPI_(int) StrCmpNIA(LPCSTR lpStr1,LPCSTR lpStr2,int nChar);
   LWSTDAPI_(int) StrCmpNIW(LPCWSTR lpStr1,LPCWSTR lpStr2,int nChar);
+
+  LWSTDAPI_(int) StrCmpNCA(LPCSTR pszStr1, LPCSTR pszStr2, int nChar);
+  LWSTDAPI_(int) StrCmpNCW(LPCWSTR pszStr1, LPCWSTR pszStr2, int nChar);
+
+#define StrCmpNC __MINGW_NAME_AW(StrCmpNC)
+
+  LWSTDAPI_(int)  StrCmpNICA(LPCSTR pszStr1, LPCSTR pszStr2, int nChar);
+  LWSTDAPI_(int)  StrCmpNICW(LPCWSTR pszStr1, LPCWSTR pszStr2, int nChar);
+
+#define StrCmpNIC __MINGW_NAME_AW(StrCmpNIC)
+
   LWSTDAPI_(int) StrCSpnA(LPCSTR lpStr,LPCSTR lpSet);
   LWSTDAPI_(int) StrCSpnW(LPCWSTR lpStr,LPCWSTR lpSet);
   LWSTDAPI_(int) StrCSpnIA(LPCSTR lpStr,LPCSTR lpSet);
@@ -82,13 +99,20 @@
   LWSTDAPI_(LPWSTR) StrStrW(LPCWSTR lpFirst,LPCWSTR lpSrch);
   LWSTDAPI_(LPSTR) StrStrIA(LPCSTR lpFirst,LPCSTR lpSrch);
   LWSTDAPI_(LPWSTR) StrStrIW(LPCWSTR lpFirst,LPCWSTR lpSrch);
+  LWSTDAPI_(PCWSTR) StrStrNW(PCWSTR pszFirst, PCWSTR pszSrch, UINT cchMax);
+  LWSTDAPI_(PCWSTR) StrStrNIW(PCWSTR pszFirst, PCWSTR pszSrch, UINT cchMax);
   LWSTDAPI_(int) StrToIntA(LPCSTR lpSrc);
   LWSTDAPI_(int) StrToIntW(LPCWSTR lpSrc);
-  LWSTDAPI_(WINBOOL) StrToIntExA(LPCSTR pszString,DWORD dwFlags,int *piRet);
-  LWSTDAPI_(WINBOOL) StrToIntExW(LPCWSTR pszString,DWORD dwFlags,int *piRet);
+
+#define STIF_DEFAULT __MSABI_LONG(0x)
+#define STIF_SUPPORT_HEX __MSABI_LONG(0x0001)
+  typedef int STIF_FLAGS;
+
+  LWSTDAPI_(WINBOOL) StrToIntExA(LPCSTR pszString,STIF_FLAGS dwFlags,int 
*piRet);
+  LWSTDAPI_(WINBOOL) StrToIntExW(LPCWSTR pszString,STIF_FLAGS dwFlags,int 
*piRet);
 #if (_WIN32_IE >= 0x0600)
-  LWSTDAPI_(WINBOOL) StrToInt64ExA(LPCSTR pszString,DWORD dwFlags,LONGLONG 
*pllRet);
-  LWSTDAPI_(WINBOOL) StrToInt64ExW(LPCWSTR pszString,DWORD dwFlags,LONGLONG 
*pllRet);
+  LWSTDAPI_(WINBOOL) StrToInt64ExA(LPCSTR pszString,STIF_FLAGS 
dwFlags,LONGLONG *pllRet);
+  LWSTDAPI_(WINBOOL) StrToInt64ExW(LPCWSTR pszString,STIF_FLAGS 
dwFlags,LONGLONG *pllRet);
 #endif
   LWSTDAPI_(WINBOOL) StrTrimA(LPSTR psz,LPCSTR pszTrimChars);
   LWSTDAPI_(WINBOOL) StrTrimW(LPWSTR psz,LPCWSTR pszTrimChars);
@@ -122,9 +146,25 @@
   LWSTDAPI StrRetToBSTR(STRRET *pstr,LPCITEMIDLIST pidl,BSTR *pbstr);
   LWSTDAPI SHStrDupA(LPCSTR psz,WCHAR **ppwsz);
   LWSTDAPI SHStrDupW(LPCWSTR psz,WCHAR **ppwsz);
+
+#ifdef __cplusplus
+  inline HRESULT SHLocalStrDupW(PCWSTR psz, PWSTR *ppsz) {
+*ppsz = StrDupW(psz);
+return *ppsz ? S_OK : E_OUTOFMEMORY;
+  }
+
+  inline HRESULT SHLocalStrDupA(PCSTR psz, PSTR *ppsz) {
+*ppsz = StrDupA(psz);
+return *ppsz ? S_OK : E_OUTOFMEMORY;
+  }
+
+#define SHLocalStrDup __MINGW_NAME_AW(SHLocalStrDup)
+#endif 
+
   LWSTDAPI_(int) StrCmpLogicalW(LPCWSTR psz1,LPCWSTR psz2);
   LWSTDAPI_(DWORD

Re: [Mingw-w64-public] [PATCH] headers/sec_api: Add strnlen_s definition.

2021-04-28 Thread Liu Hao

在 2021-04-28 14:31, Biswapriyo Nath 写道:

Subject: [PATCH] headers/sec_api: Add strnlen_s definition.

Signed-off-by: Biswapriyo Nath
---
  mingw-w64-headers/crt/sec_api/string_s.h | 4 
  1 file changed, 4 insertions(+)


Subject: [PATCH] headers: Add rdpencomapi.idl file.

Signed-off-by: Biswapriyo Nath 
---
 mingw-w64-headers/Makefile.am |   1 +
 mingw-w64-headers/include/rdpencomapi.idl | 620 ++
 2 files changed, 621 insertions(+)
 create mode 100644 mingw-w64-headers/include/rdpencomapi.idl



Thanks. These patches look good to me. I pushed them to master.


--
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] Add missing function declarations to mingw-w64-headers/include/shlwapi.h

2021-04-28 Thread Liu Hao

在 4/28/21 12:50 PM, DAVID MAY 写道:

Thanks for the feedback.

Regarding points 1 and 2: While changing the #ifdefs and adding comments
(actually just labels) was not necessary, keeping track of the
unlabelled #ifdefs and #ifs gave me headaches.  The labels helped.
Anyway, all labels are now removed.

Regarding point 3:  I have changed the code to C89 style and added a
check for C89 conformance to my tests.

An updated patch is attached.



The reason why sometimes `#ifndef ...` is preferred to `#if !defined(...)` is that the former is 
aligned with `#define ...` in an editor, like this:


  ```
  #ifndef SOME_MACRO
  #define SOME_MACRO 1
  #endif
  ```

And please submit an isolated and atomic patch - not one that changes `#ifndef` to `#if !defined`, 
and adds other stuff at the same time. If it is really necessary for you, please send a distinct patch.



--
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: Increase precision of gettimeofday() if possible.

2021-04-28 Thread Liu Hao

在 4/27/21 2:00 AM, Christian Franke 写道:


Which complexity do you mean - the extra cost of the system call or the extra 
15 lines of code?



It's actually both.

Wall clocks are not meant to be steady, because they are free to jump back and forth due to NTP 
synchronization, and arithmetic operations aren't predicable either due to leap seconds. 
Introduction of more overhead upon each call, for some unpredictable and unreliable accuracy, is futile.


There are also some issues in this patch. You can't assign a `void*` to a pointer-to-function. And 
you can't use `volatile` variables for synchronization; you have to use `_Atomic` which yet adds 
more complexity in code.





AFAICS, my patch would switch the Mingw-w64 column to '2'.

BTW: None of the above provide an extra high_resolution_clock:
GNU Libstdc++ Headers: using high_resolution_clock = system_clock;
Cygwin (Clang headers), MSVC16: using high_resolution_clock = steady_clock;



`high_resolution_clock` should call `QueryPerformanceCounter()` on Windows or `clock_gettime()` on 
POSIX systems. `gettimeofday()` is apparently not an option, as it is not suitable for measurement. 
The libstdc++ implementation should be considered faulty. I suggest people avoid its use.



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