mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 06:33:07 +00:00
- Sync the common mingw stuff with mingw-w64 HEAD
Only few modifications were necessary to get it to work flawlessy with our tree: -> getopt.c, which should rather be a part of "mingwex" (if we need the two Unix apps using it at all..) -> Adding an 'extern int __globallocalestatus;' to the "internal.h" -> Disabling the custom __mingw_get_crt_info, which depends on defines inside the mingw-w64 tree -> Small warning fixes, which will be submitted to mingw-w64 - Add an include directory "include/reactos/mingw-w64" for their header stuff to make synchronizations easier. - Remove remainders of our previous initialization routines, which still co-existed beside the new ones - Remove misleading and unnecessary files (i.e. "binmode.c") svn path=/trunk/; revision=40006
This commit is contained in:
parent
8b8a92d9da
commit
8d291610ee
40 changed files with 757 additions and 778 deletions
|
@ -1,8 +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 within this package.
|
||||
*/
|
||||
|
||||
#ifndef _INC_INTERNAL
|
||||
#define _INC_INTERNAL
|
||||
|
||||
#include <_mingw.h>
|
||||
#include <stdint.h>
|
||||
#include <crtdefs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -11,8 +16,6 @@ extern "C" {
|
|||
#include <limits.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define _CRTALLOC(x) __attribute__ ((section (x) ))
|
||||
|
||||
#pragma pack(push,_CRT_PACKING)
|
||||
|
||||
typedef void (__cdecl *_PVFV)(void);
|
|
@ -1,7 +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 within this package.
|
||||
*/
|
||||
|
||||
#ifndef _INC_OSCALLS
|
||||
#define _INC_OSCALLS
|
||||
|
||||
#include <_mingw.h>
|
||||
#ifndef _CRTBLD
|
||||
#error ERROR: Use of C runtime library internal header file.
|
||||
#endif
|
||||
|
||||
#include <crtdefs.h>
|
||||
|
||||
#ifdef NULL
|
||||
#undef NULL
|
60
reactos/include/reactos/mingw-w64/sect_attribs.h
Normal file
60
reactos/include/reactos/mingw-w64/sect_attribs.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined (__ia64__) || defined (__x86_64)
|
||||
#define _ATTRIBUTES
|
||||
#else
|
||||
#define _ATTRIBUTES shared
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* Reference list of existing section for msvcrt. */
|
||||
#pragma section(".CRTMP$XCA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRTMP$XCZ",long,_ATTRIBUTES)
|
||||
#pragma section(".CRTMP$XIA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRTMP$XIZ",long,_ATTRIBUTES)
|
||||
|
||||
#pragma section(".CRTMA$XCA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRTMA$XCZ",long,_ATTRIBUTES)
|
||||
#pragma section(".CRTMA$XIA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRTMA$XIZ",long,_ATTRIBUTES)
|
||||
|
||||
#pragma section(".CRTVT$XCA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRTVT$XCZ",long,_ATTRIBUTES)
|
||||
|
||||
#pragma section(".CRT$XCA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XCAA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XCC",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XCZ",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XDA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XDC",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XDZ",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XIA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XIAA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XIC",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XID",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XIY",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XIZ",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XLA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XLC",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XLD",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XLZ",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XPA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XPX",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XPXA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XPZ",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XTA",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XTB",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XTX",long,_ATTRIBUTES)
|
||||
#pragma section(".CRT$XTZ",long,_ATTRIBUTES)
|
||||
#pragma section(".rdata$T",long,read)
|
||||
#pragma section(".rtc$IAA",long,read)
|
||||
#pragma section(".rtc$IZZ",long,read)
|
||||
#pragma section(".rtc$TAA",long,read)
|
||||
#pragma section(".rtc$TZZ",long,read)
|
||||
#endif
|
||||
|
||||
#define _CRTALLOC(x) __attribute__ ((section (x) ))
|
6
reactos/lib/3rdparty/mingw/CRT_fp10.c
vendored
6
reactos/lib/3rdparty/mingw/CRT_fp10.c
vendored
|
@ -1,3 +1,9 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
void _fpreset (void)
|
||||
{ __asm__ ("fninit" ) ;}
|
||||
|
||||
|
|
6
reactos/lib/3rdparty/mingw/CRT_fp8.c
vendored
6
reactos/lib/3rdparty/mingw/CRT_fp8.c
vendored
|
@ -1,3 +1,9 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
extern void (*_imp___fpreset)(void) ;
|
||||
void _fpreset (void)
|
||||
{ (*_imp___fpreset)(); }
|
||||
|
|
6
reactos/lib/3rdparty/mingw/_newmode.c
vendored
6
reactos/lib/3rdparty/mingw/_newmode.c
vendored
|
@ -1 +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.
|
||||
*/
|
||||
|
||||
int _newmode = 0;
|
||||
|
|
15
reactos/lib/3rdparty/mingw/_wgetopt.c
vendored
15
reactos/lib/3rdparty/mingw/_wgetopt.c
vendored
|
@ -1,15 +0,0 @@
|
|||
/* $Id$
|
||||
*/
|
||||
/*
|
||||
tgetopt -- POSIX-compliant implementation of getopt() with string-type-generic
|
||||
semantics
|
||||
|
||||
This is public domain software
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
#define _UNICODE
|
||||
#include "getopt.c"
|
||||
|
||||
/* EOF */
|
11
reactos/lib/3rdparty/mingw/atonexit.c
vendored
11
reactos/lib/3rdparty/mingw/atonexit.c
vendored
|
@ -1,11 +1,18 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#undef CRTDLL
|
||||
#ifndef _DLL
|
||||
#define _DLL
|
||||
#endif
|
||||
|
||||
#include "oscalls.h"
|
||||
#include "internal.h"
|
||||
#include <oscalls.h>
|
||||
#include <internal.h>
|
||||
#include <stdlib.h>
|
||||
#include <crtdefs.h>
|
||||
#include <limits.h>
|
||||
#include <windows.h>
|
||||
|
||||
|
|
4
reactos/lib/3rdparty/mingw/binmode.c
vendored
4
reactos/lib/3rdparty/mingw/binmode.c
vendored
|
@ -1,4 +0,0 @@
|
|||
#define SPECIAL_CRTEXE
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
18
reactos/lib/3rdparty/mingw/charmax.c
vendored
18
reactos/lib/3rdparty/mingw/charmax.c
vendored
|
@ -1,9 +1,21 @@
|
|||
#include "internal.h"
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
int __lconv_init (void);
|
||||
#include <sect_attribs.h>
|
||||
#include <internal.h>
|
||||
|
||||
__declspec(dllimport) int __lconv_init (void);
|
||||
|
||||
int mingw_initcharmax = 0;
|
||||
|
||||
int _charmax = 255;
|
||||
|
||||
_CRTALLOC(".CRT$XIC") _PIFV __mingw_pinit = __lconv_init;
|
||||
static int my_lconv_init(void)
|
||||
{
|
||||
return __lconv_init();
|
||||
}
|
||||
|
||||
_CRTALLOC(".CRT$XIC") _PIFV __mingw_pinit = my_lconv_init;
|
||||
|
|
3
reactos/lib/3rdparty/mingw/cinitexe.c
vendored
3
reactos/lib/3rdparty/mingw/cinitexe.c
vendored
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include "internal.h"
|
||||
#include <internal.h>
|
||||
#include <sect_attribs.h>
|
||||
|
||||
_CRTALLOC(".CRT$XIA") _PVFV __xi_a[] = { NULL };
|
||||
_CRTALLOC(".CRT$XIZ") _PVFV __xi_z[] = { NULL };
|
||||
|
|
6
reactos/lib/3rdparty/mingw/crt0_c.c
vendored
6
reactos/lib/3rdparty/mingw/crt0_c.c
vendored
|
@ -1,3 +1,9 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
int main (int flags, char **cmdline, char **inst)
|
||||
|
|
13
reactos/lib/3rdparty/mingw/crt0_w.c
vendored
13
reactos/lib/3rdparty/mingw/crt0_w.c
vendored
|
@ -1,13 +1,20 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern void __main(void);
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine,int nShowCmd);
|
||||
|
||||
void __main(void);
|
||||
int wmain (int flags, wchar_t **cmdline, wchar_t **inst)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
/* C++ initialization. (gcc inserts this call automatically for
|
||||
* a function called "main", but not for "wmain") */
|
||||
/* C++ initialization.
|
||||
gcc inserts this call automatically for a function called main , but not for wmain. */
|
||||
__main();
|
||||
#endif
|
||||
return (int) wWinMain ((HINSTANCE) inst, NULL, (LPWSTR) cmdline,(DWORD) flags);
|
||||
|
|
6
reactos/lib/3rdparty/mingw/crtdll.c
vendored
6
reactos/lib/3rdparty/mingw/crtdll.c
vendored
|
@ -1,3 +1,9 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef CRTDLL
|
||||
#undef CRTDLL
|
||||
#define _DLL
|
||||
|
|
50
reactos/lib/3rdparty/mingw/crtexe.c
vendored
50
reactos/lib/3rdparty/mingw/crtexe.c
vendored
|
@ -1,15 +1,22 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#undef CRTDLL
|
||||
//#define _DLL
|
||||
|
||||
#define SPECIAL_CRTEXE
|
||||
|
||||
#include "oscalls.h"
|
||||
#include "internal.h"
|
||||
#include <oscalls.h>
|
||||
#include <internal.h>
|
||||
#include <process.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#include <sect_attribs.h>
|
||||
#include <locale.h>
|
||||
|
||||
#ifndef __winitenv
|
||||
|
@ -42,6 +49,7 @@ extern int *_imp___commode;
|
|||
#define _commode (*_imp___commode)
|
||||
extern int _dowildcard;
|
||||
|
||||
int _MINGW_INSTALL_DEBUG_MATHERR __attribute__((weak)) = 0;
|
||||
extern int __defaultmatherr;
|
||||
extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
|
||||
|
||||
|
@ -76,7 +84,7 @@ static _startupinfo startinfo;
|
|||
|
||||
extern void _pei386_runtime_relocator (void);
|
||||
static CALLBACK long _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
|
||||
//static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data);
|
||||
static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data);
|
||||
#ifdef WPRFLAG
|
||||
static void duplicate_ppstrings (int ac, wchar_t ***av);
|
||||
#else
|
||||
|
@ -107,9 +115,14 @@ pre_c_init (void)
|
|||
#else
|
||||
_setargv();
|
||||
#endif
|
||||
|
||||
if (! __defaultmatherr)
|
||||
__setusermatherr (_matherr);
|
||||
if (_MINGW_INSTALL_DEBUG_MATHERR)
|
||||
{
|
||||
if (! __defaultmatherr)
|
||||
{
|
||||
__setusermatherr (_matherr);
|
||||
__defaultmatherr = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (__globallocalestatus == -1)
|
||||
{
|
||||
|
@ -202,24 +215,24 @@ __tmainCRTStartup (void)
|
|||
if (__dyn_tls_init_callback != NULL && _IsNonwritableInCurrentImage ((PBYTE) &__dyn_tls_init_callback))
|
||||
__dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
_pei386_runtime_relocator ();
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#ifdef _WIN64
|
||||
__asm__ __volatile__ (
|
||||
"xorq %rax,%rax\n\t"
|
||||
"decq %rax\n\t"
|
||||
"movq %rax,%gs:0" "\n");
|
||||
#elif defined(__i386__)
|
||||
#else
|
||||
__asm__ __volatile__ (
|
||||
"xorl %eax,%eax\n\t"
|
||||
"decl %eax\n\t"
|
||||
"movl %eax,%fs:0" "\n");
|
||||
#endif
|
||||
//AddVectoredExceptionHandler (0, (PVECTORED_EXCEPTION_HANDLER)__mingw_vex);
|
||||
AddVectoredExceptionHandler (0, (PVECTORED_EXCEPTION_HANDLER)__mingw_vex);
|
||||
SetUnhandledExceptionFilter (_gnu_exception_handler);
|
||||
|
||||
_fpreset ();
|
||||
|
||||
if (mingw_app_type)
|
||||
{
|
||||
#ifdef WPRFLAG
|
||||
|
@ -229,10 +242,10 @@ __tmainCRTStartup (void)
|
|||
#else
|
||||
lpszCommandLine = (char *) _acmdln;
|
||||
#endif
|
||||
while (*lpszCommandLine > SPACECHAR || (*lpszCommandLine && inDoubleQuote))
|
||||
while (*lpszCommandLine > SPACECHAR || (*lpszCommandLine&&inDoubleQuote))
|
||||
{
|
||||
if (*lpszCommandLine == DQUOTECHAR)
|
||||
inDoubleQuote = TRUE;
|
||||
inDoubleQuote = !inDoubleQuote;
|
||||
#ifdef _MBCS
|
||||
if (_ismbblead (*lpszCommandLine))
|
||||
{
|
||||
|
@ -289,10 +302,9 @@ check_managed_app (void)
|
|||
PIMAGE_OPTIONAL_HEADER64 pNTHeader64;
|
||||
|
||||
/* Force to be linked. */
|
||||
//TLS sections
|
||||
//mingw_initltsdrot_force=1;
|
||||
//mingw_initltsdyn_force=1;
|
||||
//mingw_initltssuo_force=1;
|
||||
mingw_initltsdrot_force=1;
|
||||
mingw_initltsdyn_force=1;
|
||||
mingw_initltssuo_force=1;
|
||||
mingw_initcharmax=1;
|
||||
|
||||
pDOSHeader = (PIMAGE_DOS_HEADER) &__ImageBase;
|
||||
|
@ -319,8 +331,6 @@ check_managed_app (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int __defaultmatherr;
|
||||
|
||||
static CALLBACK long
|
||||
_gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
|
||||
{
|
||||
|
@ -400,7 +410,6 @@ _gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
|
|||
return action;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data)
|
||||
{
|
||||
/* TODO this is not chainablem, therefore need rewrite. Disabled the ill code. */
|
||||
|
@ -425,7 +434,6 @@ static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data)
|
|||
#endif
|
||||
return _gnu_exception_handler(exception_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WPRFLAG
|
||||
|
||||
|
|
22
reactos/lib/3rdparty/mingw/dllargv.c
vendored
22
reactos/lib/3rdparty/mingw/dllargv.c
vendored
|
@ -1,10 +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 within this package.
|
||||
*/
|
||||
|
||||
#ifdef CRTDLL
|
||||
#undef CRTDLL
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
extern int _dowildcard;
|
||||
#include <internal.h>
|
||||
|
||||
#ifdef WPRFLAG
|
||||
int __CRTDECL
|
||||
|
@ -16,15 +20,3 @@ _setargv (void)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WPRFLAG
|
||||
int __CRTDECL
|
||||
__wsetargv (void)
|
||||
#else
|
||||
int __CRTDECL
|
||||
__setargv (void)
|
||||
#endif
|
||||
{
|
||||
_dowildcard = 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
8
reactos/lib/3rdparty/mingw/dllentry.c
vendored
8
reactos/lib/3rdparty/mingw/dllentry.c
vendored
|
@ -1,5 +1,11 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <oscalls.h>
|
||||
#define _DECL_DLLMAIN
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
BOOL WINAPI DllEntryPoint(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
|
|
3
reactos/lib/3rdparty/mingw/dllmain.c
vendored
3
reactos/lib/3rdparty/mingw/dllmain.c
vendored
|
@ -1,6 +1,5 @@
|
|||
#include <oscalls.h>
|
||||
#define _DECL_DLLMAIN
|
||||
#define _WINDOWS_
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
BOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
|
|
14
reactos/lib/3rdparty/mingw/gccmain.c
vendored
14
reactos/lib/3rdparty/mingw/gccmain.c
vendored
|
@ -1,15 +1,9 @@
|
|||
/*
|
||||
* gccmain.c
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is a part of the mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within the package.
|
||||
*
|
||||
* A separate version of __main, __do_global_ctors and __do_global_dtors for
|
||||
* Mingw32 for use with Cygwin32 b19. Hopefully this object file will only
|
||||
* be linked if the libgcc.a doesn't include __main, __do_global_dtors and
|
||||
* __do_global_ctors.
|
||||
*
|
||||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
|
|
515
reactos/lib/3rdparty/mingw/getopt.c
vendored
515
reactos/lib/3rdparty/mingw/getopt.c
vendored
|
@ -1,137 +1,394 @@
|
|||
/* $Id$
|
||||
*/
|
||||
/*
|
||||
tgetopt -- POSIX-compliant implementation of getopt() with string-type-generic
|
||||
semantics
|
||||
|
||||
This is public domain software
|
||||
*/
|
||||
|
||||
#include <tchar.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "tgetopt.h"
|
||||
#define REPLACE_GETOPT
|
||||
|
||||
int _topterr = 1;
|
||||
int _toptind = 1;
|
||||
int _toptopt;
|
||||
_TCHAR * _toptarg;
|
||||
#define _DIAGASSERT(x) do {} while (0)
|
||||
|
||||
int _tgetopt(int argc, _TCHAR * const argv[], const _TCHAR * optstring)
|
||||
#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)
|
||||
{
|
||||
static int s_nArgChar = 0;
|
||||
_TCHAR * pcOptChar;
|
||||
|
||||
/* we're done */
|
||||
if(_toptind >= argc) return -1;
|
||||
|
||||
/* last time we reached the end of argv[_toptind] */
|
||||
if(s_nArgChar != 0 && argv[_toptind][s_nArgChar] == 0)
|
||||
{
|
||||
/* scan the next argument */
|
||||
++ _toptind;
|
||||
|
||||
/* we're done */
|
||||
if(_toptind >= argc) return -1;
|
||||
|
||||
s_nArgChar = 0;
|
||||
}
|
||||
|
||||
/* first time we scan argv[_toptind] */
|
||||
if(s_nArgChar == 0)
|
||||
{
|
||||
/* argument is NULL - we're done */
|
||||
if(argv[_toptind] == NULL)
|
||||
return (int)-1;
|
||||
/* argument is empty - we're done */
|
||||
else if(argv[_toptind][0] == 0)
|
||||
return (int)-1;
|
||||
/* argument begins with '-' */
|
||||
else if(argv[_toptind][0] == _T('-'))
|
||||
{
|
||||
/* argument is "--" */
|
||||
if(argv[_toptind][1] == _T('-'))
|
||||
{
|
||||
/* increment optind */
|
||||
++ _toptind;
|
||||
s_nArgChar = 0;
|
||||
|
||||
/* we're done */
|
||||
return (int)-1;
|
||||
}
|
||||
/* argument is "-" */
|
||||
else if(argv[_toptind][1] == 0)
|
||||
{
|
||||
/* we're done */
|
||||
return (int)-1;
|
||||
}
|
||||
/* possible option */
|
||||
else
|
||||
++ s_nArgChar;
|
||||
}
|
||||
/* argument doesn't begin with a dash - we're done */
|
||||
else
|
||||
return (int)-1;
|
||||
}
|
||||
|
||||
/* return the current character */
|
||||
_toptopt = argv[_toptind][s_nArgChar];
|
||||
|
||||
/* advance to the next character */
|
||||
++ s_nArgChar;
|
||||
|
||||
/* unrecognized option */
|
||||
if(_toptopt == _T(':') || (pcOptChar = _tcschr(optstring, _toptopt)) == NULL)
|
||||
{
|
||||
/* print an error message */
|
||||
if(_topterr && optstring[0] != _T(':'))
|
||||
_ftprintf(stderr, _T("%s: illegal option -- %c\n"), argv[0], _toptopt);
|
||||
|
||||
/* return an error */
|
||||
return _T('?');
|
||||
}
|
||||
|
||||
/* the option requires an argument */
|
||||
if(pcOptChar[1] == _T(':'))
|
||||
{
|
||||
/* we are at the end of the argument */
|
||||
if(argv[_toptind][s_nArgChar] == 0)
|
||||
{
|
||||
/* the argument of the option is the next argument */
|
||||
++ _toptind;
|
||||
s_nArgChar = 0;
|
||||
|
||||
/* this is the last argument */
|
||||
if(_toptind >= argc)
|
||||
{
|
||||
/* print an error message */
|
||||
if(_topterr && optstring[0] != _T(':'))
|
||||
{
|
||||
_ftprintf
|
||||
(
|
||||
stderr,
|
||||
_T("%s: option requires an argument -- %c\n"),
|
||||
argv[0],
|
||||
_toptopt
|
||||
);
|
||||
}
|
||||
|
||||
/* return an error */
|
||||
return ((optstring[0] == _T(':')) ? _T(':') : _T('?'));
|
||||
}
|
||||
|
||||
/* return the argument */
|
||||
_toptarg = argv[_toptind];
|
||||
++ _toptind;
|
||||
}
|
||||
/* the rest of the argument is the argument of the option */
|
||||
else
|
||||
_toptarg = argv[_toptind] + s_nArgChar;
|
||||
}
|
||||
|
||||
/* success */
|
||||
return _toptopt;
|
||||
(void)fprintf(stderr,"%s: ",__progname);
|
||||
if (fmt != NULL)
|
||||
(void)vfprintf(stderr,fmt,ap);
|
||||
(void)fprintf(stderr,"\n");
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
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;
|
||||
}
|
||||
|
|
14
reactos/lib/3rdparty/mingw/gs_support.c
vendored
14
reactos/lib/3rdparty/mingw/gs_support.c
vendored
|
@ -1,3 +1,9 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#ifdef _WIN64
|
||||
#include <intrin.h>
|
||||
|
@ -13,11 +19,12 @@
|
|||
#ifdef _WIN64
|
||||
PRUNTIME_FUNCTION RtlLookupFunctionEntry (ULONG64, PULONG64, PVOID);
|
||||
PVOID RtlVirtualUnwind (ULONG HandlerType, ULONG64, ULONG64, PRUNTIME_FUNCTION,
|
||||
PCONTEXT, PVOID *, PULONG64, PKNONVOLATILE_CONTEXT_POINTERS);
|
||||
PCONTEXT, PVOID *, PULONG64, PVOID);
|
||||
#endif
|
||||
|
||||
typedef LONG NTSTATUS;
|
||||
|
||||
#define UNW_FLAG_NHANDLER 0x00
|
||||
#define STATUS_STACK_BUFFER_OVERRUN ((NTSTATUS)0xC0000409L)
|
||||
|
||||
typedef union
|
||||
|
@ -33,8 +40,8 @@ static const EXCEPTION_POINTERS GS_ExceptionPointers = {
|
|||
&GS_ExceptionRecord,&GS_ContextRecord
|
||||
};
|
||||
|
||||
__declspec(selectany) UINT_PTR __security_cookie = DEFAULT_SECURITY_COOKIE;
|
||||
__declspec(selectany) UINT_PTR __security_cookie_complement = ~(DEFAULT_SECURITY_COOKIE);
|
||||
DECLSPEC_SELECTANY UINT_PTR __security_cookie = DEFAULT_SECURITY_COOKIE;
|
||||
DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement = ~(DEFAULT_SECURITY_COOKIE);
|
||||
|
||||
void __cdecl
|
||||
__security_init_cookie (void)
|
||||
|
@ -89,7 +96,6 @@ __report_gsfailure (ULONGLONG StackCookie)
|
|||
PVOID hndData;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN64
|
||||
RtlCaptureContext (&GS_ContextRecord);
|
||||
controlPC = GS_ContextRecord.Rip;
|
||||
|
|
25
reactos/lib/3rdparty/mingw/isascii.c
vendored
25
reactos/lib/3rdparty/mingw/isascii.c
vendored
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* isascii.c
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is a part of the mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within the package.
|
||||
*
|
||||
* Oldnames from ANSI header ctype.h
|
||||
*
|
||||
* Some wrapper functions for those old name functions whose appropriate
|
||||
* equivalents are not simply underscore prefixed.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef isascii
|
||||
#undef isascii
|
||||
#endif
|
||||
|
||||
int
|
||||
isascii (int c)
|
||||
{
|
||||
return __isascii(c);
|
||||
}
|
||||
|
24
reactos/lib/3rdparty/mingw/iscsym.c
vendored
24
reactos/lib/3rdparty/mingw/iscsym.c
vendored
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* iscsym.c
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is a part of the mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within the package.
|
||||
*
|
||||
* Oldnames from ANSI header ctype.h
|
||||
*
|
||||
* Some wrapper functions for those old name functions whose appropriate
|
||||
* equivalents are not simply underscore prefixed.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef iscsym
|
||||
#undef iscsym
|
||||
#endif
|
||||
|
||||
int
|
||||
iscsym (int c)
|
||||
{
|
||||
return __iscsym(c);
|
||||
}
|
25
reactos/lib/3rdparty/mingw/iscsymf.c
vendored
25
reactos/lib/3rdparty/mingw/iscsymf.c
vendored
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* iscsymf.c
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is a part of the mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within the package.
|
||||
*
|
||||
* Oldnames from ANSI header ctype.h
|
||||
*
|
||||
* Some wrapper functions for those old name functions whose appropriate
|
||||
* equivalents are not simply underscore prefixed.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef iscsymf
|
||||
#undef iscsymf
|
||||
#endif
|
||||
|
||||
int
|
||||
iscsymf (int c)
|
||||
{
|
||||
return __iscsymf(c);
|
||||
}
|
||||
|
51
reactos/lib/3rdparty/mingw/merr.c
vendored
51
reactos/lib/3rdparty/mingw/merr.c
vendored
|
@ -1,12 +1,53 @@
|
|||
#include "internal.h"
|
||||
#include <math.h>
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
int __defaultmatherr = 1;
|
||||
#include <internal.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int __defaultmatherr = 0;
|
||||
|
||||
int __CRTDECL
|
||||
_matherr (struct _exception *pexcept)
|
||||
{
|
||||
/* Make compiler happy. */
|
||||
pexcept = pexcept;
|
||||
const char * type;
|
||||
|
||||
switch(pexcept->type)
|
||||
{
|
||||
case _DOMAIN:
|
||||
type = "Argument domain error (DOMAIN)";
|
||||
break;
|
||||
|
||||
case _SING:
|
||||
type = "Argument singularity (SIGN)";
|
||||
break;
|
||||
|
||||
case _OVERFLOW:
|
||||
type = "Overflow range error (OVERFLOW)";
|
||||
break;
|
||||
|
||||
case _PLOSS:
|
||||
type = "Partial loss of significance (PLOSS)";
|
||||
break;
|
||||
|
||||
case _TLOSS:
|
||||
type = "Total loss of significance (TLOSS)";
|
||||
break;
|
||||
|
||||
case _UNDERFLOW:
|
||||
type = "The result is too small to be represented (UNDERFLOW)";
|
||||
break;
|
||||
|
||||
default:
|
||||
type = "Unknown error";
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stderr, "_matherr(): %s in %s(%g, %g) (retval=%g)\n",
|
||||
type, pexcept->name, pexcept->arg1, pexcept->arg2, pexcept->retval);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
18
reactos/lib/3rdparty/mingw/mingw.rbuild
vendored
18
reactos/lib/3rdparty/mingw/mingw.rbuild
vendored
|
@ -2,13 +2,12 @@
|
|||
<!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<group>
|
||||
<module name="mingw_common" type="staticlibrary" isstartuplib="true" underscoresymbols="true" crt="dll">
|
||||
<define name="_CRTBLD" />
|
||||
<importlibrary definition="moldname-msvcrt.def" dllname="msvcrt.dll" />
|
||||
<include base="mingw_common">include</include>
|
||||
<include base="ReactOS">include/reactos/mingw-w64</include>
|
||||
<library>kernel32</library>
|
||||
<file>_newmode.c</file>
|
||||
<file>_wgetopt.c</file>
|
||||
<file>atonexit.c</file>
|
||||
<file>binmode.c</file>
|
||||
<file>charmax.c</file>
|
||||
<file>cinitexe.c</file>
|
||||
<file>CRT_fp10.c</file>
|
||||
|
@ -30,21 +29,24 @@
|
|||
<file>xtxtmode.c</file>
|
||||
</module>
|
||||
<module name="mingw_main" type="staticlibrary" isstartuplib="true" crt="dll">
|
||||
<include base="mingw_common">include</include>
|
||||
<define name="_CRTBLD" />
|
||||
<include base="ReactOS">include/reactos/mingw-w64</include>
|
||||
<file>crt0_c.c</file>
|
||||
<file>crtexe.c</file>
|
||||
<file>dllargv.c</file>
|
||||
</module>
|
||||
<module name="mingw_wmain" type="staticlibrary" isstartuplib="true" unicode="yes" crt="dll">
|
||||
<include base="mingw_common">include</include>
|
||||
<define name="WPRFLAG"/>
|
||||
<define name="_CRTBLD" />
|
||||
<define name="WPRFLAG" />
|
||||
<include base="ReactOS">include/reactos/mingw-w64</include>
|
||||
<file>crt0_w.c</file>
|
||||
<file>crtexe.c</file>
|
||||
<file>dllargv.c</file>
|
||||
</module>
|
||||
<module name="mingw_dllmain" type="staticlibrary" isstartuplib="true" crt="dll">
|
||||
<include base="mingw_common">include</include>
|
||||
<file>dllargv.c</file>
|
||||
<define name="_CRTBLD" />
|
||||
<include base="ReactOS">include/reactos/mingw-w64</include>
|
||||
<file>crtdll.c</file>
|
||||
<file>dllargv.c</file>
|
||||
</module>
|
||||
</group>
|
||||
|
|
22
reactos/lib/3rdparty/mingw/mingw_helpers.c
vendored
22
reactos/lib/3rdparty/mingw/mingw_helpers.c
vendored
|
@ -1,10 +1,20 @@
|
|||
#include "oscalls.h"
|
||||
#include "internal.h"
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <oscalls.h>
|
||||
#include <internal.h>
|
||||
#include <process.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#include <sect_attribs.h>
|
||||
#include <locale.h>
|
||||
#if 0
|
||||
#include "../revstamp.h"
|
||||
#endif
|
||||
|
||||
const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
|
||||
|
||||
|
@ -23,3 +33,11 @@ _encode_pointer (void *ptr)
|
|||
/* 0:console, 1:windows. */
|
||||
int mingw_app_type = 0;
|
||||
|
||||
#if 0
|
||||
const char *__mingw_get_crt_info (void)
|
||||
{
|
||||
return "MinGW-W64 Runtime " __MINGW64_VERSION " ("
|
||||
__MINGW64_VERSION_STATE " - "
|
||||
"rev. " __MINGW_W64_REV ") " __MINGW_W64_REV_STAMP;
|
||||
}
|
||||
#endif
|
||||
|
|
37
reactos/lib/3rdparty/mingw/moldname-msvcrt.def
vendored
37
reactos/lib/3rdparty/mingw/moldname-msvcrt.def
vendored
|
@ -1,28 +1,3 @@
|
|||
;
|
||||
; moldname-msvcrt.def
|
||||
;
|
||||
; Exports from the runtime except that these exports are actually preceeded
|
||||
; by a underscore in the actual DLL. These correspond to functions which
|
||||
; are non-ANSI and were prefixed with an underscore to avoid name space
|
||||
; clutter. However many, in fact most programs still use a few of these
|
||||
; functions without the underscore. This .def file is specially processed
|
||||
; to make those non-underscored name function calls call the equivalent
|
||||
; underscored functions.
|
||||
;
|
||||
; Contributors:
|
||||
; Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
; Maintained by Mumit Khan <khan@xraylith.wisc.edu>
|
||||
;
|
||||
; 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.
|
||||
;
|
||||
EXPORTS
|
||||
access
|
||||
chdir
|
||||
|
@ -31,9 +6,7 @@ chsize
|
|||
close
|
||||
creat
|
||||
cwait
|
||||
|
||||
daylight DATA
|
||||
|
||||
dup
|
||||
dup2
|
||||
ecvt
|
||||
|
@ -52,10 +25,10 @@ fgetchar
|
|||
fgetwchar
|
||||
filelength
|
||||
fileno
|
||||
; Alias fpreset is set in CRT_fp10,c and CRT_fp8.c.
|
||||
; fpreset
|
||||
fputchar
|
||||
fputwchar
|
||||
;fstat
|
||||
ftime
|
||||
gcvt
|
||||
getch
|
||||
|
@ -95,6 +68,7 @@ spawnv
|
|||
spawnve
|
||||
spawnvp
|
||||
spawnvpe
|
||||
;stat
|
||||
strcmpi
|
||||
strdup
|
||||
stricmp
|
||||
|
@ -108,10 +82,7 @@ strupr
|
|||
swab
|
||||
tell
|
||||
tempnam
|
||||
|
||||
timezone DATA
|
||||
|
||||
; export tzname for both. See <time.h>
|
||||
tzname DATA
|
||||
tzset
|
||||
umask
|
||||
|
@ -127,9 +98,7 @@ wcsnset
|
|||
wcsrev
|
||||
wcsset
|
||||
wcsupr
|
||||
|
||||
wpopen
|
||||
|
||||
write
|
||||
; non-ANSI functions declared in math.h
|
||||
j0
|
||||
|
@ -139,7 +108,7 @@ y0
|
|||
y1
|
||||
yn
|
||||
chgsign
|
||||
scalb
|
||||
;scalb
|
||||
finite
|
||||
fpclass
|
||||
; C99 functions
|
||||
|
|
9
reactos/lib/3rdparty/mingw/natstart.c
vendored
9
reactos/lib/3rdparty/mingw/natstart.c
vendored
|
@ -1,4 +1,11 @@
|
|||
#include "internal.h"
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <crtdefs.h>
|
||||
#include <internal.h>
|
||||
|
||||
_PGLOBAL
|
||||
volatile unsigned int __native_dllmain_reason = UINT_MAX;
|
||||
|
|
6
reactos/lib/3rdparty/mingw/pesect.c
vendored
6
reactos/lib/3rdparty/mingw/pesect.c
vendored
|
@ -1,3 +1,9 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#if defined (_WIN64) && defined (__ia64__)
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
char __RUNTIME_PSEUDO_RELOC_LIST_END__ = 0;
|
||||
char __RUNTIME_PSEUDO_RELOC_LIST__ = 0;
|
||||
|
|
45
reactos/lib/3rdparty/mingw/pseudo-reloc.c
vendored
45
reactos/lib/3rdparty/mingw/pseudo-reloc.c
vendored
|
@ -1,7 +1,13 @@
|
|||
/* Only necesary on x86 and amd64 targets */
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
extern char __RUNTIME_PSEUDO_RELOC_LIST__;
|
||||
extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
|
||||
|
@ -24,6 +30,24 @@ typedef struct {
|
|||
DWORD version;
|
||||
} runtime_pseudo_reloc_v2;
|
||||
|
||||
static void
|
||||
__write_memory (void *addr,const void *src,size_t len)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION b;
|
||||
DWORD oldprot;
|
||||
if (!len)
|
||||
return;
|
||||
if (!VirtualQuery (addr, &b, sizeof(b)))
|
||||
abort ();
|
||||
// Protect
|
||||
if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
|
||||
VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE,
|
||||
&oldprot);
|
||||
memcpy (addr, src, len);
|
||||
if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
|
||||
VirtualProtect (b.BaseAddress, b.RegionSize, oldprot, &oldprot);
|
||||
}
|
||||
|
||||
#define RP_VERSION_V1 0
|
||||
#define RP_VERSION_V2 1
|
||||
|
||||
|
@ -47,8 +71,10 @@ do_pseudo_reloc (void* start,void *end,void *base)
|
|||
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;
|
||||
*((DWORD*) reloc_target) += o->addend;
|
||||
newval = (*((DWORD*) reloc_target)) + o->addend;
|
||||
__write_memory ((void *) reloc_target, &newval, sizeof(DWORD));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -102,17 +128,17 @@ do_pseudo_reloc (void* start,void *end,void *base)
|
|||
switch ((r->flags & 0xff))
|
||||
{
|
||||
case 8:
|
||||
*((unsigned char*)reloc_target)=(unsigned char) reldata;
|
||||
__write_memory ((void *) reloc_target, &reldata, 1);
|
||||
break;
|
||||
case 16:
|
||||
*((unsigned short*)reloc_target)=(unsigned short) reldata;
|
||||
__write_memory ((void *) reloc_target, &reldata, 2);
|
||||
break;
|
||||
case 32:
|
||||
*((unsigned int*)reloc_target)=(unsigned int) reldata;
|
||||
__write_memory ((void *) reloc_target, &reldata, 4);
|
||||
break;
|
||||
#ifdef _WIN64
|
||||
case 64:
|
||||
*((unsigned long long*)reloc_target)=(unsigned long long) reldata;
|
||||
__write_memory ((void *) reloc_target, &reldata, 8);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
@ -122,6 +148,9 @@ do_pseudo_reloc (void* start,void *end,void *base)
|
|||
void
|
||||
_pei386_runtime_relocator ()
|
||||
{
|
||||
static int was_init = 0;
|
||||
if (was_init)
|
||||
return;
|
||||
++was_init;
|
||||
do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&_image_base__);
|
||||
}
|
||||
#endif
|
||||
|
|
90
reactos/lib/3rdparty/mingw/tgetopt.h
vendored
90
reactos/lib/3rdparty/mingw/tgetopt.h
vendored
|
@ -1,90 +0,0 @@
|
|||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
#ifdef _UNICODE
|
||||
#define _toption _woption
|
||||
#define _toptarg _woptarg
|
||||
#define _toptind _woptind
|
||||
#define _topterr _wopterr
|
||||
#define _toptopt _woptopt
|
||||
#define _tgetopt _wgetopt
|
||||
#define _tgetopt_long _wgetopt_long
|
||||
#define _tgetopt_long_only _wgetopt_long_only
|
||||
#define _tgetopt_internal _wgetopt_internal
|
||||
#else
|
||||
#define _toption option
|
||||
#define _toptarg optarg
|
||||
#define _toptind optind
|
||||
#define _topterr opterr
|
||||
#define _toptopt optopt
|
||||
#define _tgetopt getopt
|
||||
#define _tgetopt_long getopt_long
|
||||
#define _tgetopt_long_only getopt_long_only
|
||||
#define _tgetopt_internal _getopt_internal
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
extern int opterr;
|
||||
extern int optopt;
|
||||
|
||||
extern wchar_t *_woptarg;
|
||||
extern int _woptind;
|
||||
extern int _wopterr;
|
||||
extern int _woptopt;
|
||||
|
||||
struct option
|
||||
{
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
struct _woption
|
||||
{
|
||||
const wchar_t *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts, const struct option *longopts, int *longind);
|
||||
|
||||
extern int _wgetopt (int argc, wchar_t *const *argv, const wchar_t *shortopts);
|
||||
extern int _wgetopt_long (int argc, wchar_t *const *argv, const wchar_t *shortopts,
|
||||
const struct _woption *longopts, int *longind);
|
||||
extern int _wgetopt_long_only (int argc, wchar_t *const *argv,
|
||||
const wchar_t *shortopts,
|
||||
const struct _woption *longopts, int *longind);
|
||||
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts, const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
|
||||
extern int _wgetopt_internal (int argc, wchar_t *const *argv,
|
||||
const wchar_t *shortopts,
|
||||
const struct _woption *longopts, int *longind,
|
||||
int long_only);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GETOPT_H */
|
||||
|
17
reactos/lib/3rdparty/mingw/tlssup.c
vendored
17
reactos/lib/3rdparty/mingw/tlssup.c
vendored
|
@ -1,8 +1,15 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef CRTDLL
|
||||
#undef CRTDLL
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
#include <internal.h>
|
||||
#include <sect_attribs.h>
|
||||
#include <windows.h>
|
||||
#include <malloc.h>
|
||||
#include <crtdbg.h>
|
||||
|
@ -54,13 +61,11 @@ __dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
|||
{
|
||||
_PVFV *pfunc;
|
||||
|
||||
//DbgPrint("__dyn_tls_init: hDllHandle %p, dwReason %d\n", hDllHandle,dwReason);
|
||||
if (dwReason != DLL_THREAD_ATTACH)
|
||||
return TRUE;
|
||||
|
||||
for (pfunc = &__xd_a + 1; pfunc != &__xd_z; ++pfunc)
|
||||
{
|
||||
//DbgPrint("pfunc at %p\n",pfunc);
|
||||
if (*pfunc != NULL)
|
||||
(*pfunc)();
|
||||
}
|
||||
|
@ -74,9 +79,7 @@ _CRTALLOC(".CRT$XLC") PIMAGE_TLS_CALLBACK __xl_c = (PIMAGE_TLS_CALLBACK) __dyn_t
|
|||
int __cdecl
|
||||
__tlregdtor (_PVFV func)
|
||||
{
|
||||
//DbgPrint("__tlregdtor: func %p\n",func);
|
||||
|
||||
if (dtor_list == NULL)
|
||||
if (dtor_list == NULL)
|
||||
{
|
||||
dtor_list = &dtor_list_head;
|
||||
dtor_list_head.count = 0;
|
||||
|
@ -99,11 +102,9 @@ __tlregdtor (_PVFV func)
|
|||
static BOOL WINAPI
|
||||
__dyn_tls_dtor (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
{
|
||||
|
||||
TlsDtorNode *pnode, *pnext;
|
||||
int i;
|
||||
|
||||
//DbgPrint("__dyn_tls_dtor: hDllHandle %p, dwReason %d\n");
|
||||
if (dwReason != DLL_THREAD_DETACH && dwReason != DLL_PROCESS_DETACH)
|
||||
return TRUE;
|
||||
|
||||
|
|
25
reactos/lib/3rdparty/mingw/toascii.c
vendored
25
reactos/lib/3rdparty/mingw/toascii.c
vendored
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* toascii.c
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is a part of the mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within the package.
|
||||
*
|
||||
* Oldnames from ANSI header ctype.h
|
||||
*
|
||||
* Some wrapper functions for those old name functions whose appropriate
|
||||
* equivalents are not simply underscore prefixed.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef toascii
|
||||
#undef toascii
|
||||
#endif
|
||||
|
||||
int
|
||||
toascii (int c)
|
||||
{
|
||||
return __toascii(c);
|
||||
}
|
||||
|
308
reactos/lib/3rdparty/mingw/wcrt1.c
vendored
308
reactos/lib/3rdparty/mingw/wcrt1.c
vendored
|
@ -1,308 +0,0 @@
|
|||
/*
|
||||
* crt1.c
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is a part of the mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within the package.
|
||||
*
|
||||
* Source code for the startup proceedures used by all programs. This code
|
||||
* is compiled to make crt1.o, which should be located in the library path.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Hide the declaration of _fmode with dllimport attribute in stdlib.h to
|
||||
avoid problems with older GCC. */
|
||||
#define __IN_MINGW_RUNTIME
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <signal.h>
|
||||
|
||||
/* NOTE: The code for initializing the _argv, _argc, and environ variables
|
||||
* has been moved to a separate .c file which is included in both
|
||||
* crt1.c and dllcrt1.c. This means changes in the code don't have to
|
||||
* be manually synchronized, but it does lead to this not-generally-
|
||||
* a-good-idea use of include. */
|
||||
#include "winit.c"
|
||||
#include "cpu_features.h"
|
||||
|
||||
extern void _pei386_runtime_relocator (void);
|
||||
|
||||
extern int wmain (int, wchar_t **, wchar_t **);
|
||||
|
||||
/*
|
||||
* Must have the correct app type for MSVCRT.
|
||||
*/
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
#define __UNKNOWN_APP 0
|
||||
#define __CONSOLE_APP 1
|
||||
#define __GUI_APP 2
|
||||
_CRTIMP void __set_app_type(int);
|
||||
#endif /* __MSVCRT__ */
|
||||
|
||||
/* Global _fmode for this .exe, not the one in msvcrt.dll,
|
||||
The default is set in txtmode.o in libmingw32.a */
|
||||
/* Override the dllimport'd declarations in stdlib.h */
|
||||
#undef _fmode
|
||||
extern int _fmode;
|
||||
#ifdef __MSVCRT__
|
||||
extern int* __p__fmode(void); /* To access the dll _fmode */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Setup the default file handles to have the _CRT_fmode mode, as well as
|
||||
* any new files created by the user.
|
||||
*/
|
||||
extern int _CRT_fmode;
|
||||
|
||||
static void
|
||||
_mingw32_init_fmode (void)
|
||||
{
|
||||
/* Don't set the std file mode if the user hasn't set any value for it. */
|
||||
if (_CRT_fmode)
|
||||
{
|
||||
_fmode = _CRT_fmode;
|
||||
|
||||
/*
|
||||
* This overrides the default file mode settings for stdin,
|
||||
* stdout and stderr. At first I thought you would have to
|
||||
* test with isatty, but it seems that the DOS console at
|
||||
* least is smart enough to handle _O_BINARY stdout and
|
||||
* still display correctly.
|
||||
*/
|
||||
if (stdin)
|
||||
{
|
||||
_setmode (_fileno (stdin), _CRT_fmode);
|
||||
}
|
||||
if (stdout)
|
||||
{
|
||||
_setmode (_fileno (stdout), _CRT_fmode);
|
||||
}
|
||||
if (stderr)
|
||||
{
|
||||
_setmode (_fileno (stderr), _CRT_fmode);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now sync the dll _fmode to the one for this .exe. */
|
||||
#ifdef __MSVCRT__
|
||||
*__p__fmode() = _fmode;
|
||||
#else
|
||||
*_imp___fmode_dll = _fmode;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function will be called when a trap occurs. Thanks to Jacob
|
||||
Navia for his contribution. */
|
||||
static LONG CALLBACK
|
||||
_gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
|
||||
{
|
||||
void (*old_handler) (int);
|
||||
LONG action = EXCEPTION_CONTINUE_SEARCH;
|
||||
int reset_fpu = 0;
|
||||
|
||||
switch (exception_data->ExceptionRecord->ExceptionCode)
|
||||
{
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
/* test if the user has set SIGSEGV */
|
||||
old_handler = signal (SIGSEGV, SIG_DFL);
|
||||
if (old_handler == SIG_IGN)
|
||||
{
|
||||
/* this is undefined if the signal was raised by anything other
|
||||
than raise (). */
|
||||
signal (SIGSEGV, SIG_IGN);
|
||||
action = EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
else if (old_handler != SIG_DFL)
|
||||
{
|
||||
/* This means 'old' is a user defined function. Call it */
|
||||
(*old_handler) (SIGSEGV);
|
||||
action = EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
break;
|
||||
|
||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||
case EXCEPTION_PRIV_INSTRUCTION:
|
||||
/* test if the user has set SIGILL */
|
||||
old_handler = signal (SIGILL, SIG_DFL);
|
||||
if (old_handler == SIG_IGN)
|
||||
{
|
||||
/* this is undefined if the signal was raised by anything other
|
||||
than raise (). */
|
||||
signal (SIGILL, SIG_IGN);
|
||||
action = EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
else if (old_handler != SIG_DFL)
|
||||
{
|
||||
/* This means 'old' is a user defined function. Call it */
|
||||
(*old_handler) (SIGILL);
|
||||
action = EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
break;
|
||||
|
||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
||||
case EXCEPTION_FLT_OVERFLOW:
|
||||
case EXCEPTION_FLT_UNDERFLOW:
|
||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
||||
reset_fpu = 1;
|
||||
/* fall through. */
|
||||
|
||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||
/* test if the user has set SIGFPE */
|
||||
old_handler = signal (SIGFPE, SIG_DFL);
|
||||
if (old_handler == SIG_IGN)
|
||||
{
|
||||
signal (SIGFPE, SIG_IGN);
|
||||
if (reset_fpu)
|
||||
_fpreset ();
|
||||
action = EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
else if (old_handler != SIG_DFL)
|
||||
{
|
||||
/* This means 'old' is a user defined function. Call it */
|
||||
(*old_handler) (SIGFPE);
|
||||
action = EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
/*
|
||||
* The function mainCRTStartup is the entry point for all console programs.
|
||||
*/
|
||||
static void __declspec(noreturn)
|
||||
__mingw_wCRTStartup (void)
|
||||
{
|
||||
int nRet;
|
||||
|
||||
/*
|
||||
* Set up the top-level exception handler so that signal handling
|
||||
* works as expected. The mapping between ANSI/POSIX signals and
|
||||
* Win32 SE is not 1-to-1, so caveat emptore.
|
||||
*
|
||||
*/
|
||||
SetUnhandledExceptionFilter (_gnu_exception_handler);
|
||||
|
||||
/*
|
||||
* Initialize floating point unit.
|
||||
*/
|
||||
__cpu_features_init (); /* Do we have SSE, etc.*/
|
||||
_fpreset (); /* Supplied by the runtime library. */
|
||||
|
||||
/*
|
||||
* Set up __argc, __argv and _wenviron.
|
||||
*/
|
||||
_mingw32_init_wmainargs ();
|
||||
|
||||
/*
|
||||
* Sets the default file mode.
|
||||
* If _CRT_fmode is set, also set mode for stdin, stdout
|
||||
* and stderr, as well
|
||||
* NOTE: DLLs don't do this because that would be rude!
|
||||
*/
|
||||
_mingw32_init_fmode ();
|
||||
|
||||
/* Adust references to dllimported data that have non-zero offsets. */
|
||||
#if defined(__i386__)
|
||||
_pei386_runtime_relocator ();
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if defined(__i386__)
|
||||
/* Align the stack to 16 bytes for the sake of SSE ops in main
|
||||
or in functions inlined into main. */
|
||||
asm __volatile__ ("andl $-16, %%esp" : : : "%esp");
|
||||
#elif defined(__mips__)
|
||||
/* Align the stack to 16 bytes */
|
||||
asm __volatile__ ("andi %sp,%sp,-16" : : : "%sp");
|
||||
#elif defined(__PowerPC__)
|
||||
/* Align the stack to 16 bytes */
|
||||
asm __volatile__ ("li 0,15\n\tandc 1,1,0" : : : "r1");
|
||||
#else
|
||||
#error Unsupported architecture
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_M_IX86)
|
||||
/* Align the stack to 16 bytes for the sake of SSE ops in main
|
||||
or in functions inlined into main. */
|
||||
__asm and esp, 0FFFFFFF0h
|
||||
#else
|
||||
#error Unsupported architecture
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Call the main function. If the user does not supply one
|
||||
* the one in the 'libmingw32.a' library will be linked in, and
|
||||
* that one calls WinMain. See main.c in the 'lib' dir
|
||||
* for more details.
|
||||
*/
|
||||
nRet = wmain (_argc, _wargv, _wenviron);
|
||||
|
||||
/*
|
||||
* Perform exit processing for the C library. This means
|
||||
* flushing output and calling 'atexit' registered functions.
|
||||
*/
|
||||
_cexit ();
|
||||
|
||||
ExitProcess (nRet);
|
||||
}
|
||||
|
||||
/*
|
||||
* The function mainCRTStartup is the entry point for all console programs.
|
||||
*/
|
||||
void
|
||||
wmainCRTStartup (void)
|
||||
{
|
||||
#ifdef __MSVCRT__
|
||||
__set_app_type (__CONSOLE_APP);
|
||||
#endif
|
||||
__mingw_wCRTStartup ();
|
||||
}
|
||||
|
||||
/*
|
||||
* For now the GUI startup function is the same as the console one.
|
||||
* This simply gets rid of the annoying warning about not being able
|
||||
* to find WinMainCRTStartup when linking GUI applications.
|
||||
*/
|
||||
void
|
||||
wWinMainCRTStartup (void)
|
||||
{
|
||||
#ifdef __MSVCRT__
|
||||
__set_app_type (__GUI_APP);
|
||||
#endif
|
||||
__mingw_wCRTStartup ();
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* We force use of library version of atexit, which is only
|
||||
* visible in import lib as _imp__atexit
|
||||
*/
|
||||
extern int (*_imp__atexit)(void (*)(void));
|
||||
int atexit (void (* pfn )(void) )
|
||||
{
|
||||
return ( (*_imp__atexit)(pfn));
|
||||
}
|
||||
|
||||
/* Likewise for non-ANSI _onexit */
|
||||
extern _onexit_t (*_imp___onexit)(_onexit_t);
|
||||
_onexit_t
|
||||
_onexit (_onexit_t pfn )
|
||||
{
|
||||
return (*_imp___onexit)(pfn);
|
||||
}
|
||||
#endif
|
6
reactos/lib/3rdparty/mingw/wildcard.c
vendored
6
reactos/lib/3rdparty/mingw/wildcard.c
vendored
|
@ -1 +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.
|
||||
*/
|
||||
|
||||
int _dowildcard = 0;
|
||||
|
|
6
reactos/lib/3rdparty/mingw/xncommod.c
vendored
6
reactos/lib/3rdparty/mingw/xncommod.c
vendored
|
@ -1 +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.
|
||||
*/
|
||||
|
||||
int _commode = 0;
|
||||
|
|
6
reactos/lib/3rdparty/mingw/xthdloc.c
vendored
6
reactos/lib/3rdparty/mingw/xthdloc.c
vendored
|
@ -1 +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.
|
||||
*/
|
||||
|
||||
int __globallocalestatus = ~0x1;
|
||||
|
|
6
reactos/lib/3rdparty/mingw/xtxtmode.c
vendored
6
reactos/lib/3rdparty/mingw/xtxtmode.c
vendored
|
@ -1 +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.
|
||||
*/
|
||||
|
||||
int _fmode = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue