Re: [Mingw-w64-public] [PATCH] crt: Increase precision of gettimeofday() if possible.

2021-05-02 Thread Martin Storsjö

On Wed, 28 Apr 2021, 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?




Just for the record - I wouldn't mind applying the patch or something like 
it. I agree with the arguments that it would be beneficial to get more 
precision here, even if one in general maybe can argue that we don't 
strictly need to provide such precision.


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


We have lots of cases of wrappers that do GetProcAddress() in 
mingw-w64-crt, and a lot of them use a plain (void*) cast. (Others do cast 
the return value of GetProcAddress() directly to the type of the function 
pointer.)


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


FWIW lots of similar existing cases in mingw-w64-crt just use a plain 
global pointer that is overwritten, without any atomicity. Just grep for 
GetProcAddress in mingw-w64-crt and look at all the existing cases. Many 
of them go via an __MINGW_IMP_SYMBOL pointer which first points at an init 
function, which then updates the __MINGW_IMP_SYMBOL pointer - but that's 
essentially the same as here even though this is a static pointer and used 
inline in a different function.


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

2021-05-02 Thread Liu Hao

在 2021-05-03 00:39, Dan Raymond 写道:
I don't agree with this.  First: precision and accuracy are two entirely different things so it's 
important not to use them interchangeably.  It is true that the absolute value of the wall clock 
time is not likely to be very accurate.  If you are interested in the absolute value then increasing 
precision in clock_gettime() is not going to help you.  But if you 
are interested in the relative 
difference between two consecutive wall clock times then high precision 
is useful.  Log timestamps 
are an excellent example of this.  I probably won't care if event 1 happened at exactly 
10:28:16.594.  However I will likely care very much about the precision of the interval between 
event 1 and event 2.  I don't understand your claim that only the order of writes matters in logs.  
If that were true then we wouldn't use timestamps at all.





Yes, you are right, and should one prefer `system_clock`, `steady_clock` or `high_resolution_clock` 
under such circumstances? Why not call `GetSystemTimePreciseAsFileTime()` 
directly?




--
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] headers: Add missing names in shlwapi.h

2021-05-02 Thread Liu Hao

在 2021-05-03 01:53, Biswapriyo Nath 写道:

 From 3bde731614cf9ea87f75a98752b905785b984485 Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath
Date: Sun, 2 May 2021 23:21:56 +0530
Subject: [PATCH] headers: Add missing names in shlwapi.h

Signed-off-by: Biswapriyo Nath
---
  mingw-w64-headers/include/shlwapi.h | 32 -
  1 file changed, 27 insertions(+), 5 deletions(-)



Thanks. This patch looks good to me. Pushed.


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


[Mingw-w64-public] [PATCH] headers: Add missing names in shlwapi.h

2021-05-02 Thread Biswapriyo Nath

From 3bde731614cf9ea87f75a98752b905785b984485 Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath 
Date: Sun, 2 May 2021 23:21:56 +0530
Subject: [PATCH] headers: Add missing names in shlwapi.h

Signed-off-by: Biswapriyo Nath 
---
 mingw-w64-headers/include/shlwapi.h | 32 -
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-headers/include/shlwapi.h 
b/mingw-w64-headers/include/shlwapi.h
index 41ed0fe..dc10c23 100644
--- a/mingw-w64-headers/include/shlwapi.h
+++ b/mingw-w64-headers/include/shlwapi.h
@@ -601,7 +601,18 @@ LWSTDAPI PathMatchSpecExW(LPCWSTR pszFile, LPCWSTR 
pszSpec, DWORD dwFlags);
 #define URL_UNESCAPE_HIGH_ANSI_ONLY 0x0040
 #define URL_INTERNAL_PATH 0x0080
 #define URL_FILE_USE_PATHURL 0x0001
+#if _WIN32_IE >= _WIN32_IE_IE60SP2
 #define URL_DONT_UNESCAPE 0x0002
