|
From: Keith M. <no...@so...> - 2017-01-30 15:15:47
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Repository: mingw-org-wsl".
The branch, 5.0-active has been updated
via e52d64b7f86888d5f318fae98fec0536653093d3 (commit)
via c0372a60e6918ffd944670ba8502a0d99fa69044 (commit)
via 7428c55ab13b7f25c68e0248269bbca64f2906b2 (commit)
from 58fece31502adede9300337c67d4f4e0f04ba01c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sf.net/p/mingw/mingw-org-wsl/ci/e52d64b7f86888d5f318fae98fec0536653093d3/
commit e52d64b7f86888d5f318fae98fec0536653093d3
Author: Keith Marshall <kei...@us...>
Date: Mon Jan 30 15:12:46 2017 +0000
Implement strerror_r()/strerror_s() API.
diff --git a/mingwrt/ChangeLog b/mingwrt/ChangeLog
index 8064858..1862aa4 100644
--- a/mingwrt/ChangeLog
+++ b/mingwrt/ChangeLog
@@ -1,5 +1,19 @@
2017-01-30 Keith Marshall <kei...@us...>
+ Implement strerror_r()/strerror_s() API.
+
+ * mingwex/strerror_r.c: New file; it implements...
+ (strerror_r): ...this new POSIX.1-2001 conforming function.
+
+ * include/string.h (strerror_s): Add function prototype, subject to...
+ [_MSVCR80_DLL || _WIN32_WINNT_VISTA]: ...this DLL version dependency;
+ otherwise implement an inline wrapper function to emulate it, using...
+ [_POSIX_C_SOURCE > 200112L] (strerror_r): ...this; add prototype.
+
+ * Makefile.in (libmingwex.a): Add strerror_r.$OBJEXT
+
+2017-01-30 Keith Marshall <kei...@us...>
+
Avoid -Wformat noise from snprintf() and vsnprintf()
* include/stdio.h (snprintf, vsnprintf): Add inline implementations;
diff --git a/mingwrt/Makefile.in b/mingwrt/Makefile.in
index 20fd2c5..7593cca 100644
--- a/mingwrt/Makefile.in
+++ b/mingwrt/Makefile.in
@@ -494,9 +494,8 @@ libmingwex.a: $(addsuffix .$(OBJEXT), glob getopt basename dirname nsleep)
libmingwex.a: $(addsuffix .$(OBJEXT), mkstemp mkdtemp cryptnam setenv)
libmingwex.a: $(addsuffix .$(OBJEXT), tdelete tfind tsearch twalk)
-
+libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn strerror_r)
libmingwex.a: $(addsuffix .$(OBJEXT), getdelim gettimeofday)
-libmingwex.a: $(addsuffix .$(OBJEXT), dirent wdirent dlfcn)
vpath %.s ${mingwrt_srcdir}/mingwex
vpath %.sx ${mingwrt_srcdir}/mingwex
diff --git a/mingwrt/include/string.h b/mingwrt/include/string.h
index a53a71a..ef80f37 100644
--- a/mingwrt/include/string.h
+++ b/mingwrt/include/string.h
@@ -198,6 +198,35 @@ __CRT_ALIAS size_t strnlen (const char *__text, size_t __maxlen)
#endif /* MSVCRT.DLL || pre-MSVCR80.DLL */
#endif /* _POSIX_C_SOURCE >= 200809L */
+#if _POSIX_C_SOURCE >= 200112L
+/* POSIX.1-2001 added a re-entrant variant of strerror(), which stores
+ * the message text in a user supplied buffer, rather than in (possibly
+ * volatile) system supplied storage. Although inherently thread-safe,
+ * Microsoft's strerror() also uses a potentially volatile buffer, (in
+ * the sense that it is overwritten by successive calls within a single
+ * thread); thus, we provide our own implementation of POSIX.1-2001's
+ * strerror_r() function, to facilitate the return of non-volatile
+ * copies of strerror()'s message text.
+ */
+extern int strerror_r (int, char *, size_t);
+#endif
+
+#if __MSVCRT_VERSION__>=__MSVCR80_DLL || _WIN32_WINNT >= _WIN32_WINNT_VISTA
+/* MSVCR80.DLL introduced a safer, (erroneously so called "more secure"),
+ * alternative to strerror(), named strerror_s(); it was later retrofitted
+ * to MSVCRT.DLL, from the release of Windows-Vista onwards.
+ */
+_CRTIMP __cdecl __MINGW_NOTHROW int strerror_s (char *, size_t, int);
+
+#elif _POSIX_C_SOURCE >= 200112L
+/* For the benefit of pre-Vista MSVCRT.DLL users, we provide an approximate
+ * emulation of strerror_s(), in terms of inline referral to POSIX.1-2001's
+ * strerror_r() function.
+ */
+__CRT_ALIAS int strerror_s (char *__buf, size_t __len, int __err)
+{ return strerror_r (__err, __buf, __len); }
+#endif
+
#undef __STRING_H_SOURCED__
_END_C_DECLS
diff --git a/mingwrt/mingwex/strerror_r.c b/mingwrt/mingwex/strerror_r.c
new file mode 100644
index 0000000..4194357
--- /dev/null
+++ b/mingwrt/mingwex/strerror_r.c
@@ -0,0 +1,89 @@
+/*
+ * strerror_r.c
+ *
+ * Implementation of POSIX standard IEEE 1003.1-2001 strerror_r() function.
+ *
+ * $Id$
+ *
+ * Written by Keith Marshall <kei...@us...>
+ * Copyright (C) 2016, 2017, MinGW.org Project
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+#define _POSIX_C_SOURCE 200112L
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+int strerror_r( int errnum, char *buf, size_t len )
+{
+ /* Copy the error message, as retrieved by strerror(), to the user
+ * supplied buffer, so protecting it from subsequent overwrite by a
+ * future call to strerror(); returns zero on success, otherwise sets
+ * errno to, and returns, EINVAL if the user specified errnum doesn't
+ * refer to a valid message, or ERANGE if the associated message, and
+ * its terminating NUL, will not fit within the specified buffer.
+ *
+ * Note that Microsoft's strerror() DOES appear to be thread-safe,
+ * but it uses a single static buffer per thread; thus, within any
+ * one thread, successive calls will overwrite the previous contents
+ * of this buffer; use of strerror_r() allows the user to save a copy
+ * of strerror()'s buffer contents, following each call, where they
+ * are not subject to overwriting by a subsequent strerror() call.
+ */
+ if( buf == NULL )
+ /* POSIX does not recommend any handling for the case of a NULL
+ * return buffer argument; rather than segfault, we will treat it
+ * as a zero-length buffer, into which we can fit no message text
+ * at all, and so we simply return, setting errno to ERANGE.
+ */
+ return errno = ERANGE;
+
+ /* The buffer pointer isn't NULL; assume it is valid, (we will fail
+ * on segfault if it isn't), and proceed to validate errnum.
+ */
+ if( ((unsigned)(errnum)) >= sys_nerr )
+ { /* Note that we check errnum as unsigned; this will also catch a
+ * negative value, since it will appear to be within the positive
+ * range INT_MAX < errnum <= UINT_MAX, while sys_nerr is expected
+ * to be less than INT_MAX.
+ */
+ snprintf( buf, len, "Unknown error: %d", errnum );
+ return errno = EINVAL;
+ }
+ /* errnum appears to be valid; copy the associated message, while
+ * checking that its entire text is copied...
+ */
+ if( snprintf( buf, len, "%s", strerror( errnum )) >= len )
+ /*
+ * ...otherwise, set errno on truncation.
+ */
+ return errno = ERANGE;
+
+ /* If we get to here, return zero, indicating success; (DO NOT
+ * modify errno, in this case).
+ */
+ return 0;
+}
+
+/* $RCSfile$: end of file */
https://sf.net/p/mingw/mingw-org-wsl/ci/c0372a60e6918ffd944670ba8502a0d99fa69044/
commit c0372a60e6918ffd944670ba8502a0d99fa69044
Author: Keith Marshall <kei...@us...>
Date: Mon Jan 30 13:33:51 2017 +0000
Avoid -Wformat noise from snprintf() and vsnprintf()
diff --git a/mingwrt/ChangeLog b/mingwrt/ChangeLog
index a1ffb6e..8064858 100644
--- a/mingwrt/ChangeLog
+++ b/mingwrt/ChangeLog
@@ -1,5 +1,13 @@
2017-01-30 Keith Marshall <kei...@us...>
+ Avoid -Wformat noise from snprintf() and vsnprintf()
+
+ * include/stdio.h (snprintf, vsnprintf): Add inline implementations;
+ they redirect to "__mingw_" prefixed alternatives, so suppressing the
+ effect of automatic format attribute recognition.
+
+2017-01-30 Keith Marshall <kei...@us...>
+
Remove duplicate libmingwex.a entries.
* mingwex/jmpstub.sx (DLLENTRY): Interpret it.
diff --git a/mingwrt/include/stdio.h b/mingwrt/include/stdio.h
index 9e2ccab..e17afa0 100644
--- a/mingwrt/include/stdio.h
+++ b/mingwrt/include/stdio.h
@@ -394,6 +394,16 @@ int sprintf (char *__stream, const char *__format, ...)
}
__mingw_stdio_redirect__
+int snprintf (char *__stream, size_t __len, const char *__format, ...)
+{
+ register int __retval;
+ __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
+ __retval = __mingw_vsnprintf( __stream, __len, __format, __local_argv );
+ __builtin_va_end( __local_argv );
+ return __retval;
+}
+
+__mingw_stdio_redirect__
int vfprintf (FILE *__stream, const char *__format, __VALIST __local_argv)
{
return __mingw_vfprintf( __stream, __format, __local_argv );
@@ -411,6 +421,12 @@ int vsprintf (char *__stream, const char *__format, __VALIST __local_argv)
return __mingw_vsprintf( __stream, __format, __local_argv );
}
+__mingw_stdio_redirect__
+int vsnprintf (char *__stream, size_t __len, const char *__format, __VALIST __local_argv)
+{
+ return __mingw_vsnprintf( __stream, __len, __format, __local_argv );
+}
+
#else
/* Default configuration: simply direct all calls to MSVCRT...
*/
https://sf.net/p/mingw/mingw-org-wsl/ci/7428c55ab13b7f25c68e0248269bbca64f2906b2/
commit 7428c55ab13b7f25c68e0248269bbca64f2906b2
Author: Keith Marshall <kei...@us...>
Date: Mon Jan 30 10:53:24 2017 +0000
Remove duplicate libmingwex.a entries.
diff --git a/mingwrt/ChangeLog b/mingwrt/ChangeLog
index 19d884c..a1ffb6e 100644
--- a/mingwrt/ChangeLog
+++ b/mingwrt/ChangeLog
@@ -1,3 +1,20 @@
+2017-01-30 Keith Marshall <kei...@us...>
+
+ Remove duplicate libmingwex.a entries.
+
+ * mingwex/jmpstub.sx (DLLENTRY): Interpret it.
+
+ * Makefile.in (jmpstub_awk_script): Handle DLLENTRY.
+ (libmingwex.a): Remove explicit object file references to...
+ (snwprintf, vsnwprintf): ...these.
+
+ * include/stdio.h (snwprintf, vsnwprintf): Map them as __JMPSTUB__
+ references to MSVCRT.DLL entry points, via DLLENTRY references to...
+ (_snwprintf, _vsnwprintf): ...these, respectively.
+
+ * mingwex/snwprintf.c: Redundant file; delete it.
+ * mingwex/vsnwprintf.c: Likewise.
+
2017-01-29 Keith Marshall <kei...@us...>
Clean up <limits.h> header file.
diff --git a/mingwrt/Makefile.in b/mingwrt/Makefile.in
index 6b7afca..20fd2c5 100644
--- a/mingwrt/Makefile.in
+++ b/mingwrt/Makefile.in
@@ -469,8 +469,8 @@ libmingwex.a: $(addsuffix .$(OBJEXT), cosf cosl acosf acosl sinf sinl asinf \
#
vpath %.c ${mingwrt_srcdir}/mingwex/stdio
libmingwex.a: $(addsuffix .$(OBJEXT), btowc fprintf fseeko64 ofmtctl pformat \
- printf snprintf snwprintf sprintf vfprintf vfscanf vfwscanf vprintf vscanf \
- vsnprintf vsnwprintf vsprintf vsscanf vswscanf vwscanf)
+ printf snprintf sprintf vfprintf vfscanf vfwscanf vprintf vscanf vsnprintf \
+ vsprintf vsscanf vswscanf vwscanf)
# pformat.$(OBJEXT) needs an explicit build rule, since we need to
# specify an additional header file path.
@@ -583,7 +583,9 @@ jmpstub_awk_script = test -z "$1" || awk '\
LIB = match( $$0, ".*[ ,(:]LIB *= *"symbol, altlib ) ? altlib[1] : "mingwex"; \
OBJNAME = gensub( "_*(.*)_*", "\\1", 1, FUNCTION )".jmpstub.$$(OBJEXT)"; \
OBJNAME_CFLAGS = "-D FUNCTION="FUNCTION; \
- if( match( $$0, ".*[ ,(:]REMAPPED *= *"symbol, alias ) ) \
+ if( match( $$0, ".*[ ,(:]DLLENTRY *= *"symbol, alias ) ) \
+ OBJNAME_CFLAGS = OBJNAME_CFLAGS" -D DLLENTRY="alias[1]; \
+ else if( match( $$0, ".*[ ,(:]REMAPPED *= *"symbol, alias ) ) \
OBJNAME_CFLAGS = OBJNAME_CFLAGS" -D REMAPPED="alias[1]; \
printf fmt, LIB, OBJNAME, OBJNAME, OBJNAME_CFLAGS; \
} \
diff --git a/mingwrt/include/stdio.h b/mingwrt/include/stdio.h
index 252c210..9e2ccab 100644
--- a/mingwrt/include/stdio.h
+++ b/mingwrt/include/stdio.h
@@ -7,7 +7,7 @@
* $Id$
*
* Written by Colin Peters <co...@bi...>
- * Copyright (C) 1997-2005, 2007-2010, 2014-2016, MinGW.org Project.
+ * Copyright (C) 1997-2005, 2007-2010, 2014-2017, MinGW.org Project.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -950,12 +950,13 @@ _CRTIMP __cdecl __MINGW_NOTHROW FILE * _wpopen (const wchar_t *, const wchar
#endif /* __MSVCRT__ */
#ifdef _ISOC99_SOURCE
+__JMPSTUB__(( FUNCTION = snwprintf, DLLENTRY = _snwprintf ))
__cdecl __MINGW_NOTHROW int snwprintf (wchar_t *, size_t, const wchar_t *, ...);
__cdecl __MINGW_NOTHROW int vsnwprintf (wchar_t *, size_t, const wchar_t *, __VALIST);
#ifndef __NO_INLINE__
__CRT_INLINE __cdecl __MINGW_NOTHROW
-__JMPSTUB__(( FUNCTION = vsnwprintf, REMAPPED = _vsnwprintf ))
+__JMPSTUB__(( FUNCTION = vsnwprintf, DLLENTRY = _vsnwprintf ))
int vsnwprintf (wchar_t *__s, size_t __n, const wchar_t *__fmt, __VALIST __arg)
{ return _vsnwprintf ( __s, __n, __fmt, __arg); }
#endif
diff --git a/mingwrt/mingwex/jmpstub.sx b/mingwrt/mingwex/jmpstub.sx
index aa57975..200a120 100644
--- a/mingwrt/mingwex/jmpstub.sx
+++ b/mingwrt/mingwex/jmpstub.sx
@@ -7,7 +7,7 @@
* $Id$
*
* Written by Keith Marshall <kei...@us...>
- * Copyright (C) 2013, 2014, MinGW.org Project
+ * Copyright (C) 2013, 2014, 2017, MinGW.org Project
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -46,20 +46,48 @@
* an additional "-D REMAPPED=entryname" option, resulting in redirection
* of "funcname()" calls to the "entryname()" function entry point.
*
+ * Alternatively, calls to "funcname()" may be redirected to a DLL entry point,
+ * via its importable name within the DLL's export table, by specification of
+ * the "-D DLLENTRY=entryname" option, instead of "-D REMAPPED=entryname".
+ *
*/
#define __entry__(__suffix__) __label__(_,__suffix__)
#define __label__(__prefix__,__suffix__) __prefix__##__suffix__
-#ifndef REMAPPED
-# define __mingw__(__suffix__) __label__(__mingw_,__suffix__)
-# define REMAPPED __mingw__(FUNCTION)
+#if defined LLENTRY && ! defined DLLENTRY
+/* This is a convenience for users; it allows specification of a DLLENTRY
+ * option as simply "-DLLENTRY=entryname", as an alternative to specifying
+ * it fully, as "-D DLLENTRY=entryname".
+ */
+#define DLLENTRY LLENTRY
#endif
.text
+#ifdef DLLENTRY
+ /* This represents the case of redirection to a function implementation
+ * residing within a DLL...
+ */
+# define __dllentry__(__suffix__) __label__(__imp__,__suffix__)
+# define __redirect__ *__dllentry__(DLLENTRY)
+
+#else
+ /* ...whereas this redirection to an alternative static library function,
+ * or to a DLL implementation accessed via an import library trampoline.
+ */
+# ifndef REMAPPED
+ /* No explicit entry point redirection specified; use the default entry
+ * point name, within the "__mingw_" pseudo-namespace.
+ */
+# define __mingw__(__suffix__) __label__(__mingw_,__suffix__)
+# define REMAPPED __mingw__(FUNCTION)
+# endif
+# define __redirect__ __entry__(REMAPPED)
+.def __entry__(REMAPPED); .scl 2; .type 32; .endef
+#endif
+
.global __entry__(FUNCTION)
.def __entry__(FUNCTION); .scl 2; .type 32; .endef
-.def __entry__(REMAPPED); .scl 2; .type 32; .endef
-__entry__(FUNCTION): jmp __entry__(REMAPPED)
+__entry__(FUNCTION): jmp __redirect__
/* $RCSfile$: end of file */
diff --git a/mingwrt/mingwex/stdio/snwprintf.c b/mingwrt/mingwex/stdio/snwprintf.c
deleted file mode 100644
index d69892e..0000000
--- a/mingwrt/mingwex/stdio/snwprintf.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <stdarg.h>
-#include <wchar.h>
-
-int snwprintf(wchar_t* buffer, size_t n, const wchar_t* format, ...)
-{
- int retval;
- va_list argptr;
-
- va_start( argptr, format );
- retval = _vsnwprintf( buffer, n, format, argptr );
- va_end( argptr );
- return retval;
-}
diff --git a/mingwrt/mingwex/stdio/vsnwprintf.c b/mingwrt/mingwex/stdio/vsnwprintf.c
deleted file mode 100644
index 1b59a07..0000000
--- a/mingwrt/mingwex/stdio/vsnwprintf.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdarg.h>
-#include <wchar.h>
-
-int vsnwprintf(wchar_t *buffer, size_t n, const wchar_t * format, va_list argptr)
- { return _vsnwprintf( buffer, n, format, argptr );}
-----------------------------------------------------------------------
Summary of changes:
mingwrt/ChangeLog | 39 ++++++++++++++++
mingwrt/Makefile.in | 11 ++--
mingwrt/include/stdio.h | 21 ++++++++-
mingwrt/include/string.h | 29 ++++++++++++
mingwrt/mingwex/jmpstub.sx | 40 ++++++++++++++--
mingwrt/mingwex/stdio/snwprintf.c | 13 -----
mingwrt/mingwex/stdio/vsnwprintf.c | 5 --
mingwrt/mingwex/strerror_r.c | 89 ++++++++++++++++++++++++++++++++++++
8 files changed, 216 insertions(+), 31 deletions(-)
delete mode 100644 mingwrt/mingwex/stdio/snwprintf.c
delete mode 100644 mingwrt/mingwex/stdio/vsnwprintf.c
create mode 100644 mingwrt/mingwex/strerror_r.c
hooks/post-receive
--
Repository: mingw-org-wsl
|