Update mingw library to mingw-w64 trunk (mingw-w64-src_20100325)

svn path=/branches/ros-amd64-bringup/; revision=46537
This commit is contained in:
Timo Kreuzer 2010-03-28 23:27:01 +00:00
parent b8a5d2b45c
commit 8236cf6a81
52 changed files with 659 additions and 585 deletions

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef _INC_INTERNAL
@ -18,9 +18,12 @@ extern "C" {
#pragma pack(push,_CRT_PACKING)
#ifndef __INTERNAL_FUNC_DEFINED
#define __INTERNAL_FUNC_DEFINED
typedef void (__cdecl *_PVFV)(void);
typedef int (__cdecl *_PIFV)(void);
typedef void (__cdecl *_PVFI)(int);
#endif
#if defined (SPECIAL_CRTEXE) && (defined (_DLL) || defined (__GNUC__))
extern int _commode;
@ -32,12 +35,6 @@ extern "C" {
#define __IOINFO_TM_UTF8 1
#define __IOINFO_TM_UTF16LE 2
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4214)
#pragma warning(disable:4820)
#endif
typedef struct {
intptr_t osfhnd;
char osfile;
@ -49,10 +46,6 @@ extern "C" {
char pipech2[2];
} ioinfo;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#define IOINFO_ARRAY_ELTS (1 << 5)
#define _pioinfo(i) (__pioinfo[(i) >> 5] + ((i) & (IOINFO_ARRAY_ELTS - 1)))

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef _INC_OSCALLS
@ -30,11 +30,6 @@
#endif
#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4214)
#endif
typedef struct _FTIME
{
unsigned short twosecs : 5;
@ -51,10 +46,6 @@ typedef struct _FDATE
unsigned short year : 7;
} FDATE;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
typedef FDATE *PFDATE;
#endif

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#if defined (__ia64__) || defined (__x86_64)
@ -10,7 +10,7 @@
#define _ATTRIBUTES shared
#endif
#if defined(_MSC_VER)
#if 0
/* Reference list of existing section for msvcrt. */
#pragma section(".CRTMP$XCA",long,_ATTRIBUTES)
#pragma section(".CRTMP$XCZ",long,_ATTRIBUTES)
@ -55,14 +55,6 @@
#pragma section(".rtc$IZZ",long,read)
#pragma section(".rtc$TAA",long,read)
#pragma section(".rtc$TZZ",long,read)
#pragma section(".tls",long,read,write)
#pragma section(".tls$ZZZ",long,read,write)
#endif
#if defined(_MSC_VER)
#define _CRTALLOC(x) __declspec(allocate(x))
#elif defined(__GNUC__)
#define _CRTALLOC(x) __attribute__ ((section (x) ))
#else
#error
#endif

View file

@ -1,22 +1,12 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
void _fpreset (void);
void _fpreset (void)
{
#ifdef __GNUC__
__asm__ ("fninit" );
#else
__asm fninit;
#endif
}
{ __asm__ ("fninit" ) ;}
#ifdef __GNUC__
void __attribute__ ((alias ("_fpreset"))) fpreset(void);
#else
void fpreset(void) { _fpreset(); }
#endif

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <_mingw.h>
@ -14,8 +14,4 @@ void _fpreset (void)
(* __MINGW_IMP_SYMBOL(_fpreset))();
}
#ifdef __GNUC__
void __attribute__ ((alias ("_fpreset"))) fpreset(void);
#else
void fpreset(void) { _fpreset(); }
#endif

View file

@ -2,7 +2,7 @@
* CRT_glob.c
* This file has no copyright is assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
* No warranty is given; refer to the file DISCLAIMER.PD within the package.
*
* Include this object file to set _dowildcard to a state that will turn on
* command line globbing by default. (wildcard.o which goes into libmingw32.a

17
reactos/lib/3rdparty/mingw/CRT_noglob.c vendored Normal file
View file

@ -0,0 +1,17 @@
/*
* CRT_noglob.c
* This file has no copyright is assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within the package.
*
* Include this object file to set _dowildcard to a state that will turn off
* command line globbing by default. (wildcard.o which goes into libmingw32.a
* has a default state of off if not configured with --enable-wildcard.)
*
* To use this object include the object file in your link command:
* gcc -o foo.exe foo.o CRT_noglob.o
*
*/
int _dowildcard = 0;

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _newmode = 0;

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#undef CRTDLL

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#define SPECIAL_CRTEXE

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <sect_attribs.h>

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
@ -13,6 +13,14 @@
#include <signal.h>
#include <stdio.h>
#if defined (_WIN64) && defined (__ia64__)
#error FIXME: Unsupported __ImageBase implementation.
#else
#define __ImageBase __MINGW_LSYMBOL(_image_base__)
/* This symbol is defined by the linker. */
extern IMAGE_DOS_HEADER __ImageBase;
#endif
#pragma pack(push,1)
typedef struct _UNWIND_INFO {
BYTE VersionAndFlags;
@ -107,6 +115,8 @@ __mingw_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord,
(*old_handler) (SIGSEGV);
action = EXCEPTION_CONTINUE_EXECUTION;
}
else
action = EXCEPTION_EXECUTE_HANDLER;
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
case EXCEPTION_PRIV_INSTRUCTION:
@ -125,6 +135,8 @@ __mingw_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord,
(*old_handler) (SIGILL);
action = EXCEPTION_CONTINUE_EXECUTION;
}
else
action = EXCEPTION_EXECUTE_HANDLER;
break;
case EXCEPTION_FLT_INVALID_OPERATION:
case EXCEPTION_FLT_DIVIDE_BY_ZERO:

6
reactos/lib/3rdparty/mingw/crtbegin.c vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifdef CRTDLL
@ -40,6 +40,7 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
/* TLS initialization hook. */
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
static int __proc_attached = 0;
@ -49,9 +50,9 @@ extern _PVFV *__onexitend;
extern int mingw_app_type;
extern BOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved);
extern WINBOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved);
extern BOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
extern WINBOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
static int pre_c_init (void);
@ -71,7 +72,7 @@ pre_c_init (void)
return 0;
}
BOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
if (dwReason == DLL_PROCESS_DETACH)
{
@ -148,12 +149,12 @@ BOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
return TRUE;
}
static BOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
static WINBOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
BOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID);
WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID);
int __mingw_init_ehandler (void);
BOOL WINAPI
WINBOOL WINAPI
DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
mingw_app_type = 0;
@ -167,10 +168,10 @@ DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
}
__declspec(noinline) BOOL
__declspec(noinline) WINBOOL
__DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
BOOL retcode = TRUE;
WINBOOL retcode = TRUE;
__native_dllmain_reason = dwReason;
if (dwReason == DLL_PROCESS_DETACH && __proc_attached == 0)

