Skip to content

Commit 2e64b9e

Browse files
committed
Always use __p__fmode for _fmode.
It requires adding compatibility code for x86_64 msvcrt version. I don't have arm setup to test, but I assume it's present there. Signed-off-by: Jacek Caban <[email protected]> Signed-off-by: Martin Storsjö <[email protected]>
1 parent 060cd67 commit 2e64b9e

File tree

7 files changed

+145
-56
lines changed

7 files changed

+145
-56
lines changed

mingw-w64-crt/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,24 +228,28 @@ src_msvcrt64=\
228228
$(src_msvcrt) \
229229
misc/__p___argv.c \
230230
misc/__p__acmdln.c \
231+
misc/__p__fmode.c \
231232
misc/__p__wcmdln.c
232233

233234
src_msvcrtarm32=\
234235
$(src_msvcrt) \
235236
misc/__p___argv.c \
236237
misc/__p__acmdln.c \
238+
misc/__p__fmode.c \
237239
misc/__p__wcmdln.c
238240

239241
src_msvcrtarm64=\
240242
$(src_msvcrt) \
241243
misc/__p___argv.c \
242244
misc/__p__acmdln.c \
245+
misc/__p__fmode.c \
243246
misc/__p__wcmdln.c
244247

245248
src_msvcr80_64=\
246249
$(src_msvcrt_common) \
247250
misc/__p___argv.c \
248251
misc/__p__acmdln.c \
252+
misc/__p__fmode.c \
249253
misc/__p__wcmdln.c
250254

251255
# These mingwex sources are target independent:

mingw-w64-crt/Makefile.in

Lines changed: 90 additions & 14 deletions
Large diffs are not rendered by default.

mingw-w64-crt/aclocal.m4

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# generated automatically by aclocal 1.15 -*- Autoconf -*-
1+
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
22

3-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
3+
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
44

55
# This file is free software; the Free Software Foundation
66
# gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to.
2020
If you have problems, you may need to regenerate the build system entirely.
2121
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
2222

23-
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
23+
# Copyright (C) 2002-2017 Free Software Foundation, Inc.
2424
#
2525
# This file is free software; the Free Software Foundation
2626
# gives unlimited permission to copy and/or distribute it,
@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
3535
[am__api_version='1.15'
3636
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
3737
dnl require some minimum version. Point them to the right macro.
38-
m4_if([$1], [1.15], [],
38+
m4_if([$1], [1.15.1], [],
3939
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
4040
])
4141

@@ -51,12 +51,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
5151
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
5252
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
5353
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
54-
[AM_AUTOMAKE_VERSION([1.15])dnl
54+
[AM_AUTOMAKE_VERSION([1.15.1])dnl
5555
m4_ifndef([AC_AUTOCONF_VERSION],
5656
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
5757
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
5858

59-
# Copyright (C) 2011-2014 Free Software Foundation, Inc.
59+
# Copyright (C) 2011-2017 Free Software Foundation, Inc.
6060
#
6161
# This file is free software; the Free Software Foundation
6262
# gives unlimited permission to copy and/or distribute it,
@@ -118,7 +118,7 @@ AC_SUBST([AR])dnl
118118

119119
# Figure out how to run the assembler. -*- Autoconf -*-
120120

121-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
121+
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
122122
#
123123
# This file is free software; the Free Software Foundation
124124
# gives unlimited permission to copy and/or distribute it,
@@ -138,7 +138,7 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
138138

139139
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
140140

141-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
141+
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
142142
#
143143
# This file is free software; the Free Software Foundation
144144
# gives unlimited permission to copy and/or distribute it,
@@ -190,7 +190,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
190190

191191
# AM_COND_IF -*- Autoconf -*-
192192

193-
# Copyright (C) 2008-2014 Free Software Foundation, Inc.
193+
# Copyright (C) 2008-2017 Free Software Foundation, Inc.
194194
#
195195
# This file is free software; the Free Software Foundation
196196
# gives unlimited permission to copy and/or distribute it,
@@ -227,7 +227,7 @@ fi[]dnl
227227

228228
# AM_CONDITIONAL -*- Autoconf -*-
229229

230-
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
230+
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
231231
#
232232
# This file is free software; the Free Software Foundation
233233
# gives unlimited permission to copy and/or distribute it,
@@ -258,7 +258,7 @@ AC_CONFIG_COMMANDS_PRE(
258258
Usually this means the macro was only invoked conditionally.]])
259259
fi])])
260260

261-
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
261+
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
262262
#
263263
# This file is free software; the Free Software Foundation
264264
# gives unlimited permission to copy and/or distribute it,
@@ -449,7 +449,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
449449

450450
# Generate code to set up dependency tracking. -*- Autoconf -*-
451451

