Re: [Mingw-w64-public] SJLJ GCC

2021-12-26 Thread NightStrike
I forgot to do this.  What's your SF username?

On Sat, Sep 18, 2021 at 1:44 AM Ralph Engels  wrote:
>
> sure :) that would make it a litle easier.
>
> Ralph Engels
>
> Den 17-09-2021 kl. 20:20 skrev NightStrike:
> > Do you want upload access? There's already a personal build section
> >
> > On Fri, Sep 17, 2021, 02:01 Ralph Engels  wrote:
> >
> >> P.s you are welcome to link to or upload the sjlj build with ada on the
> >> mingw-w64 site if anyone else sees use for it :)  i can also provide TDM
> >> based versions which default to linking to the static gcc runtimes.
> >>
> >> The TDM versions also accept ASLR and DEP now.
> >>
> >> Den 17-09-2021 kl. 07:47 skrev sotrdg sotrdg:
> >>> C++ exception handling is a mistake. No matter it is sjlj, dwarf or SEH
> >>>
> >>> Sent from Mail  for
> >>> Windows
> >>>
> >>> *From: *NightStrike 
> >>> *Sent: *Thursday, September 16, 2021 22:24
> >>> *To: *Ralph Engels 
> >>> *Cc: *mingw-w64-public@lists.sourceforge.net
> >>> 
> >>> *Subject: *Re: [Mingw-w64-public] SJLJ GCC
> >>>
> >>> On Thu, Sep 16, 2021 at 10:12 PM Ralph Engels 
> >>> wrote:
>  dunno ? he might need it for building some library for msvc in which
>  case sjlj is pretty much the only thing that works besides maybe seh.
>  sjlj is extensively tested on windows it was the first exception model
>  avaliable to us with mingw and many years it did its job just fine :),
>  it is a bit slower but it is by no means a game breaker.
> >>> Given that I was the one identifying and testing all of the issues
> >>> sjlj caused, I can assure you it did not work well in the beginning :P
> >>>   It worked better than dw2, though.  In any case, when we got SEH,
> >>> pretty much everything dropped sjlj unless they had a 32-bit need.
> >>>
> >>>
> >>> ___
> >>> 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
> >>
> > ___
> > 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


[Mingw-w64-public] [PATCH] crt: De-duplicate _vscprintf/_vsnprintf code

2021-12-26 Thread Pali Rohár
Functions __ms_snprintf() and __ms_vsnprintf() contains same logic and code
around _vscprintf() and _vsnprintf() wrappers. Remove duplicated code from
__ms_snprintf() and redirects __ms_snprintf() to __ms_vsnprintf().
---
 mingw-w64-crt/stdio/snprintf.c | 22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/mingw-w64-crt/stdio/snprintf.c b/mingw-w64-crt/stdio/snprintf.c
index 0bb5556fe3de..2e43a67aeee4 100644
--- a/mingw-w64-crt/stdio/snprintf.c
+++ b/mingw-w64-crt/stdio/snprintf.c
@@ -12,27 +12,7 @@ int __cdecl __ms_snprintf(char* buffer, size_t n, const char 
*format, ...)
   va_list argptr;
  
   va_start(argptr, format);
-
-  /* _vsnprintf() does not work with zero length buffer
-   * so count number of character by _vscprintf() call */
-  if (n == 0 || !buffer)
-  {
-retval = _vscprintf(format, argptr);
-va_end(argptr);
-return retval;
-  }
-
-  retval = _vsnprintf (buffer, n, format, argptr);
-
-  /* _vsnprintf() returns negative number if buffer is too small
-   * so count number of character by _vscprintf() call */
-  if (retval < 0)
-retval = _vscprintf(format, argptr);
-
-  /* _vsnprintf() does not fill trailing null byte if there is not place for 
it */
-  if ((size_t)retval >= n)
-buffer[n-1] = '\0';
-
+  retval = __ms_vsnprintf(buffer, n, format, argptr);
   va_end(argptr);
   return retval;
 }
-- 
2.20.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] crt: Add fallback _vscprintf_emu code for __ms_vsnprintf()

2021-12-26 Thread Pali Rohár
Original MSVC 6.0 msvcrt.dll library does not provide _vscprintf()
function. Therefore usage of snprintf() with this DLL library cause
application crash. Add simple fallback implementation of _vscprintf() just
for __ms_vsnprintf() to allow usage of snprintf() function also when using
original msvcrt.dll library. This fallback implementation is static and not
exported outside of vsnprintf.c source file.
---
 mingw-w64-crt/stdio/vsnprintf.c | 67 +
 1 file changed, 67 insertions(+)

diff --git a/mingw-w64-crt/stdio/vsnprintf.c b/mingw-w64-crt/stdio/vsnprintf.c
index 364186702b75..d65ebd3be9e2 100644
--- a/mingw-w64-crt/stdio/vsnprintf.c
+++ b/mingw-w64-crt/stdio/vsnprintf.c
@@ -4,8 +4,75 @@
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
 #define __CRT__NO_INLINE
+#include 
+#include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+static int __cdecl my_vscprintf_init(const char * __restrict__ format, va_list 
arglist);
+static int (__cdecl *my_vscprintf_func)(const char * __restrict__, va_list) = 
my_vscprintf_init;
+
+/* emulation of _vscprintf() via _vsnprintf() */
+static int __cdecl my_vscprintf_emu(const char * __restrict__ format, va_list 
arglist)
+{
+char *buffer, *new_buffer;
+size_t size;
+int ret;
+
+/* if format is a null pointer, _vscprintf() returns -1 and sets errno to 
EINVAL */
+if (!format) {
+_set_errno(EINVAL);
+return -1;
+}
+
+/* size for _vsnprintf() must be non-zero and buffer must have place for 
terminating null character */
+size = strlen(format) * 2 + 1;
+buffer = malloc(size);
+
+if (!buffer) {
+_set_errno(ENOMEM);
+return -1;
+}
+
+/* if the number of characters to write is greater than size, _vsnprintf() 
returns -1 */
+while (size < SIZE_MAX/2 && (ret = _vsnprintf(buffer, size, format, 
arglist)) < 0) {
+/* in this case try with larger buffer */
+size *= 2;
+new_buffer = realloc(buffer, size);
+if (!new_buffer)
+break;
+buffer = new_buffer;
+}
+
+free(buffer);
+
+if (ret < 0) {
+_set_errno(ENOMEM);
+return -1;
+}
+
+return ret;
+}
+
+static int __cdecl my_vscprintf_init(const char * __restrict__ format, va_list 
arglist)
+{
+HMODULE msvcrt = __mingw_get_msvcrt_handle();
+int (__cdecl *func)(const char * __restrict__, va_list) = NULL;
+
+if (msvcrt)
+func = (int (__cdecl *)(const char * __restrict__, 
va_list))GetProcAddress(msvcrt, "_vscprintf");
+
+if (!func)
+func = my_vscprintf_emu;
+
+return (my_vscprintf_func = func)(format, arglist);
+}
+
+#undef _vscprintf
+#define _vscprintf my_vscprintf_func
 
 int __cdecl __ms_vsnprintf (char *s,size_t n,const char *format,va_list arg)
 {
-- 
2.20.1



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


[Mingw-w64-public] VLC build failure after addition of timespec_get

2021-12-26 Thread Biswapriyo Nath
VLC 3.0.16 failed to build in ucrt with this error:

/vlc-3.0.16/compat/timespec_get.c:28:5: error: redefinition of 'timespec_get'
   28 | int timespec_get(struct timespec *ts, int base)
  | ^~~~


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