6
reactos/lib/3rdparty/mingw/crtend.c vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#undef CRTDLL
@ -20,7 +20,6 @@
#include <tchar.h>
#include <sect_attribs.h>
#include <locale.h>
#include <intrin.h>
#ifndef __winitenv
extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
@ -32,6 +31,11 @@ extern char *** __MINGW_IMP_SYMBOL(__initenv);
#define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
#endif
/* Hack, for bug in ld. Will be removed soon. */
#define __ImageBase __MINGW_LSYMBOL(_image_base__)
/* This symbol is defined by ld. */
extern IMAGE_DOS_HEADER __ImageBase;
extern void _fpreset (void);
#define SPACECHAR _T(' ')
#define DQUOTECHAR _T('\"')
@ -47,11 +51,7 @@ extern int * __MINGW_IMP_SYMBOL(_commode);
#define _commode (* __MINGW_IMP_SYMBOL(_commode))
extern int _dowildcard;
#if defined(__GNUC__)
int _MINGW_INSTALL_DEBUG_MATHERR __attribute__((weak)) = 0;
#else
int _MINGW_INSTALL_DEBUG_MATHERR = 0;
#endif
extern int __defaultmatherr;
extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
@ -62,6 +62,7 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
/* TLS initialization hook. */
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
extern _PVFV *__onexitbegin;
@ -179,7 +180,7 @@ __tmainCRTStartup (void)
{
_TCHAR *lpszCommandLine = NULL;
STARTUPINFO StartupInfo;
BOOL inDoubleQuote = FALSE;
WINBOOL inDoubleQuote = FALSE;
memset (&StartupInfo, 0, sizeof (STARTUPINFO));
if (mingw_app_type)

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifdef CRTDLL

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifdef CRTDLL

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <oscalls.h>

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>

View file

@ -1,394 +0,0 @@
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <stdarg.h>
#include <stdio.h>
#define REPLACE_GETOPT
#define _DIAGASSERT(x) do {} while (0)
#ifdef REPLACE_GETOPT
#ifdef __weak_alias
__weak_alias(getopt,_getopt)
#endif
int opterr = 1;
int optind = 1;
int optopt = '?';
int optreset;
char *optarg;
#endif
#ifdef __weak_alias
__weak_alias(getopt_long,_getopt_long)
#endif
#ifndef __CYGWIN__
#define __progname __argv[0]
#else
extern char __declspec(dllimport) *__progname;
#endif
#define IGNORE_FIRST (*options == '-' || *options == '+')
#define PRINT_ERROR ((opterr) && ((*options != ':') || (IGNORE_FIRST && options[1] != ':')))
#ifndef IS_POSIXLY_CORRECT
#define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL)
#endif
#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST)
#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-')
#define BADCH (int)'?'
#define BADARG ((IGNORE_FIRST && options[1] == ':') || (*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
static char EMSG[1];
static int getopt_internal (int,char * const *,const char *);
static int gcd (int,int);
static void permute_args (int,int,int,char * const *);
static char *place = EMSG;
static int nonopt_start = -1;
static int nonopt_end = -1;
static const char recargchar[] = "option requires an argument -- %c";
static const char recargstring[] = "option requires an argument -- %s";
static const char ambig[] = "ambiguous option -- %.*s";
static const char noarg[] = "option doesn't take an argument -- %.*s";
static const char illoptchar[] = "unknown option -- %c";
static const char illoptstring[] = "unknown option -- %s";
static void
_vwarnx(const char *fmt,va_list ap)
{
(void)fprintf(stderr,"%s: ",__progname);
if (fmt != NULL)
(void)vfprintf(stderr,fmt,ap);
(void)fprintf(stderr,"\n");
}
static void
warnx(const char *fmt,...)
{
va_list ap;
va_start(ap,fmt);
_vwarnx(fmt,ap);
va_end(ap);
}
static int
gcd(a,b)
int a;
int b;
{
int c;
c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return b;
}
static void
permute_args(panonopt_start,panonopt_end,opt_end,nargv)
int panonopt_start;
int panonopt_end;
int opt_end;
char * const *nargv;
{
int cstart,cyclelen,i,j,ncycle,nnonopts,nopts,pos;
char *swap;
_DIAGASSERT(nargv != NULL);
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
ncycle = gcd(nnonopts,nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
cstart = panonopt_end+i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
pos -= nnonopts;
else
pos += nopts;
swap = nargv[pos];
((char **) nargv)[pos] = nargv[cstart];
((char **)nargv)[cstart] = swap;
}
}
}
static int
getopt_internal(nargc,nargv,options)
int nargc;
char * const *nargv;
const char *options;
{
char *oli;
int optchar;
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(options != NULL);
optarg = NULL;
if (optind == 0)
optind = 1;
if (optreset)
nonopt_start = nonopt_end = -1;
start:
if (optreset || !*place) {
optreset = 0;
if (optind >= nargc) {
place = EMSG;
if (nonopt_end != -1) {
permute_args(nonopt_start,nonopt_end,optind,nargv);
optind -= nonopt_end - nonopt_start;
}
else if (nonopt_start != -1) {
optind = nonopt_start;
}
nonopt_start = nonopt_end = -1;
return -1;
}
if ((*(place = nargv[optind]) != '-')
|| (place[1] == '\0')) {
place = EMSG;
if (IN_ORDER) {
optarg = nargv[optind++];
return INORDER;
}
if (!PERMUTE) {
return -1;
}
if (nonopt_start == -1)
nonopt_start = optind;
else if (nonopt_end != -1) {
permute_args(nonopt_start,nonopt_end,optind,nargv);
nonopt_start = optind -
(nonopt_end - nonopt_start);
nonopt_end = -1;
}
optind++;
goto start;
}
if (nonopt_start != -1 && nonopt_end == -1)
nonopt_end = optind;
if (place[1] && *++place == '-') {
place++;
return -2;
}
}
if ((optchar = (int)*place++) == (int)':' ||
(oli = strchr(options + (IGNORE_FIRST ? 1 : 0),optchar)) == NULL) {
if (!*place)
++optind;
if (PRINT_ERROR)
warnx(illoptchar,optchar);
optopt = optchar;
return BADCH;
}
if (optchar == 'W' && oli[1] == ';') {
if (*place)
return -2;
if (++optind >= nargc) {
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar,optchar);
optopt = optchar;
return BADARG;
} else
place = nargv[optind];
return -2;
}
if (*++oli != ':') {
if (!*place)
++optind;
} else {
optarg = NULL;
if (*place)
optarg = place;
else if (oli[1] != ':') {
if (++optind >= nargc) {
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar,optchar);
optopt = optchar;
return BADARG;
} else
optarg = nargv[optind];
}
place = EMSG;
++optind;
}
return optchar;
}
#ifdef REPLACE_GETOPT
int
getopt(nargc,nargv,options)
int nargc;
char * const *nargv;
const char *options;
{
int retval;
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(options != NULL);
if ((retval = getopt_internal(nargc,nargv,options)) == -2) {
++optind;
if (nonopt_end != -1) {
permute_args(nonopt_start,nonopt_end,optind,nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
retval = -1;
}
return retval;
}
#endif
int
getopt_long(nargc,nargv,options,long_options,idx)
int nargc;
char * const *nargv;
const char *options;
const struct option *long_options;
int *idx;
{
int retval;
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(options != NULL);
_DIAGASSERT(long_options != NULL);
if ((retval = getopt_internal(nargc,nargv,options)) == -2) {
char *current_argv,*has_equal;
size_t current_argv_len;
int i,match;
current_argv = place;
match = -1;
optind++;
place = EMSG;
if (*current_argv == '\0') {
if (nonopt_end != -1) {
permute_args(nonopt_start,nonopt_end,optind,nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
return -1;
}
if ((has_equal = strchr(current_argv,'=')) != NULL) {
current_argv_len = has_equal - current_argv;
has_equal++;
} else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
if (strncmp(current_argv,long_options[i].name,current_argv_len))
continue;
if (strlen(long_options[i].name) ==
(unsigned)current_argv_len) {
match = i;
break;
}
if (match == -1)
match = i;
else {
if (PRINT_ERROR)
warnx(ambig,(int)current_argv_len,current_argv);
optopt = 0;
return BADCH;
}
}
if (match != -1) {
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
warnx(noarg,(int)current_argv_len,current_argv);
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
return BADARG;
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {
if (has_equal)
optarg = has_equal;
else if (long_options[match].has_arg ==
required_argument) {
optarg = nargv[optind++];
}
}
if ((long_options[match].has_arg == required_argument)
&& (optarg == NULL)) {
if (PRINT_ERROR)
warnx(recargstring,current_argv);
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
--optind;
return BADARG;
}
} else {
if (PRINT_ERROR)
warnx(illoptstring,current_argv);
optopt = 0;
return BADCH;
}
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
retval = 0;
} else
retval = long_options[match].val;
if (idx)
*idx = match;
}
return retval;
}

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
@ -112,22 +112,12 @@ __report_gsfailure (ULONGLONG StackCookie)
else
#endif
{
#ifdef __GNUC__
#ifdef _WIN64
GS_ContextRecord.Rip = (ULONGLONG) __builtin_return_address (0);
GS_ContextRecord.Rsp = (ULONGLONG) __builtin_frame_address (0) + 8;
#else
GS_ContextRecord.Eip = (DWORD) __builtin_return_address (0);
GS_ContextRecord.Esp = (DWORD) __builtin_frame_address (0) + 4;
#endif
#else
#ifdef _WIN64
GS_ContextRecord.Rip = (ULONGLONG) _ReturnAddress();
GS_ContextRecord.Rsp = (ULONGLONG) _AddressOfReturnAddress();
#else
GS_ContextRecord.Eip = (DWORD) _ReturnAddress();
GS_ContextRecord.Esp = (DWORD) _AddressOfReturnAddress();
#endif
#endif
}

16
reactos/lib/3rdparty/mingw/isascii.c vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <ctype.h>
#undef isascii
int isascii (int);
int
isascii (int c)
{
return __isascii(c);
}

16
reactos/lib/3rdparty/mingw/iscsym.c vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <ctype.h>
#undef iscsym
int iscsym (int);
int
iscsym (int c)
{
return __iscsym(c);
}

16
reactos/lib/3rdparty/mingw/iscsymf.c vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <ctype.h>
#undef iscsymf
int iscsymf (int);
int
iscsymf (int c)
{
return __iscsymf(c);
}

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <internal.h>

View file

@ -3,6 +3,10 @@
<group>
<module name="mingw_common" type="staticlibrary" isstartuplib="true" crt="dll">
<define name="_CRTBLD" />
<!-- This is to prevent from using data imports directly -->
<define name="_M_CEE_PURE" />
<importlibrary definition="moldname-msvcrt.def" dllname="msvcrt.dll" />
<include base="ReactOS">include/reactos/mingw-w64</include>
<if property="USERMODE" value="1">
@ -18,19 +22,18 @@
<file>CRT_glob.c</file>
<file>crt_handler.c</file>
<file>dllentry.c</file>
<file>dummy_mingwthrd.c</file>
<file>gccmain.c</file>
<file>getopt.c</file>
<file>gs_support.c</file>
<file>merr.c</file>
<!-- file>mingw_custom.c</file -->
<file>mingw_helpers.c</file>
<file>mingwthrd_nomt.c</file>
<file>natstart.c</file>
<file>pesect.c</file>
<file>pseudo-reloc.c</file>
<file>pseudo-reloc-list.c</file>
<file>tlsmcrt.c</file>
<file>tlssup.c</file>
<file>tlsthrd.c</file>
<file>txtmode.c</file>
<file>wildcard.c</file>
<file>xncommod.c</file>

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <_mingw.h>

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <oscalls.h>

View file

@ -1,30 +0,0 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <stdlib.h>
/* We support TLS cleanup code in any case. If shared version of libgcc is used _CRT_MT has value 1, otherwise
we do tls cleanup in runtime and _CRT_MT has value 2. */
int _CRT_MT = 2;
int __mingwthr_key_dtor (DWORD key, void (*dtor)(void *));
int __mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
int
__mingwthr_remove_key_dtor (DWORD key)
{
return ___w64_mingwthr_remove_key_dtor (key);
}
int
__mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
{
if (dtor)
return ___w64_mingwthr_add_key_dtor (key, dtor);
return 0;
}

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <crtdefs.h>

View file

@ -1,15 +1,24 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
#include <string.h>
BOOL _ValidateImageBase (PBYTE);
#if defined (_WIN64) && defined (__ia64__)
#error FIXME: Unsupported __ImageBase implementation.
#else
/* Hack, for bug in ld. Will be removed soon. */
#define __ImageBase __MINGW_LSYMBOL(_image_base__)
/* This symbol is defined by the linker. */
extern IMAGE_DOS_HEADER __ImageBase;
#endif
BOOL
WINBOOL _ValidateImageBase (PBYTE);
WINBOOL
_ValidateImageBase (PBYTE pImageBase)
{
PIMAGE_DOS_HEADER pDOSHeader;
@ -122,9 +131,9 @@ _GetPEImageBase (void)
return pImageBase;
}
BOOL _IsNonwritableInCurrentImage (PBYTE);
WINBOOL _IsNonwritableInCurrentImage (PBYTE);
BOOL
WINBOOL
_IsNonwritableInCurrentImage (PBYTE pTarget)
{
PBYTE pImageBase;

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
char __RUNTIME_PSEUDO_RELOC_LIST_END__ = 0;

View file

@ -1,27 +1,71 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*
* Contributed by Egor Duda <deo@logos-m.ru>
* Modified by addition of runtime_pseudo_reloc version 2
* by Kai Tietz <kai.tietz@onevision.com>
*/
/* pseudo-reloc.c
Contributed by Egor Duda <deo@logos-m.ru>
Modified by addition of runtime_pseudo_reloc version 2
by Kai Tietz <kai.tietz@onevision.com>
THIS SOFTWARE IS NOT COPYRIGHTED
This source code is offered for use in the public domain. You may
use, modify or distribute it freely.
This code is distributed in the hope that it will be useful but
WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
DISCLAMED. This includes but is not limited to warrenties of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>
#include <assert.h>
#if defined(__CYGWIN__)
#include <wchar.h>
#include <ntdef.h>
#include <sys/cygwin.h>
/* copied from winsup.h */
# define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
/* custom status code: */
#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269)
#define SHORT_MSG_BUF_SZ 128
#else
# define NO_COPY
#endif
#ifdef __GNUC__
#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
#else
#define ATTRIBUTE_NORETURN
#endif
#ifndef __MINGW_LSYMBOL
#define __MINGW_LSYMBOL(sym) sym
#endif
extern char __RUNTIME_PSEUDO_RELOC_LIST__;
extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
extern char __MINGW_LSYMBOL(_image_base__);
void _pei386_runtime_relocator (void);
/* v1 relocation is basically:
* *(base + .target) += .addend
* where (base + .target) is always assumed to point
* to a DWORD (4 bytes).
*/
typedef struct {
DWORD addend;
DWORD target;
} runtime_pseudo_reloc_item_v1;
/* v2 relocation is more complex. In effect, it is
* *(base + .target) += *(base + .sym) - (base + .sym)
* with care taken in both reading, sign extension, and writing
* because .flags may indicate that (base + .target) may point
* to a BYTE, WORD, DWORD, or QWORD (w64).
*/
typedef struct {
DWORD sym;
DWORD target;
@ -29,24 +73,123 @@ typedef struct {
} runtime_pseudo_reloc_item_v2;
typedef struct {
DWORD magic1;
DWORD magic2;
DWORD version;
DWORD magic1;
DWORD magic2;
DWORD version;
} runtime_pseudo_reloc_v2;
static void ATTRIBUTE_NORETURN
__report_error (const char *msg, ...)
{
#ifdef __CYGWIN__
/* This function is used to print short error messages
* to stderr, which may occur during DLL initialization
* while fixing up 'pseudo' relocations. This early, we
* may not be able to use cygwin stdio functions, so we
* use the win32 WriteFile api. This should work with both
* normal win32 console IO handles, redirected ones, and
* cygwin ptys.
*/
char buf[SHORT_MSG_BUF_SZ];
wchar_t module[MAX_PATH];
char * posix_module = NULL;
static const char UNKNOWN_MODULE[] = "<unknown module>: ";
static const size_t UNKNOWN_MODULE_LEN = sizeof (UNKNOWN_MODULE) - 1;
static const char CYGWIN_FAILURE_MSG[] = "Cygwin runtime failure: ";
static const size_t CYGWIN_FAILURE_MSG_LEN = sizeof (CYGWIN_FAILURE_MSG) - 1;
DWORD len;
DWORD done;
va_list args;
HANDLE errh = GetStdHandle (STD_ERROR_HANDLE);
ssize_t modulelen = GetModuleFileNameW (NULL, module, sizeof (module));
if (errh == INVALID_HANDLE_VALUE)
cygwin_internal (CW_EXIT_PROCESS,
STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION,
1);
if (modulelen > 0)
posix_module = cygwin_create_path (CCP_WIN_W_TO_POSIX, module);
va_start (args, msg);
len = (DWORD) vsnprintf (buf, SHORT_MSG_BUF_SZ, msg, args);
va_end (args);
buf[SHORT_MSG_BUF_SZ-1] = '\0'; /* paranoia */
if (posix_module)
{
WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG,
CYGWIN_FAILURE_MSG_LEN, &done, NULL);
WriteFile (errh, (PCVOID)posix_module,
strlen(posix_module), &done, NULL);
WriteFile (errh, (PCVOID)": ", 2, &done, NULL);
WriteFile (errh, (PCVOID)buf, len, &done, NULL);
free (posix_module);
}
else
{
WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG,
CYGWIN_FAILURE_MSG_LEN, &done, NULL);
WriteFile (errh, (PCVOID)UNKNOWN_MODULE,
UNKNOWN_MODULE_LEN, &done, NULL);
WriteFile (errh, (PCVOID)buf, len, &done, NULL);
}
WriteFile (errh, (PCVOID)"\n", 1, &done, NULL);
cygwin_internal (CW_EXIT_PROCESS,
STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION,
1);
/* not reached, but silences noreturn warning */
abort ();
#else
va_list argp;
va_start (argp, msg);
# ifdef __MINGW64_VERSION_MAJOR
fprintf (stderr, "Mingw-w64 runtime failure:\n");
# else
fprintf (stderr, "Mingw runtime failure:\n");
# endif
vfprintf (stderr, msg, argp);
va_end (argp);
abort ();
#endif
}
/* This function temporarily marks the page containing addr
* writable, before copying len bytes from *src to *addr, and
* then restores the original protection settings to the page.
*
* Using this function eliminates the requirement with older
* pseudo-reloc implementations, that sections containing
* pseudo-relocs (such as .text and .rdata) be permanently
* marked writable. This older behavior sabotaged any memory
* savings achieved by shared libraries on win32 -- and was
* slower, too. However, on cygwin as of binutils 2.20 the
* .text section is still marked writable, and the .rdata section
* is folded into the (writable) .data when --enable-auto-import.
*/
static void
__write_memory (void *addr, const void *src, size_t len)
{
MEMORY_BASIC_INFORMATION b;
DWORD oldprot;
if (!len)
return;
assert (VirtualQuery (addr, &b, sizeof(b)));
if (!VirtualQuery (addr, &b, sizeof(b)))
{
__report_error (" VirtualQuery failed for %d bytes at address %p",
(int) sizeof(b), addr);
}
/* Temporarily allow write access to read-only protected memory. */
if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE,
&oldprot);
/* write the data. */
memcpy (addr, src, len);
/* Restore original protection. */
if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
VirtualProtect (b.BaseAddress, b.RegionSize, oldprot, &oldprot);
}
@ -55,66 +198,122 @@ __write_memory (void *addr, const void *src, size_t len)
#define RP_VERSION_V2 1
static void
do_pseudo_reloc (void *start, void *end, void *base)
do_pseudo_reloc (void * start, void * end, void * base)
{
ptrdiff_t addr_imp, reldata;
ptrdiff_t reloc_target = (ptrdiff_t) ((char *)end - (char*)start);
runtime_pseudo_reloc_v2 *v2_hdr = (runtime_pseudo_reloc_v2 *) start;
runtime_pseudo_reloc_item_v2 *r;
/* A valid relocation list will contain at least one entry, and
* one v1 data structure (the smallest one) requires two DWORDs.
* So, if the relocation list is smaller than 8 bytes, bail.
*/
if (reloc_target < 8)
return;
/* Check if this is old version pseudo relocation version. */
/* Check if this is the old pseudo relocation version. */
/* There are two kinds of v1 relocation lists:
* 1) With a (v2-style) version header. In this case, the
* first entry in the list is a 3-DWORD structure, with
* value:
* { 0, 0, RP_VERSION_V1 }
* In this case, we skip to the next entry in the list,
* knowing that all elements after the head item can
* be cast to runtime_pseudo_reloc_item_v1.
* 2) Without a (v2-style) version header. In this case, the
* first element in the list IS an actual v1 relocation
* record, which is two DWORDs. Because there will never
* be a case where a v1 relocation record has both
* addend == 0 and target == 0, this case will not be
* confused with the prior one.
* All current binutils, when generating a v1 relocation list,
* use the second (e.g. original) form -- that is, without the
* v2-style version header.
*/
if (reloc_target >= 12
&& v2_hdr->magic1 == 0 && v2_hdr->magic2 == 0
&& v2_hdr->version == RP_VERSION_V1)
{
/* We have a list header item indicating that the rest
* of the list contains v1 entries. Move the pointer to
* the first true v1 relocation record. By definition,
* that v1 element will not have both addend == 0 and
* target == 0 (and thus, when interpreted as a
* runtime_pseudo_reloc_v2, it will not have both
* magic1 == 0 and magic2 == 0).
*/
v2_hdr++;
}
if (v2_hdr->magic1 != 0 || v2_hdr->magic2 != 0)
{
runtime_pseudo_reloc_item_v1 *o;
for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr; o < (runtime_pseudo_reloc_item_v1 *)end; o++)
{
DWORD newval;
/*************************
* Handle v1 relocations *
*************************/
runtime_pseudo_reloc_item_v1 * o;
for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr;
o < (runtime_pseudo_reloc_item_v1 *)end;
o++)
{
DWORD newval;
reloc_target = (ptrdiff_t) base + o->target;
newval = (*((DWORD*) reloc_target)) + o->addend;
__write_memory ((void *) reloc_target, &newval, sizeof(DWORD));
}
}
return;
}
/* If we got this far, then we have relocations of version 2 or newer */
/* Check if this is a known version. */
if (v2_hdr->version != RP_VERSION_V2)
{
#ifdef DEBUG
fprintf (stderr, "pseudo_relocation protocol version %d is unknown to this runtime.\n",
(int) v2_hdr->version);
#endif
__report_error (" Unknown pseudo relocation protocol version %d.\n",
(int) v2_hdr->version);
return;
}
/* Walk over header. */
/*************************
* Handle v2 relocations *
*************************/
/* Walk over header. */
r = (runtime_pseudo_reloc_item_v2 *) &v2_hdr[1];
for (; r < (runtime_pseudo_reloc_item_v2 *) end; r++)
{
/* location where new address will be written */
reloc_target = (ptrdiff_t) base + r->target;
/* get sym pointer. It points either to the iat entry
* of the referenced element, or to the stub function.
*/
addr_imp = (ptrdiff_t) base + r->sym;
addr_imp = *((ptrdiff_t *) addr_imp);
switch ((r->flags&0xff))
/* read existing relocation value from image, casting to the
* bitsize indicated by the 8 LSBs of flags. If the value is
* negative, manually sign-extend to ptrdiff_t width. Raise an
* error if the bitsize indicated by the 8 LSBs of flags is not
* supported.
*/
switch ((r->flags & 0xff))
{
case 8:
reldata = (ptrdiff_t) (*((unsigned char *)reloc_target));
if ((reldata&0x80) != 0)
if ((reldata & 0x80) != 0)
reldata |= ~((ptrdiff_t) 0xff);
break;
case 16:
reldata = (ptrdiff_t) (*((unsigned short *)reloc_target));
if ((reldata&0x8000) != 0)
if ((reldata & 0x8000) != 0)
reldata |= ~((ptrdiff_t) 0xffff);
break;
case 32:
reldata = (ptrdiff_t) (*((unsigned int *)reloc_target));
#ifdef _WIN64
if ((reldata&0x80000000) != 0)
if ((reldata & 0x80000000) != 0)
reldata |= ~((ptrdiff_t) 0xffffffff);
#endif
break;
@ -125,15 +324,18 @@ do_pseudo_reloc (void *start, void *end, void *base)
#endif
default:
reldata=0;
#ifdef DEBUG
fprintf(stderr, "Unknown pseudo relocation bit size %d\n",(int) (r->flags & 0xff));
#endif
__report_error (" Unknown pseudo relocation bit size %d.\n",
(int) (r->flags & 0xff));
break;
}
/* Adjust the relocation value */
reldata -= ((ptrdiff_t) base + r->sym);
reldata += addr_imp;
/* Write the new relocation value back to *reloc_target */
switch ((r->flags & 0xff))
{
{
case 8:
__write_memory ((void *) reloc_target, &reldata, 1);
break;
@ -148,18 +350,18 @@ do_pseudo_reloc (void *start, void *end, void *base)
__write_memory ((void *) reloc_target, &reldata, 8);
break;
#endif
}
}
}
}
}
void _pei386_runtime_relocator (void);
void
_pei386_runtime_relocator (void)
{
static int was_init = 0;
static NO_COPY int was_init = 0;
if (was_init)
return;
++was_init;
do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&__ImageBase);
do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,
&__RUNTIME_PSEUDO_RELOC_LIST_END__,
&__MINGW_LSYMBOL(_image_base__));
}

