void __chk8087( void ) /********************/ { _RWD_real87 = __r87; _RWD_8087 = __87; _fpreset(); }
static void APIENTRY begin_thread_helper( thread_args *td ) /*********************************************************/ { thread_fn *rtn; void *arg; EXCEPTIONREGISTRATIONRECORD xcpt; thread_data *tdata; rtn = td->rtn; arg = td->argument; tdata = __alloca( __ThreadDataSize ); memset( tdata, 0, __ThreadDataSize ); // tdata->__allocated = 0; tdata->__data_size = __ThreadDataSize; if( !__Is_DLL ) { if( !__OS2AddThread( *_threadid, tdata ) ) return; } DosPostEventSem( td->event ); _fpreset(); __XCPTHANDLER = &xcpt; __sig_init_rtn(); (*rtn)( arg ); _endthread(); }
void __chk8087( void ) /********************/ { char devinfo; #if defined( _M_I86 ) if( _RWD_8087 == 0 ) { DosDevConfig( &devinfo, 3, 0 ); if( devinfo == 0 ) { _RWD_real87 = 0; } else { _RWD_real87 = __x87id(); } _RWD_8087 = _RWD_real87; } if( _RWD_real87 ) { __GrabFP87(); } if( _RWD_8087 ) { _RWD_FPE_handler = __default_sigfpe_handler; } #else DosDevConfig( &devinfo, DEVINFO_COPROCESSOR ); if( devinfo == 0 ) { _RWD_real87 = 0; } else { _RWD_real87 = __x87id(); } _RWD_8087 = _RWD_real87; #endif _fpreset(); }
/* This function will be called when a trap occurs. Thanks to Jacob Navia for his contribution. */ static CALLBACK long _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_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; }
int matherr() /***************************************************************************** * ****************************************************************************/ { _fpreset(); builtin_err = Err_float; return 1; }
void __init_8087( void ) { #if !defined( __UNIX__ ) && !defined( __OS2_386__ ) if( _RWD_real87 != 0 ) { /* if our emulator, don't worry */ _RWD_Save8087 = __save_8087; /* point to real save 8087 routine */ _RWD_Rest8087 = __rest_8087; /* point to real restore 8087 routine */ } #endif _fpreset(); }
void __chk8087( void ) /********************/ { extern char __87; extern char __r87; _RWD_real87 = __r87; _RWD_8087 = __87; _fpreset(); }
void __chk8087( void ) /********************/ { // TODO: We really need to call Linux and determine if the machine // has a real FPU or not, so we can properly work with an FPU // emulator. _RWD_real87 = __x87id(); _RWD_8087 = _RWD_real87; _fpreset(); }
/////////////////////////////////////////////////////////////////////////////// // constructor of any FloatException has to clear exception CFltException::CFltException (const char *_S) : CMathException(_S) { _clearfp(); // turn off exception for _controlfp to succeed UINT uiCW = _controlfp (0, 0); // save current control word _fpreset(); // reset everything _controlfp (uiCW, (UINT)~0); // restore control word }
/* fphandler handles SIGFPE (floating-point error) interrupt. Note * that this prototype accepts two arguments and that the * prototype for signal in the run-time library expects a signal * handler to have only one argument. * * The second argument in this signal handler allows processing of * _FPE_INVALID, _FPE_OVERFLOW, _FPE_UNDERFLOW, and * _FPE_ZERODIVIDE, all of which are Microsoft-specific symbols * that augment the information provided by SIGFPE. The compiler * will generate a warning, which is harmless and expected. */ void fphandler(int sig, int num) { /* Set global for outside check since we don't want * to do I/O in the handler. */ fperr = num; /* Initialize floating-point package. */ _fpreset(); /* Restore calling environment and jump back to setjmp. Return * -1 so that setjmp will return false for conditional test. */ printf("about to do longjmp\n"); fflush(stdout); longjmp(mark, -1); }
void #endif fpe_trap(int signo) { #if defined(i386) && !defined(M_XENIX) asm(" fnclex"); asm(" fwait"); #else #ifdef IEEE_MATH (void)fpsetsticky((fp_except)0); /* Clear exception */ #endif /* IEEE_MATH */ #ifdef PC _fpreset(); #endif #endif longjmp(fpe_buf, 1); }
static int fpe_handler(int signum) #endif /***************************************************************************** * this routine catches div-by-zero and overflows in fp math instructions. * we just set builtin_err so that the poco interpreter will see an error * upon completion of the current virtual machine instruction, then we * re-install ourselves since signal handlers are one-shot by definition. * IMPORTANT NOTES: * watcom calls the floating point signal handler from within its * interupt handler for 80387 exceptions. upon entry to this routine, * the hardware stack (ss:esp) is pointing to a 768-byte interupt stack! * if this routine is ever modified to take more extensive actions (ie, * calling an error reporting dialog) it will be necessary to switch to * a bigger stack. * despite what the watcom docs say, the 'errno' variable is NOT valid * upon entry to this routine! ****************************************************************************/ { _fpreset(); /* clear status & re-init chip/emulator */ builtin_err = Err_float; /* remember error for poco interpreter */ signal(SIGFPE, fpe_handler); /* re-install self */ return(0); /* don't know who looks at this... */ }
void cdecl _EXPFUNC _tstartup(MODULE_DATA *mod_table) { EXCEPTIONREGISTRATIONRECORD hand; MULTI_INIT *share_dll_table; /* module tables for DLLs */ int i; /* Set the _isWindows flag if this is a Windows application. * This is used by _ErrorMessage to determine whether to put * up a dialog box or write to the console. */ _isWindows = mod_table->flags & MF_WINDOWS; /* Disable precision, denormal, and underflow floating point exceptions, * enable all others. Also set other control bits; see deflt87.c. */ _fpreset(); /* Initialize pointers to _matherr and _matherrl, _fmode, and _fileinfo */ _initmatherr(mod_table->matherr, mod_table->matherrl); _initfmode(mod_table->fmode); _initfileinfo(mod_table->pfileinfo); /* Make up a MULTI_INIT structure for this EXE. */ _exe_table.ntables = 1; _exe_table.table[0] = mod_table; /* Save a pointer to the exception registration record in the stack. * If signal() is used, or stack checking is enabled, or threads * are created, except.c will be linked in and will use this pointer * to install an exception handler. */ _ExcRegPtr = &hand; /* Hack to link in GP handler */ _InitDefaultHander(); /* Set up global variables pointing to the environment data * and command line, respectively. These are used by _INIT_ * functions to set up argc, argv, and _environ before main is called. * Also save the module handle for use by WINMAIN. */ _tosenv = GetEnvironmentStrings(); _toscmd = GetCommandLine(); /* Initialize wildcard expansion if necessary */ _init_wild_handlers(mod_table->wild_func, mod_table->wwild_func); /* Initialize pointers to the routines that will handle the argv processing. */ _init_setargv_handlers( mod_table->setargv_func, mod_table->exitargv_func, mod_table->wsetargv_func, mod_table->wexitargv_func ); /* Call initialization functions for any DLLs that might have * been loaded. Then call each DLL's pseudo-entry point, * which simply calls that DLL's _dllmain(). */ if ((share_dll_table = _create_shmem()) != NULL) { /* Put a -1 marker at the end of the list of DLL module tables. * This forces any DLLs that are loaded dynamically later to * call their initialization functions themselves. */ share_dll_table->table[share_dll_table->ntables] = (MODULE_DATA *)-1; /* Call all the _INIT_ functions */ _init_exit_proc(share_dll_table, 0); /* Call _dllmain. */ for (i = 0; i < share_dll_table->ntables; i++) #pragma warn -pro share_dll_table->table[i]->main(0, share_dll_table->table[i]->hmod); #pragma warn .pro } /* Call all the initialization functions for the EXE. */ _init_exit_proc(&_exe_table, 0); if (mod_table->flags & MF_WINDOWS) { _TCHAR *cmdline, termchar; /* Skip past leading whitespace in command line. */ for (cmdline = _toscmd; *cmdline == _TEXT(' ') || *cmdline == _TEXT('\t'); cmdline++) ; /* Check whether EXE name is quoted, if so then we need to search for * the terminating quote. */ if (*cmdline == _TEXT('"')) { termchar = _TEXT('"'); cmdline++; } else termchar = _TEXT(' '); /* Skip past program name. */ while (*cmdline && *cmdline != termchar && *cmdline != _TEXT('\t')) cmdline++; /* If we ended up on terminating quote then skip it. */ if (*cmdline == _TEXT('"')) cmdline++; /* Skip past leading whitespace in command line. */ while (*cmdline && *cmdline == _TEXT(' ') || *cmdline == _TEXT('\t')) cmdline++; /* Call WinMain, exit with its return code. */ #pragma warn -pro exit(mod_table->main(GetModuleHandle(NULL), NULL, cmdline, GetSWFlag())); #pragma warn .pro } else { /* Call main, exit with its return code. */ #pragma warn -pro exit(mod_table->main(_C0argc,_tC0argv,_tC0environ)); #pragma warn .pro } }
/** Configures the application - returns false if the user chooses to abandon configuration. */ Ogre::Root* OgreSetup::configure(void) { ConfigService& configService(EmberServices::getSingleton().getConfigService()); createOgreSystem(); #ifndef BUILD_WEBEMBER bool success = false; bool suppressConfig = false; if (configService.itemExists("ogre", "suppressconfigdialog")) { suppressConfig = static_cast<bool>(configService.getValue("ogre", "suppressconfigdialog")); } try { success = mRoot->restoreConfig(); if (!success || !suppressConfig) { success = showConfigurationDialog(); } } catch (const std::exception& ex) { S_LOG_WARNING("Error when showing config dialog. Will try to remove ogre.cfg file and retry." << ex); unlink((EmberServices::getSingleton().getConfigService().getHomeDirectory() + "/ogre.cfg").c_str()); try { success = mRoot->showConfigDialog(); } catch (const std::exception& ex) { S_LOG_CRITICAL("Could not configure Ogre. Will shut down." << ex); } } if (!success) { return false; } mRenderWindow = mRoot->initialise(true, "Ember"); #else //BUILD_WEBEMBER == true //In webember we will disable the config dialog. //Also we will use fixed resolution and windowed mode. try { mRoot->restoreConfig(); } catch (const std::exception& ex) { //this isn't a problem, we will set the needed functions manually. } Ogre::RenderSystem* renderer = mRoot->getRenderSystem(); #ifdef _WIN32 //on windows, the default renderer is directX, we will force OpenGL. renderer = mRoot->getRenderSystemByName("OpenGL Rendering Subsystem"); if (renderer != NULL) { mRoot->setRenderSystem(renderer); } else { S_LOG_WARNING("OpenGL RenderSystem not found. Starting with default RenderSystem."); renderer = mRoot->getRenderSystem(); } #endif // _WIN32 renderer->setConfigOption("Video Mode", "800 x 600"); renderer->setConfigOption("Full Screen", "no"); mRoot->initialise(false, "Ember"); Ogre::NameValuePairList options; if (configService.itemExists("ogre", "windowhandle")) { //set the owner window std::string windowhandle = configService.getValue("ogre", "windowhandle"); options["parentWindowHandle"] = windowhandle; //put it in the top left corner options["top"] = "0"; options["left"] = "0"; } mRenderWindow = mRoot->createRenderWindow("Ember",800,600,false,&options); #endif // BUILD_WEBEMBER #ifdef _WIN32 //do some FPU fiddling, since we need the correct settings for stuff like mercator (which uses fractals etc.) to work _fpreset(); _controlfp(_PC_64, _MCW_PC); _controlfp(_RC_NEAR , _MCW_RC); #endif mRenderWindow->setActive(true); mRenderWindow->setAutoUpdated(true); mRenderWindow->setVisible(true); setStandardValues(); // Create new scene manager factory mSceneManagerFactory = new EmberPagingSceneManagerFactory(); // Register our factory mRoot->addSceneManagerFactory(mSceneManagerFactory); return mRoot; }
void OpenFileDlg::LoadWfdiscRecords(LPSTR lpFileName) { int nRecord=0; CListCtrl m_list; char cChan[32],cSpS[32],cSta[32],cTimeBeg[32],cTimeEnd[32]; LV_ITEM lvi; static char line[WFDISC_SIZE+2]; static wfdisc wfd; struct wfdisc *pwfdisc; pwfdisc=&wfd; m_list.Attach(GetDlgItem(IDC_LIST)->m_hWnd); m_list.DeleteAllItems(); int result; struct _stat buffer; result = _stat(lpFileName, &buffer); if( result == 0 ) { int file_type=_S_IFREG; int dir_type=_S_IFDIR ; if( (buffer.st_mode & _S_IFMT) == _S_IFMT) { m_list.Detach(); return; } } else { m_list.Detach(); return; } FILE *fp=fopen(lpFileName,"rt"); if(fp==NULL) { m_list.Detach(); return; } _fpreset(); while(1) { if (fgets(line, WFDISC_SIZE+1, fp) == NULL) break; if (lstrlen(line) == WFDISC_SIZE) { // sscanf(line, WFDISC_SCS, WFDISC_RVL(pwfdisc)); ScanWfdLine(pwfdisc, line); WFDISC_TRM(pwfdisc); lstrcpy(cSta, pwfdisc->sta); lstrcpy(cChan, pwfdisc->chan); sprintf(cSpS,"%.3f", pwfdisc->smprate); sprintf(cTimeBeg,"%s",dttostr(pwfdisc->time, 1)); sprintf(cTimeEnd,"%s",dttostr(pwfdisc->endtime, 1)); memset(&lvi,0,sizeof(lvi)); lvi.iItem=nRecord; lvi.iSubItem=0; lvi.mask=LVIF_TEXT; lvi.iImage=0; lvi.cchTextMax=sizeof(cSta); lvi.pszText=cSta; m_list.InsertItem(&lvi); m_list.SetItemText(nRecord,1,cChan); m_list.SetItemText(nRecord,2,cSpS); m_list.SetItemText(nRecord,3,cTimeBeg); m_list.SetItemText(nRecord,4,cTimeEnd); ++nRecord; } } fclose(fp); m_list.Detach(); }
void test_fp_and_80x87_math( void ) { double dnum; int inum; #ifdef __FPI__ unsigned fp_status, fp_control, fp_mask, origbits, bits; #endif printf( "Testing other floating point " ); #ifdef __FPI__ printf( "and 80x87 specific " ); #endif printf( "functions...\n" ); VERIFY( CompDbl( j0( 2.387 ), 0.009288 ) ); VERIFY( CompDbl( j1( 2.387 ), 0.522941 ) ); VERIFY( CompDbl( jn( 2, 2.387 ), 0.428870 ) ); VERIFY( CompDbl( y0( 2.387 ), 0.511681 ) ); VERIFY( CompDbl( y1( 2.387 ), 0.094374 ) ); VERIFY( CompDbl( yn( 2, 2.387 ), -0.432608 ) ); VERIFY( ceil( 1.0001 ) == 2.0 ); VERIFY( ceil( -1.0001 ) == -1.0 ); VERIFY( floor( 1.0001 ) == 1.0 ); VERIFY( floor( -1.0001 ) == -2.0 ); VERIFY( CompDbl( exp( 1.0 ), E ) ); VERIFY( CompDbl( exp( 3.0 ), E * E * E ) ); VERIFY( exp( 0.0 ) == 1.0 ); VERIFY( fabs( -1.5 ) == 1.5 ); VERIFY( fabs( 2.5 ) == 2.5 ); VERIFY( fabs( 0.0 ) == 0.0 ); VERIFY( fmod( 2.5, 0.5 ) == 0.0 ); VERIFY( fmod( 4.5, 2.0 ) == 0.5 ); VERIFY( fmod( -4.5, 2.0 ) == -0.5 ); VERIFY( fmod( -7.5, -2.0 ) == -1.5 ); dnum = frexp( 65535.0, &inum ); VERIFY( inum == 16 ); VERIFY( CompDbl( ldexp( dnum, inum ), 65535.0 ) ); while( inum-- > 0 ) dnum *= 2; VERIFY( CompDbl( dnum, 65535.0 ) ); VERIFY( CompDbl( log( E ), 1.0 ) ); VERIFY( CompDbl( log( 1.0 ), 0.0 ) ); VERIFY( CompDbl( log( 1.0 / E ), -1.0 ) ); VERIFY( CompDbl( log10( 10.0 ), 1.0 ) ); VERIFY( CompDbl( log10( 1 ), 0.0 ) ); VERIFY( CompDbl( log10( 0.1 ), -1.0 ) ); #ifdef __WATCOMC__ /* Not in Microsoft libs. */ VERIFY( CompDbl( log2( 65536.0 ), 16.0 ) ); VERIFY( CompDbl( log2( 1 ), 0.0 ) ); VERIFY( CompDbl( log2( 0.25 ), -2.0 ) ); #endif VERIFY( CompDbl( sqrt( 99980001.0 ), 9999.0 ) ); dnum = 1.0/DBL_MIN; VERIFY( CompDbl( 1.0 / dnum, DBL_MIN ) ); VERIFY( CompDbl( modf( PI, &dnum ), PI - 3.0 ) ); VERIFY( dnum == 3.0 ); VERIFY( CompDbl( modf( -PI, &dnum ) , - PI + 3.0 ) ); VERIFY( dnum == -3.0 ); VERIFY( pow( 1.0, 123456789.0 ) == 1.0 ); VERIFY( pow( 2.0, 16.0 ) == 65536.0 ); VERIFY( CompDbl( pow( E, log(1234.0) ), 1234.0 ) ); #ifdef __FPI__ VERIFY( sqrt( -1 ) == 1 ); // Now my_matherrno should == DOMAIN after calling sqrt( -1 ) // If not, matherr() fails VERIFY( my_matherrno == DOMAIN ); my_matherrno = 0; // reset VERIFY( sqrt( 0 ) == 0 ); VERIFY( my_matherrno == 0 ); _fpreset(); fp_status = _clear87(); VERIFY( fp_status == 0 ); // fp_status = _status87(); VERIFY( fp_status == 0 ); // _fpreset(); fp_control = _control87( 0, 0 ); bits = fp_control & MCW_IC; bits = (bits == IC_AFFINE) ? IC_PROJECTIVE : IC_AFFINE; fp_control = _control87( bits, MCW_IC ); VERIFY( (fp_control & MCW_IC) == bits ); bits = (bits == IC_AFFINE) ? IC_PROJECTIVE : IC_AFFINE; fp_control = _control87( bits, MCW_IC ); VERIFY( (fp_control & MCW_IC) == bits ); // fp_control = _control87( 0, 0 ); origbits = fp_control & MCW_RC; bits = (origbits == RC_NEAR) ? RC_CHOP : RC_NEAR; fp_control = _control87( bits, MCW_RC ); VERIFY( (fp_control & MCW_RC) == bits ); fp_control = _control87( origbits, MCW_RC ); VERIFY( (fp_control & MCW_RC) == origbits ); // _fpreset(); fp_control = 0; fp_mask = _EM_INEXACT; signal( SIGFPE, (void (*)(int))my_handler ); (void)_control87( fp_control, fp_mask ); q = a / b; VERIFY( sig_count > 0 ); fp_control = _EM_INEXACT; (void)_control87( fp_control, fp_mask ); sig_count = 0; q = a / b; VERIFY( sig_count == 0 ); signal( SIGFPE, SIG_DFL ); #endif }
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; #ifdef _WIN64 case EXCEPTION_DATATYPE_MISALIGNMENT: case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: case EXCEPTION_FLT_STACK_CHECK: case EXCEPTION_INT_OVERFLOW: case EXCEPTION_INVALID_HANDLE: /*case EXCEPTION_POSSIBLE_DEADLOCK: */ action = EXCEPTION_CONTINUE_EXECUTION; break; #endif default: break; } if (action == EXCEPTION_CONTINUE_SEARCH && __mingw_oldexcpt_handler) action = (*__mingw_oldexcpt_handler)(exception_data); return action; }
__declspec(noinline) int __tmainCRTStartup (void) { _TCHAR *lpszCommandLine = NULL; STARTUPINFO StartupInfo; WINBOOL inDoubleQuote = FALSE; memset (&StartupInfo, 0, sizeof (STARTUPINFO)); if (mingw_app_type) GetStartupInfo (&StartupInfo); { void *lock_free = NULL; void *fiberid = ((PNT_TIB)NtCurrentTeb())->StackBase; int nested = FALSE; while((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock, fiberid, 0)) != 0) { if (lock_free == fiberid) { nested = TRUE; break; } Sleep(1000); } if (__native_startup_state == __initializing) { _amsg_exit (31); } else if (__native_startup_state == __uninitialized) { __native_startup_state = __initializing; _initterm ((_PVFV *)(void *)__xi_a, (_PVFV *)(void *) __xi_z); } else has_cctor = 1; if (__native_startup_state == __initializing) { _initterm (__xc_a, __xc_z); __native_startup_state = __initialized; } _ASSERTE(__native_startup_state == __initialized); if (! nested) (VOID)InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0); if (__dyn_tls_init_callback != NULL) __dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL); _pei386_runtime_relocator (); __mingw_oldexcpt_handler = SetUnhandledExceptionFilter (_gnu_exception_handler); #ifdef _WIN64 __mingw_init_ehandler (); #endif __mingw_prepare_except_for_msvcr80_and_higher (); _fpreset (); if (mingw_app_type) { #ifdef WPRFLAG lpszCommandLine = (_TCHAR *) _wcmdln; #else lpszCommandLine = (char *) _acmdln; #endif while (*lpszCommandLine > SPACECHAR || (*lpszCommandLine&&inDoubleQuote)) { if (*lpszCommandLine == DQUOTECHAR) inDoubleQuote = !inDoubleQuote; #ifdef _MBCS if (_ismbblead (*lpszCommandLine)) { if (lpszCommandLine) /* FIXME: Why this check? Should I check for *lpszCommandLine != 0 too? */ lpszCommandLine++; } #endif ++lpszCommandLine; } while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR)) lpszCommandLine++; __mingw_winmain_hInstance = (HINSTANCE) &__ImageBase; __mingw_winmain_lpCmdLine = lpszCommandLine; __mingw_winmain_nShowCmd = StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? StartupInfo.wShowWindow : SW_SHOWDEFAULT; } duplicate_ppstrings (argc, &argv); #ifdef WPRFLAG __winitenv = envp; /* C++ initialization. gcc inserts this call automatically for a function called main, but not for wmain. */ __main (); mainret = wmain (argc, argv, envp); #else __initenv = envp; mainret = main (argc, argv, envp); #endif if (!managedapp) exit (mainret); if (has_cctor == 0) _cexit (); } return mainret; }
void fpreset(void) { _fpreset(); }
int QtWinMainCRTStartup() { #ifdef __MSVCRT__ __set_app_type (__GUI_APP); #endif SetUnhandledExceptionFilter (_gnu_exception_handler); /* * Initialize floating point unit. */ _fpreset (); /* Supplied by the runtime library. */ /* * 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. */ _pei386_runtime_relocator (); char *szCmd; STARTUPINFO startinfo; int nRet; /* Get the command line passed to the process. */ szCmd = GetCommandLineA (); GetStartupInfo (&startinfo); /* Strip off the name of the application and any leading * whitespace. */ if (szCmd) { while (ISSPACE (*szCmd)) { szCmd++; } /* On my system I always get the app name enclosed * in quotes... */ if (*szCmd == '\"') { do { szCmd++; } while (*szCmd != '\"' && *szCmd != '\0'); if (*szCmd == '\"') { szCmd++; } } else { /* If no quotes then assume first token is program * name. */ while (!ISSPACE (*szCmd) && *szCmd != '\0') { szCmd++; } } while (ISSPACE (*szCmd)) { szCmd++; } } nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd, (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? startinfo.wShowWindow : SW_SHOWDEFAULT); /* * Perform exit processing for the C library. This means * flushing output and calling 'atexit' registered functions. */ _cexit (); ExitProcess (nRet); return 0; }