452-
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
452+
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
453453
#
454454
# This file is free software; the Free Software Foundation
455455
# gives unlimited permission to copy and/or distribute it,
@@ -525,7 +525,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
525525

526526
# Do all the work for Automake. -*- Autoconf -*-
527527

528-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
528+
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
529529
#
530530
# This file is free software; the Free Software Foundation
531531
# gives unlimited permission to copy and/or distribute it,
@@ -722,7 +722,7 @@ for _am_header in $config_headers :; do
722722
done
723723
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
724724

725-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
725+
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
726726
#
727727
# This file is free software; the Free Software Foundation
728728
# gives unlimited permission to copy and/or distribute it,
@@ -743,7 +743,7 @@ if test x"${install_sh+set}" != xset; then
743743
fi
744744
AC_SUBST([install_sh])])
745745

746-
# Copyright (C) 2003-2014 Free Software Foundation, Inc.
746+
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
747747
#
748748
# This file is free software; the Free Software Foundation
749749
# gives unlimited permission to copy and/or distribute it,
@@ -765,7 +765,7 @@ AC_SUBST([am__leading_dot])])
765765
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
766766
# From Jim Meyering
767767

768-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
768+
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
769769
#
770770
# This file is free software; the Free Software Foundation
771771
# gives unlimited permission to copy and/or distribute it,
@@ -800,7 +800,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
800800

801801
# Check to see how 'make' treats includes. -*- Autoconf -*-
802802

803-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
803+
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
804804
#
805805
# This file is free software; the Free Software Foundation
806806
# gives unlimited permission to copy and/or distribute it,
@@ -850,7 +850,7 @@ rm -f confinc confmf
850850

851851
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
852852

853-
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
853+
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
854854
#
855855
# This file is free software; the Free Software Foundation
856856
# gives unlimited permission to copy and/or distribute it,
@@ -889,7 +889,7 @@ fi
889889

890890
# Helper functions for option handling. -*- Autoconf -*-
891891

892-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
892+
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
893893
#
894894
# This file is free software; the Free Software Foundation
895895
# gives unlimited permission to copy and/or distribute it,
@@ -918,7 +918,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
918918
AC_DEFUN([_AM_IF_OPTION],
919919
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
920920

921-
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
921+
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
922922
#
923923
# This file is free software; the Free Software Foundation
924924
# gives unlimited permission to copy and/or distribute it,
@@ -965,7 +965,7 @@ AC_LANG_POP([C])])
965965
# For backward compatibility.
966966
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
967967

968-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
968+
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
969969
#
970970
# This file is free software; the Free Software Foundation
971971
# gives unlimited permission to copy and/or distribute it,
@@ -984,7 +984,7 @@ AC_DEFUN([AM_RUN_LOG],
984984

985985
# Check to make sure that the build environment is sane. -*- Autoconf -*-
986986

987-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
987+
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
988988
#
989989
# This file is free software; the Free Software Foundation
990990
# gives unlimited permission to copy and/or distribute it,
@@ -1065,7 +1065,7 @@ AC_CONFIG_COMMANDS_PRE(
10651065
rm -f conftest.file
10661066
])
10671067

1068-
# Copyright (C) 2009-2014 Free Software Foundation, Inc.
1068+
# Copyright (C) 2009-2017 Free Software Foundation, Inc.
10691069
#
10701070
# This file is free software; the Free Software Foundation
10711071
# gives unlimited permission to copy and/or distribute it,
@@ -1125,7 +1125,7 @@ AC_SUBST([AM_BACKSLASH])dnl
11251125
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
11261126
])
11271127

1128-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
1128+
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
11291129
#
11301130
# This file is free software; the Free Software Foundation
11311131
# gives unlimited permission to copy and/or distribute it,
@@ -1153,7 +1153,7 @@ fi
11531153
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
11541154
AC_SUBST([INSTALL_STRIP_PROGRAM])])
11551155

1156-
# Copyright (C) 2006-2014 Free Software Foundation, Inc.
1156+
# Copyright (C) 2006-2017 Free Software Foundation, Inc.
11571157
#
11581158
# This file is free software; the Free Software Foundation
11591159
# gives unlimited permission to copy and/or distribute it,
@@ -1172,7 +1172,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
11721172

11731173
# Check how to create a tarball. -*- Autoconf -*-
11741174

1175-
# Copyright (C) 2004-2014 Free Software Foundation, Inc.
1175+
# Copyright (C) 2004-2017 Free Software Foundation, Inc.
11761176
#
11771177
# This file is free software; the Free Software Foundation
11781178
# gives unlimited permission to copy and/or distribute it,