16
reactos/lib/3rdparty/mingw/strcasecmp.c vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#define __CRT__NO_INLINE
#include <string.h>
#undef strcasecmp
int strcasecmp (const char *, const char *);
int
strcasecmp (const char *sz1, const char *sz2)
{
return _stricmp (sz1,sz2);
}

View file

@ -0,0 +1,17 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#define __CRT__NO_INLINE
#include <string.h>
#undef strncasecmp
int strncasecmp (const char *, const char *, size_t);
int
strncasecmp (const char *sz1,const char *sz2,size_t sizeMaxCompare)
{
return _strnicmp (sz1,sz2,sizeMaxCompare);
}

13
reactos/lib/3rdparty/mingw/tlsmcrt.c vendored Normal file
View file

@ -0,0 +1,13 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*
* Written by Kai Tietz <kai.tietz@onevision.com>
*/
/* We support TLS cleanup code in any case. If shared version of libgcc is used _CRT_MT has value 1,
otherwise
we do tls cleanup in runtime and _CRT_MT has value 2. */
int _CRT_MT = 2;

59
reactos/lib/3rdparty/mingw/tlsmthread.c vendored Normal file
View file

@ -0,0 +1,59 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*
* Written by Kai Tietz <kai.tietz@onevision.com>
*/
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <stdlib.h>
int __mingwthr_key_dtor (DWORD key, void (*dtor)(void *));
int __mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
#ifndef _WIN64
#define MINGWM10_DLL "mingwm10.dll"
typedef int (*fMTRemoveKeyDtor)(DWORD key);
typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *));
extern fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor;
extern fMTKeyDtor __mingw_gMTKeyDtor;
extern int __mingw_usemthread_dll;
#endif
int
__mingwthr_remove_key_dtor (DWORD key)
{
#ifndef _WIN64
if (!__mingw_usemthread_dll)
#endif
return ___w64_mingwthr_remove_key_dtor (key);
#ifndef _WIN64
if (__mingw_gMTRemoveKeyDtor)
return (*__mingw_gMTRemoveKeyDtor) (key);
return 0;
#endif
}
int
__mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
{
if (dtor)
{
#ifndef _WIN64
if (!__mingw_usemthread_dll)
#endif
return ___w64_mingwthr_add_key_dtor (key, dtor);
#ifndef _WIN64
if (__mingw_gMTKeyDtor)
return (*__mingw_gMTKeyDtor) (key, dtor);
#endif
}
return 0;
}

