Skip to content

Commit

Permalink
Always use __p__fmode for _fmode.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
cjacek committed Dec 18, 2017
1 parent 060cd67 commit 2e64b9e
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 56 deletions.
4 changes: 4 additions & 0 deletions mingw-w64-crt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,28 @@ src_msvcrt64=\
$(src_msvcrt) \
misc/__p___argv.c \
misc/__p__acmdln.c \
misc/__p__fmode.c \
misc/__p__wcmdln.c

src_msvcrtarm32=\
$(src_msvcrt) \
misc/__p___argv.c \
misc/__p__acmdln.c \
misc/__p__fmode.c \
misc/__p__wcmdln.c

src_msvcrtarm64=\
$(src_msvcrt) \
misc/__p___argv.c \
misc/__p__acmdln.c \
misc/__p__fmode.c \
misc/__p__wcmdln.c

src_msvcr80_64=\
$(src_msvcrt_common) \
misc/__p___argv.c \
misc/__p__acmdln.c \
misc/__p__fmode.c \
misc/__p__wcmdln.c

# These mingwex sources are target independent:
Expand Down
104 changes: 90 additions & 14 deletions mingw-w64-crt/Makefile.in

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions mingw-w64-crt/aclocal.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated automatically by aclocal 1.15 -*- Autoconf -*-
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-

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

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

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

Expand All @@ -51,12 +51,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.15])dnl
[AM_AUTOMAKE_VERSION([1.15.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])

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

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

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

# AM_AUX_DIR_EXPAND -*- Autoconf -*-

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

# AM_COND_IF -*- Autoconf -*-

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

# AM_CONDITIONAL -*- Autoconf -*-

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

# Copyright (C) 2004-2014 Free Software Foundation, Inc.
# Copyright (C) 2004-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down
2 changes: 1 addition & 1 deletion mingw-w64-crt/crt/crtexe.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pre_c_init (void)
__set_app_type (_CONSOLE_APP);
__onexitbegin = __onexitend = (_PVFV *) _encode_pointer ((_PVFV *)(-1));

* __MINGW_IMP_SYMBOL(_fmode) = _fmode;
* __p__fmode() = _fmode;
* __MINGW_IMP_SYMBOL(_commode) = _commode;

#ifdef WPRFLAG
Expand Down
2 changes: 0 additions & 2 deletions mingw-w64-crt/crt/ucrtbase_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ unsigned int __cdecl _get_output_format(void)

static char ** local__initenv;
static wchar_t ** local__winitenv;
static int local_fmode;
char *** __MINGW_IMP_SYMBOL(__initenv) = &local__initenv;
wchar_t *** __MINGW_IMP_SYMBOL(__winitenv) = &local__winitenv;
int * __MINGW_IMP_SYMBOL(_fmode) = &local_fmode;


// The parts below are mostly ugly workarounds, necessary to appease code
Expand Down
17 changes: 17 additions & 0 deletions mingw-w64-crt/misc/__p__fmode.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/

#include <_mingw.h>

extern int * __MINGW_IMP_SYMBOL(_fmode);

int *__cdecl __p__fmode(void);
int *__cdecl __p__fmode(void)
{
return __MINGW_IMP_SYMBOL(_fmode);
}

typeof(__p__fmode) *__MINGW_IMP_SYMBOL(__p__fmode) = __p__fmode;
20 changes: 7 additions & 13 deletions mingw-w64-headers/crt/stdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,28 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
#endif /* __MSVCRT_VERSION__ < 0x1400 */
#endif

// We have a fallback definition of __p___argv for msvcrt versions that
// lack it.
/* We have a fallback definition of __p___argv and __p__fmode for
msvcrt versions that lack it. */
_CRTIMP char ***__cdecl __p___argv(void);
_CRTIMP int *__cdecl __p__fmode(void);
#if (defined(_X86_) && !defined(__x86_64)) || (__MSVCRT_VERSION__ >= 0x1400)
_CRTIMP int *__cdecl __p___argc(void);
_CRTIMP wchar_t ***__cdecl __p___wargv(void);
_CRTIMP char ***__cdecl __p__environ(void);
_CRTIMP wchar_t ***__cdecl __p__wenviron(void);
_CRTIMP char **__cdecl __p__pgmptr(void);
_CRTIMP wchar_t **__cdecl __p__wpgmptr(void);
_CRTIMP int *__cdecl __p__fmode(void);
#endif

errno_t __cdecl _get_pgmptr(char **_Value);
errno_t __cdecl _get_wpgmptr(wchar_t **_Value);
_CRTIMP errno_t __cdecl _set_fmode(int _Mode);
_CRTIMP errno_t __cdecl _get_fmode(int *_PMode);

#ifndef _fmode
#define _fmode (* __p__fmode())
#endif

#ifdef _MSVCRT_

#ifndef __argc
Expand Down Expand Up @@ -220,9 +224,6 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
#ifndef _wpgmptr
extern wchar_t *_wpgmptr;
#endif
#ifndef _fmode
extern int _fmode;
#endif

#ifndef _osplatform
extern unsigned int _osplatform;
Expand Down Expand Up @@ -273,9 +274,6 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
#ifndef _wpgmptr
#define _wpgmptr (* __p__wpgmptr())
#endif
#ifndef _fmode
#define _fmode (* __p__fmode())
#endif

#else /* __MSVCRT_VERSION__ >= 0x1400 */

Expand Down Expand Up @@ -313,10 +311,6 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
extern wchar_t ** __MINGW_IMP_SYMBOL(_wpgmptr);
#define _wpgmptr (* __MINGW_IMP_SYMBOL(_wpgmptr))
#endif
#ifndef _fmode
extern int * __MINGW_IMP_SYMBOL(_fmode);
#define _fmode (* __MINGW_IMP_SYMBOL(_fmode))
#endif

#ifndef _osplatform
extern unsigned int * __MINGW_IMP_SYMBOL(_osplatform);
Expand Down

0 comments on commit 2e64b9e

Please sign in to comment.