+#endif
+#if NTDDI_VERSION >= NTDDI_WIN7
+#define URL_ESCAPE_AS_UTF8 0x0004
+#endif
+#if NTDDI_VERSION >= NTDDI_WIN8
+#define URL_UNESCAPE_AS_UTF8 URL_ESCAPE_AS_UTF8
+#define URL_ESCAPE_ASCII_URI_COMPONENT 0x0008
+#define URL_ESCAPE_URI_COMPONENT (URL_ESCAPE_ASCII_URI_COMPONENT | 
URL_ESCAPE_AS_UTF8)
+#define URL_UNESCAPE_URI_COMPONENT URL_UNESCAPE_AS_UTF8
+#endif
 #define URL_ESCAPE_PERCENT 0x1000
 #define URL_ESCAPE_SEGMENT_ONLY 0x2000
 
@@ -754,6 +765,7 @@ LWSTDAPI PathMatchSpecExW(LPCWSTR pszFile, LPCWSTR pszSpec, 
DWORD dwFlags);
 
 #define SRRF_NOEXPAND 0x1000
 #define SRRF_ZEROONFAILURE 0x2000
+#define SRRF_NOVIRT 0x4000
 
   LWSTDAPI_(LONG) SHRegGetValueA(HKEY hkey,LPCSTR pszSubKey,LPCSTR 
pszValue,SRRF dwFlags,DWORD *pdwType,void *pvData,DWORD *pcbData);
   LWSTDAPI_(LONG) SHRegGetValueW(HKEY hkey,LPCWSTR pszSubKey,LPCWSTR 
pszValue,SRRF dwFlags,DWORD *pdwType,void *pvData,DWORD *pcbData);
@@ -863,10 +875,19 @@ LWSTDAPI PathMatchSpecExW(LPCWSTR pszFile, LPCWSTR 
pszSpec, DWORD dwFlags);
 ASSOCF_REMAPRUNDLL = 0x0080,
 ASSOCF_NOFIXUPS = 0x0100,
 ASSOCF_IGNOREBASECLASS = 0x0200,
-ASSOCF_INIT_IGNOREUNKNOWN = 0x0400,
-ASSOCF_INIT_FIXED_PROGID = 0x0800,
-ASSOCF_IS_PROTOCOL = 0x1000,
-ASSOCF_INIT_FOR_FILE = 0x2000
+ASSOCF_INIT_IGNOREUNKNOWN = 0x0400
+#if NTDDI_VERSION >= NTDDI_WIN8
+,ASSOCF_INIT_FIXED_PROGID = 0x0800
+,ASSOCF_IS_PROTOCOL = 0x1000
+,ASSOCF_INIT_FOR_FILE = 0x2000
+#endif
+#if NTDDI_VERSION >= NTDDI_WIN10_RS1
+,ASSOCF_IS_FULL_URI = 0x4000
+,ASSOCF_PER_MACHINE_ONLY = 0x8000
+#endif
+#if NTDDI_VERSION >= NTDDI_WIN10_RS4
+,ASSOCF_APP_TO_APP = 0x0001
+#endif
   };
 
   typedef DWORD ASSOCF;
@@ -1213,6 +1234,7 @@ typedef const QITAB *LPCQITAB;
 #define CTF_INSIST 0x0001
 #define CTF_THREAD_REF 0x0002
 #define CTF_PROCESS_REF 0x0004
+#define CTF_COINIT_STA 0x0008
 #define CTF_COINIT 0x0008
 #if (_WIN32_IE >= _WIN32_IE_IE60)
 #define CTF_FREELIBANDEXIT 0x0010
@@ -1370,7 +1392,7 @@ typedef const QITAB *LPCQITAB;
 #define SHGVSPB_FOLDER (SHGVSPB_PERUSER | SHGVSPB_PERFOLDER)
 #define SHGVSPB_FOLDERNODEFAULTS (SHGVSPB_PERUSER | SHGVSPB_PERFOLDER | 