View file

@ -1,20 +1,32 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*
* Written by Kai Tietz <kai.tietz@onevision.com>
*/
#ifdef CRTDLL
#undef CRTDLL
#endif
#include <internal.h>
#include <sect_attribs.h>
#include <windows.h>
#include <stdio.h>
#include <memory.h>
#include <malloc.h>
#include <crtdbg.h>
extern BOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
#ifndef _CRTALLOC
#define _CRTALLOC(x) __attribute__ ((section (x) ))
#endif
#ifndef __INTERNAL_FUNC_DEFINED
#define __INTERNAL_FUNC_DEFINED
typedef void (__cdecl *_PVFV)(void);
typedef int (__cdecl *_PIFV)(void);
typedef void (__cdecl *_PVFI)(int);
#endif
extern WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
#define FUNCS_PER_NODE 30
@ -66,6 +78,16 @@ static __CRT_THREAD TlsDtorNode dtor_list_head;
extern int _CRT_MT;
#ifndef _WIN64
#define MINGWM10_DLL "mingwm10.dll"
typedef int (*fMTRemoveKeyDtor)(DWORD key);
typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *));
fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor;
fMTKeyDtor __mingw_gMTKeyDtor;
int __mingw_usemthread_dll;
static HANDLE __mingw_mthread_hdll;
#endif
BOOL WINAPI __dyn_tls_init (HANDLE, DWORD, LPVOID);
BOOL WINAPI
@ -73,6 +95,30 @@ __dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
_PVFV *pfunc;
#ifndef _WIN64
if (_winmajor < 4)
{
__mingw_usemthread_dll = 1;
__mingw_mthread_hdll = LoadLibrary (MINGWM10_DLL);
if (__mingw_mthread_hdll != NULL)
{
__mingw_gMTRemoveKeyDtor = (fMTRemoveKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_remove_key_dtor");
__mingw_gMTKeyDtor = (fMTKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_key_dtor");
}
if (__mingw_mthread_hdll == NULL || !__mingw_gMTRemoveKeyDtor || !__mingw_gMTKeyDtor)
{
__mingw_gMTKeyDtor = NULL;
__mingw_gMTRemoveKeyDtor = NULL;
if (__mingw_mthread_hdll)
FreeLibrary (__mingw_mthread_hdll);
__mingw_mthread_hdll = NULL;
_CRT_MT = 0;
return TRUE;
}
_CRT_MT = 1;
return TRUE;
}
#endif
/* We don't let us trick here. */
if (_CRT_MT != 2)
_CRT_MT = 2;

View file

@ -1,9 +1,11 @@
/*
* mthr_stub.c
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*
* Implement Mingw-w64 thread-support.
* Written by Kai Tietz <kai.tietz@onevision.com>
*
* This file is used by if gcc is built with --enable-threads=win32.
* This file is used by if gcc is built with --enable-threads=win32.
*
* Based on version created by Mumit Khan <khan@nanotech.wisc.edu>
*
@ -15,7 +17,7 @@
#include <windows.h>
#include <stdlib.h>
BOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
int ___w64_mingwthr_remove_key_dtor (DWORD key);
int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
@ -42,12 +44,10 @@ ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *))
if (__mingwthr_cs_init == 0)
return 0;
new_key = (__mingwthr_key_t *)malloc(sizeof (__mingwthr_key_t));
new_key = (__mingwthr_key_t *) calloc (1, sizeof (__mingwthr_key_t));
if (new_key == NULL)
return -1;
memset(new_key, 0,sizeof (__mingwthr_key_t));
new_key->key = key;
new_key->dtor = dtor;
@ -116,8 +116,8 @@ __mingwthr_run_key_dtors (void)
LeaveCriticalSection (&__mingwthr_cs);
}
BOOL
WINBOOL
__mingw_TLScallback (HANDLE hDllHandle __attribute__ ((__unused__)),
DWORD reason,
LPVOID reserved __attribute__ ((__unused__)))

17
reactos/lib/3rdparty/mingw/toascii.c vendored Normal file
View file

@ -0,0 +1,17 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <ctype.h>
#undef toascii
int toascii (int);
int
toascii (int c)
{
return __toascii(c);
}

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <fcntl.h>

14
reactos/lib/3rdparty/mingw/ucrtexe.c vendored Normal file
View file

@ -0,0 +1,14 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef UNICODE
#define UNICODE
#endif
#define WPRFLAG 1
#include "crtexe.c"

14
reactos/lib/3rdparty/mingw/udll_argv.c vendored Normal file
View file

@ -0,0 +1,14 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef UNICODE
#define UNICODE
#endif
#define WPRFLAG 1
#include "dll_argv.c"

14
reactos/lib/3rdparty/mingw/udllargc.c vendored Normal file
View file

@ -0,0 +1,14 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef UNICODE
#define UNICODE
#endif
#define WPRFLAG 1
#include "dllargv.c"

17
reactos/lib/3rdparty/mingw/wcscmpi.c vendored Normal file
View file

@ -0,0 +1,17 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#define __CRT__NO_INLINE
#include <string.h>
#undef wcscmpi
int wcscmpi (const wchar_t *, const wchar_t *);
int
wcscmpi (const wchar_t * ws1,const wchar_t * ws2)
{
return _wcsicmp (ws1,ws2);
}

View file

@ -1,19 +1,33 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
/* _dowildcard is an int that controls the globbing of the command line.
* If _dowildcard is non-zero, the command line will be globbed: *.*
* will be expanded to be all files in the startup directory.
*
* In the mingw-w64 library the _dowildcard variable is defined as being
* 0, therefore command line globbing is DISABLED by default. To turn it
* on and to leave wildcard command line processing MS's globbing code,
* include a line in one of your source modules defining _dowildcard and
* setting it to -1, like so:
* int _dowildcard = -1;
*
* Alternatively, the mingw-w64 library can be configured using the
* --enable-wildcard option and compiled thusly upon which the resulting
* library will have _dowildcard as -1 and command line globbing will be
* enabled by default.
*/
int _dowildcard = 0;
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef __ENABLE_GLOBBING
#define __ENABLE_GLOBBING 0 /* -1 */
#endif
int _dowildcard = __ENABLE_GLOBBING;

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _commode = 0;

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int __globallocalestatus = ~0x1;

View file

@ -1,7 +1,7 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _fmode = 0;