mingw-w64-crt/crt/crtexe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pre_c_init (void)
139139
__set_app_type (_CONSOLE_APP);
140140
__onexitbegin = __onexitend = (_PVFV *) _encode_pointer ((_PVFV *)(-1));
141141

142-
* __MINGW_IMP_SYMBOL(_fmode) = _fmode;
142+
* __p__fmode() = _fmode;
143143
* __MINGW_IMP_SYMBOL(_commode) = _commode;
144144

145145
#ifdef WPRFLAG

mingw-w64-crt/crt/ucrtbase_compat.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,8 @@ unsigned int __cdecl _get_output_format(void)
120120

121121
static char ** local__initenv;
122122
static wchar_t ** local__winitenv;
123-
static int local_fmode;
124123
char *** __MINGW_IMP_SYMBOL(__initenv) = &local__initenv;
125124
wchar_t *** __MINGW_IMP_SYMBOL(__winitenv) = &local__winitenv;
126-
int * __MINGW_IMP_SYMBOL(_fmode) = &local_fmode;
127125

128126

129127
// The parts below are mostly ugly workarounds, necessary to appease code

mingw-w64-crt/misc/__p__fmode.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* This file has no copyright assigned and is placed in the Public Domain.
3+
* This file is part of the mingw-w64 runtime package.
4+
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
5+
*/
6+
7+
#include <_mingw.h>
8+
9+
extern int * __MINGW_IMP_SYMBOL(_fmode);
10+
11+
int *__cdecl __p__fmode(void);
12+
int *__cdecl __p__fmode(void)
13+
{
14+
return __MINGW_IMP_SYMBOL(_fmode);
15+
}
16+
17+
typeof(__p__fmode) *__MINGW_IMP_SYMBOL(__p__fmode) = __p__fmode;

mingw-w64-headers/crt/stdlib.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,24 +174,28 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
174174
#endif /* __MSVCRT_VERSION__ < 0x1400 */
175175
#endif
176176

177-
// We have a fallback definition of __p___argv for msvcrt versions that
178-
// lack it.
177+
/* We have a fallback definition of __p___argv and __p__fmode for
178+
msvcrt versions that lack it. */
179179
_CRTIMP char ***__cdecl __p___argv(void);
180+
_CRTIMP int *__cdecl __p__fmode(void);
180181
#if (defined(_X86_) && !defined(__x86_64)) || (__MSVCRT_VERSION__ >= 0x1400)
181182
_CRTIMP int *__cdecl __p___argc(void);
182183
_CRTIMP wchar_t ***__cdecl __p___wargv(void);
183184
_CRTIMP char ***__cdecl __p__environ(void);
184185
_CRTIMP wchar_t ***__cdecl __p__wenviron(void);
185186
_CRTIMP char **__cdecl __p__pgmptr(void);
186187
_CRTIMP wchar_t **__cdecl __p__wpgmptr(void);
187-
_CRTIMP int *__cdecl __p__fmode(void);
188188
#endif
189189

190190
errno_t __cdecl _get_pgmptr(char **_Value);
191191
errno_t __cdecl _get_wpgmptr(wchar_t **_Value);
192192
_CRTIMP errno_t __cdecl _set_fmode(int _Mode);
193193
_CRTIMP errno_t __cdecl _get_fmode(int *_PMode);
194194

195+
#ifndef _fmode
196+
#define _fmode (* __p__fmode())
197+
#endif
198+
195199
#ifdef _MSVCRT_
196200

197201
#ifndef __argc
@@ -220,9 +224,6 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
220224
#ifndef _wpgmptr
221225
extern wchar_t *_wpgmptr;
222226
#endif
223-
#ifndef _fmode
224-
extern int _fmode;
225-
#endif
226227

227228
#ifndef _osplatform
228229
extern unsigned int _osplatform;
@@ -273,9 +274,6 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
273274
#ifndef _wpgmptr
274275
#define _wpgmptr (* __p__wpgmptr())
275276
#endif
276-
#ifndef _fmode
277-
#define _fmode (* __p__fmode())
278-
#endif
279277

280278
#else /* __MSVCRT_VERSION__ >= 0x1400 */
281279

@@ -313,10 +311,6 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
313311
extern wchar_t ** __MINGW_IMP_SYMBOL(_wpgmptr);
314312
#define _wpgmptr (* __MINGW_IMP_SYMBOL(_wpgmptr))
315313
#endif
316-
#ifndef _fmode
317-
extern int * __MINGW_IMP_SYMBOL(_fmode);
318-
#define _fmode (* __MINGW_IMP_SYMBOL(_fmode))
319-
#endif
320314

321315
#ifndef _osplatform
322316
extern unsigned int * __MINGW_IMP_SYMBOL(_osplatform);

0 commit comments

Comments
 (0)