SHGVSPB_NOAUTODEFAULTS)
 #define SHGVSPB_USERDEFAULTS (SHGVSPB_PERUSER | SHGVSPB_ALLFOLDERS)
-#define SHGVSPB_GLOBALDEAFAULTS (SHGVSPB_ALLUSERS | SHGVSPB_ALLFOLDERS)
+#define SHGVSPB_GLOBALDEFAULTS (SHGVSPB_ALLUSERS | SHGVSPB_ALLFOLDERS)
 
   LWSTDAPI SHGetViewStatePropertyBag(LPCITEMIDLIST pidl,LPCWSTR 
pszBagName,DWORD dwFlags,REFIID riid,void **ppv);
 #endif
-- 
2.31.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: Increase precision of gettimeofday() if possible.

2021-05-02 Thread Dan Raymond


1. `clock_gettime()` is not meant to be precise, and it shouldn't be, 
because the extra accuracy is useless. (It may make some sense for 
logging, as mentioned in another message; but in logs only the order 
of writes matters, while timestamps don't matter.)


I don't agree with this.  First: precision and accuracy are two entirely 
different things so it's important not to use them interchangeably.  It 
is true that the absolute value of the wall clock time is not likely to 
be very accurate.  If you are interested in the absolute value then 
increasing precision in clock_gettime() is not going to help you.  But 
if you are interested in the relative difference between two consecutive 
wall clock times then high precision is useful.  Log timestamps are an 
excellent example of this.  I probably won't care if event 1 happened at 
exactly 10:28:16.594.  However I will likely care very much about the 
precision of the interval between event 1 and event 2.  I don't 
understand your claim that only the order of writes matters in logs.  If 
that were true then we wouldn't use timestamps at all.




___
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-05-02 Thread Liu Hao

在 2021-05-02 17:58, DAVID MAY 写道:

On 2/05/2021 1:28 pm, Liu Hao wrote:


Please use `WINBOOL` instead of `BOOL` as the latter is a builtin type
on Mac.

There are more `BOOL`s in the original file, they should be replaced as
well.



See attached patch with changes you requested.



Thanks for the work! I pushed this one.


--
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-05-02 Thread DAVID MAY
On 2/05/2021 1:28 pm, Liu Hao wrote:
> 
> Please use `WINBOOL` instead of `BOOL` as the latter is a builtin type
> on Mac.
> 
> There are more `BOOL`s in the original file, they should be replaced as
> well.
> 

See attached patch with changes you requested.

-- 
David May
--- doc/mingw64-shlwapi.h   2021-04-28 21:40:36.145098000 +0800
+++ shlwapi.h   2021-05-02 14:40:21.915360200 +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) StrCatChainW(LPWSTR pszDst,DWORD cchDst,DWORD ichAt,LPCWSTR 
pszSrc);
   LWSTDAPI SHLoadIndirectString(LPCWSTR pszSource,LPWSTR pszOutBuf,UINT 
cchOutBuf,void **ppvReserved);
+
 #if (_WIN32_IE >= 0x0603)
   LWSTDAPI_(WINBOOL) IsCharSpaceA(CHAR wch);
   LWSTDAPI_(WINBOOL) IsCharSpaceW(WCHAR wch);
@@ -206,9 +246,6 @@
 #define PathIsHTMLFileA(pszPath) 
PathIsContentTypeA(pszPath,SZ_CONTENTTYPE_HTMLA)
 #define PathIsHTMLFileW(pszPath) 
PathIsContentTypeW(pszPath,SZ_CONTENTTYPE_HTMLW)
 
-#define STIF_DEFAULT __MSABI_LONG(0x)
-#define STIF_SUPPORT_HEX __MSABI_LONG(0x0001)
-
 #define StrCatA lstrcatA
 #define StrCmpA lstrcmpA
 #define StrCmpIA lstrcmpiA
@@ -239,6 +276,17 @@
 
 #endif
 
+#if (NTDDI_VERSION >= NTDDI_VISTASP1) 
+  enum tagSFBS_FLAGS {
+  SFBS_FLAGS_ROU