int main( int, char ** ) { do_main(); CUDA_SAFE_CALL( cudaDeviceReset() ); return 0; }
int main( int argc, char **argv ) { int i; for(i=0;i<argc;i++) { if( strcmp(argv[i], "-reinit") == 0 ) reinit_every_iteration = 1; else if( strcmp(argv[i], "-add_no_defs") == 0 ) add_no_defs = 1; else if( strcmp(argv[i], "-num_iterations") == 0 && i+1 < argc ) { num_iterations = atoi(argv[i+1]); i++; } } #ifdef _WIN32 /* This is an incredible weirdness but with mingw cross-compiler */ /* 1. - b/a; where double a = 6378206.4; and double b = 6356583.8; */ /* does not evaluate the same in the main thread or in a thread forked */ /* by CreateThread(), so run the main in a thread... */ { HANDLE thread = CreateThread(NULL, 0, do_main, NULL, 0, NULL); WaitForSingleObject(thread, INFINITE); CloseHandle( thread ); } #else do_main(); #endif return 0; }
int main (int argc, char const * argv[]) { auto result = do_main ("mandelbrot_reference.pbm", argc, argv, &compute_set); std::printf (" iterations: %zu\n", iterations); return result; }
int main() { VM* vm = init_vm(100,100); do_main(vm, NULL); printf("%ld\n", GETINT(RVAL)); printf("%d %d %d\n", vm->valstack, vm->valstack_base, vm->valstack_top); }
void main(void) { struct device *dev; dev = device_get_binding("TMP112"); __ASSERT(dev != NULL, "Failed to get device binding"); printk("device is %p, name is %s\n", dev, dev->config->name); do_main(dev); }
void do_mainA() { wchar_t* argv[] = { (wchar_t*)L"twpipe.exe", (wchar_t*)L"A" }; wsetenv((wchar_t*)L"CLASSPATH",(wchar_t*)L".;classes;?:/classes;?:/system/java/lib/classes.zip",0); wsetenv((wchar_t*)L"VARIABLE2",(wchar_t*)L"value2",0); wsetenv((wchar_t*)L"USER",(wchar_t*)L"Tumblin' Wide Boy - Go fer yer guns!",0); do_main(2, argv); }
/** @SYMTestCaseID SYSLIB-STDLIB-CT-1093 @SYMTestCaseDesc Tests for operations on a child pipe @SYMTestPriority High @SYMTestActions Tests for reading from a pipe in the child process @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ void do_mainB() { test_Data; wchar_t* argv[] = {(wchar_t*) L"twpipe.exe", (wchar_t*)L"B" }; int nbytes=1; int mask, err; int firstread=1; /* Don't use test_* because it involves fflush and will cause deadlock */ printf("PIPE Child"); printf("Child reads from STDIN\n"); while (nbytes>0) { char buf[5]; printf("Child calls read of fid=0\n"); nbytes=read(0,buf,sizeof(buf)); printf("Child got %d bytes\n", nbytes); if (nbytes>0) { if (firstread) { /* We hope that there is still stuff to read */ printf("Child calls E32IOSELECT(WRITE) on STDIN\n"); mask=E32SELECT_WRITE; err=ioctl(0,E32IOSELECT,(void*)&mask); test(err==0); test(mask==0); printf("Child calls E32IOSELECT(READ) on STDIN\n"); mask=E32SELECT_READ+E32SELECT_WRITE; err=ioctl(0,E32IOSELECT,(void*)&mask); test(err==0); test(mask==E32SELECT_READ); firstread=0; } printf(" %02d >%.*s<\n", nbytes, nbytes, buf); } else if (nbytes<0) printf(" %d (errno=%d)\n", nbytes, errno); } printf("Child calls E32IOSELECT on STDOUT"); mask=E32SELECT_READ+E32SELECT_WRITE; err=ioctl(1,E32IOSELECT,(void*)&mask); test(err==0); test(mask==E32SELECT_WRITE); fflush(stdout); do_main(2, argv); fclose(stdout); }
int32 lua_dobuffer(const char *buff, int32 size, const char *name) { char newname[SIZE_PREF + 25]; ZIO z; int32 status; if (!name) { build_name(buff, newname); name = newname; } luaZ_mopen(&z, buff, size, name); status = do_main(&z, buff[0] == ID_CHUNK); return status; }
/* main() * ================================================================ */ void main( void ) { int i; appl_init(); AES_Version = _AESglobal[0]; /* Get the AES version number */ vhandle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox ); work_in[0] = Getrez()+2; /* let's not gag GDOS */ for( i = 1; i < 10; work_in[i++] = 1 ); work_in[10] = 2; v_opnvwk( work_in, &vhandle, work_out ); xres = work_out[0]; yres = work_out[1]; num_pens = work_out[13]; gl_screen.g_x = gl_screen.g_y = 0; gl_screen.g_w = xres + 1; gl_screen.g_h = yres + 1; /* We're too wide for ST LOW Rez */ if(( work_in[0] == STLOW ) || ( work_in[0] == TTLOW )) { form_alert( 1, alow ); v_clsvwk( vhandle ); appl_exit(); exit( 0 ); } wind_get( 0, WF_WORKXYWH, &gl_full.g_x, &gl_full.g_y, &gl_full.g_w, &gl_full.g_h ); initialize(); if( !rsrc_init()) { form_alert( 1, arsc ); Gem_Exit( -1 ); } do_main(); Gem_Exit( 0 ); }
int lua_dofile (char *filename) { ZIO z; int status; int c; int bin; char source[MAXFILENAME]; FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); if (f == NULL) return 2; luaL_filesource(source, filename, sizeof(source)); c = fgetc(f); ungetc(c, f); bin = (c == ID_CHUNK); if (bin && f != stdin) { f = freopen(filename, "rb", f); /* set binary mode */ if (f == NULL) return 2; } luaZ_Fopen(&z, f, source); status = do_main(&z, bin); if (f != stdin) fclose(f); return status; }
static void xop_test (void) { do_main (); }
int main(int argc, char* argv[]) { PRTime start = _PR_Now(); char exePath[MAXPATHLEN]; #ifdef XP_MACOSX TriggerQuirks(); #endif nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || (size_t(lastSlash - exePath) > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) return 255; strcpy(++lastSlash, XPCOM_DLL); int gotCounters; #if defined(XP_UNIX) struct rusage initialRUsage; gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); #elif defined(XP_WIN) IO_COUNTERS ioCounters; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); #endif // We do this because of data in bug 771745 XPCOMGlueEnablePreload(); rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } XRE_StartupTimelineRecord(mozilla::StartupTimeline::START, start); #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklist(); #endif if (gotCounters) { #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, int(ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, int(ioCounters.ReadTransferCount / 1024)); IO_COUNTERS newIoCounters; if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); } #elif defined(XP_UNIX) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, int(initialRUsage.ru_majflt)); struct rusage newRUsage; if (!getrusage(RUSAGE_SELF, &newRUsage)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); } #endif } int result; { ScopedLogging log; result = do_main(argc, argv); } XPCOMGlueShutdown(); return result; }
static void avx512f_test (void) { do_main (); }
int main(int argc, _CONST char* argv[]) { #ifndef MOZ_B2G_LOADER char exePath[MAXPATHLEN]; #endif #ifdef MOZ_WIDGET_GONK // This creates a ThreadPool for binder ipc. A ThreadPool is necessary to // receive binder calls, though not necessary to send binder calls. // ProcessState::Self() also needs to be called once on the main thread to // register the main thread with the binder driver. android::ProcessState::self()->startThreadPool(); #endif nsresult rv; #ifndef MOZ_B2G_LOADER rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || ((lastSlash - exePath) + sizeof(XPCOM_DLL) + 1 > MAXPATHLEN)) return 255; strcpy(++lastSlash, XPCOM_DLL); #endif // MOZ_B2G_LOADER #if defined(XP_UNIX) // If the b2g app is launched from adb shell, then the shell will wind // up being the process group controller. This means that we can't send // signals to the process group (useful for profiling). // We ignore the return value since setsid() fails if we're already the // process group controller (the normal situation). (void)setsid(); #endif int gotCounters; #if defined(XP_UNIX) struct rusage initialRUsage; gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); #elif defined(XP_WIN) IO_COUNTERS ioCounters; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); #else #error "Unknown platform" // having this here keeps cppcheck happy #endif #ifdef HAS_DLL_BLOCKLIST DllBlocklist_Initialize(); #endif // B2G loader has already initialized Gecko so we can't initialize // it again here. #ifndef MOZ_B2G_LOADER // We do this because of data in bug 771745 XPCOMGlueEnablePreload(); rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; #endif // MOZ_B2G_LOADER rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } if (gotCounters) { #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, int(ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, int(ioCounters.ReadTransferCount / 1024)); IO_COUNTERS newIoCounters; if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); } #elif defined(XP_UNIX) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, int(initialRUsage.ru_majflt)); struct rusage newRUsage; if (!getrusage(RUSAGE_SELF, &newRUsage)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); } #else #error "Unknown platform" // having this here keeps cppcheck happy #endif } int result; { ScopedLogging log; char **_argv; /* * Duplicate argument vector to conform non-const argv of * do_main() since XRE_main() is very stupid with non-const argv. */ _argv = new char *[argc + 1]; for (int i = 0; i < argc; i++) { size_t len = strlen(argv[i]) + 1; _argv[i] = new char[len]; MOZ_ASSERT(_argv[i] != nullptr); memcpy(_argv[i], argv[i], len); } _argv[argc] = nullptr; result = do_main(argc, _argv); for (int i = 0; i < argc; i++) { delete[] _argv[i]; } delete[] _argv; } return result; }
int main(int argc, char* argv[]) { char exePath[MAXPATHLEN]; #ifdef MOZ_WIDGET_GONK // The first call of ProcessState::self() (per process) will register into // binder driver by current thread info, so the main thread is a best one to // do registration because it never leaves. android::sp<android::ProcessState> proc(android::ProcessState::self()); #endif nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || ((lastSlash - exePath) + sizeof(XPCOM_DLL) + 1 > MAXPATHLEN)) return 255; strcpy(++lastSlash, XPCOM_DLL); #if defined(XP_UNIX) // If the b2g app is launched from adb shell, then the shell will wind // up being the process group controller. This means that we can't send // signals to the process group (useful for profiling). // We ignore the return value since setsid() fails if we're already the // process group controller (the normal situation). (void)setsid(); #endif int gotCounters; #if defined(XP_UNIX) struct rusage initialRUsage; gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); #elif defined(XP_WIN) IO_COUNTERS ioCounters; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); #endif // We do this because of data in bug 771745 XPCOMGlueEnablePreload(); rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklist(); #endif if (gotCounters) { #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, int(ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, int(ioCounters.ReadTransferCount / 1024)); IO_COUNTERS newIoCounters; if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); } #elif defined(XP_UNIX) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, int(initialRUsage.ru_majflt)); struct rusage newRUsage; if (!getrusage(RUSAGE_SELF, &newRUsage)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); } #endif } int result; { ScopedLogging log; result = do_main(argc, argv); } XPCOMGlueShutdown(); return result; }
int main(int argc, char ** argv) { GumholdCompressor c; return do_main(c, argc, argv); }
int main(int argc, char* argv[]) { PRTime start = _PR_Now(); char exePath[MAXPATHLEN]; #ifdef XP_MACOSX TriggerQuirks(); #endif nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || (size_t(lastSlash - exePath) > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) return 255; strcpy(++lastSlash, XPCOM_DLL); int gotCounters; #if defined(XP_UNIX) struct rusage initialRUsage; gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); #elif defined(XP_WIN) // Don't change the order of these enumeration constants, the order matters // for reporting telemetry data. If new values are added adjust the // STARTUP_USING_PRELOAD_TRIAL histogram. enum PreloadType{ PREFETCH_PRELOAD, PREFETCH_NO_PRELOAD, NO_PREFETCH_PRELOAD, NO_PREFETCH_NO_PRELOAD }; PreloadType preloadType; IO_COUNTERS ioCounters; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); srand(time(NULL)); bool shouldUsePreload = rand() % 2 == 0; if (IsPrefetchDisabledViaService()) { if (shouldUsePreload) { preloadType = NO_PREFETCH_PRELOAD; } else { preloadType = NO_PREFETCH_NO_PRELOAD; } } else { if (shouldUsePreload) { preloadType = PREFETCH_PRELOAD; } else { preloadType = PREFETCH_NO_PRELOAD; } } if (shouldUsePreload) #endif { XPCOMGlueEnablePreload(); } rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } XRE_StartupTimelineRecord(mozilla::StartupTimeline::START, start); #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklist(); #endif #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::STARTUP_USING_PRELOAD_TRIAL, preloadType); #endif if (gotCounters) { #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, int(ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, int(ioCounters.ReadTransferCount / 1024)); IO_COUNTERS newIoCounters; if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); } #elif defined(XP_UNIX) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, int(initialRUsage.ru_majflt)); struct rusage newRUsage; if (!getrusage(RUSAGE_SELF, &newRUsage)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); } #endif } int result; { ScopedLogging log; result = do_main(argc, argv); } XPCOMGlueShutdown(); return result; }
static void avx2_test (void) { do_main (); }
int lua_dobuffer (char *buff, int size, char *name) { ZIO z; if (!name) name = "?"; luaZ_mopen(&z, buff, size, name); return do_main(&z, buff[0]==ID_CHUNK); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { return do_main (argc, argv, 0); }
int main(int argc, char* argv[]) { char exePath[MAXPATHLEN]; #ifdef MOZ_WIDGET_GONK // This creates a ThreadPool for binder ipc. A ThreadPool is necessary to // receive binder calls, though not necessary to send binder calls. // ProcessState::Self() also needs to be called once on the main thread to // register the main thread with the binder driver. android::ProcessState::self()->startThreadPool(); #endif nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || ((lastSlash - exePath) + sizeof(XPCOM_DLL) + 1 > MAXPATHLEN)) return 255; strcpy(++lastSlash, XPCOM_DLL); #if defined(XP_UNIX) // If the b2g app is launched from adb shell, then the shell will wind // up being the process group controller. This means that we can't send // signals to the process group (useful for profiling). // We ignore the return value since setsid() fails if we're already the // process group controller (the normal situation). (void)setsid(); #endif int gotCounters; #if defined(XP_UNIX) struct rusage initialRUsage; gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); #elif defined(XP_WIN) IO_COUNTERS ioCounters; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); #endif // We do this because of data in bug 771745 XPCOMGlueEnablePreload(); rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklist(); #endif int result; { ScopedLogging log; result = do_main(argc, argv); } return result; }
int main(int argc, char *argv[]) { const int fd = do_init(argc, argv); do_main(fd); return 0; }
int main(int argc, char* argv[]) { char exePath[MAXPATHLEN]; nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || (lastSlash - exePath > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) return 255; strcpy(++lastSlash, XPCOM_DLL); int gotCounters; #if defined(XP_UNIX) struct rusage initialRUsage; gotCounters = !getrusage(RUSAGE_SELF, &initialRUsage); #elif defined(XP_WIN) // GetProcessIoCounters().ReadOperationCount seems to have little to // do with actual read operations. It reports 0 or 1 at this stage // in the program. Luckily 1 coincides with when prefetch is // enabled. If Windows prefetch didn't happen we can do our own // faster dll preloading. IO_COUNTERS ioCounters; gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters); if (gotCounters && !ioCounters.ReadOperationCount) #endif { XPCOMGlueEnablePreload(); } rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } #ifdef XRE_HAS_DLL_BLOCKLIST XRE_SetupDllBlocklist(); #endif if (gotCounters) { #if defined(XP_WIN) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_OPS, int(ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_READ_TRANSFER, int(ioCounters.ReadTransferCount / 1024)); IO_COUNTERS newIoCounters; if (GetProcessIoCounters(GetCurrentProcess(), &newIoCounters)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_OPS, int(newIoCounters.ReadOperationCount - ioCounters.ReadOperationCount)); XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_READ_TRANSFER, int((newIoCounters.ReadTransferCount - ioCounters.ReadTransferCount) / 1024)); } #elif defined(XP_UNIX) XRE_TelemetryAccumulate(mozilla::Telemetry::EARLY_GLUESTARTUP_HARD_FAULTS, int(initialRUsage.ru_majflt)); struct rusage newRUsage; if (!getrusage(RUSAGE_SELF, &newRUsage)) { XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS, int(newRUsage.ru_majflt - initialRUsage.ru_majflt)); } #endif } int result; { ScopedLogging log; result = do_main(argc, argv); } XPCOMGlueShutdown(); return result; }
int main(int argc, char* argv[]) { char exePath[MAXPATHLEN]; #ifdef MOZ_WIDGET_GONK // This creates a ThreadPool for binder ipc. A ThreadPool is necessary to // receive binder calls, though not necessary to send binder calls. // ProcessState::Self() also needs to be called once on the main thread to // register the main thread with the binder driver. android::ProcessState::self()->startThreadPool(); #endif nsresult rv; rv = mozilla::BinaryPath::Get(argv[0], exePath); if (NS_FAILED(rv)) { Output("Couldn't calculate the application directory.\n"); return 255; } char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); if (!lastSlash || ((lastSlash - exePath) + sizeof(XPCOM_DLL) + 1 > MAXPATHLEN)) return 255; strcpy(++lastSlash, XPCOM_DLL); #if defined(XP_UNIX) // If the b2g app is launched from adb shell, then the shell will wind // up being the process group controller. This means that we can't send // signals to the process group (useful for profiling). // We ignore the return value since setsid() fails if we're already the // process group controller (the normal situation). (void)setsid(); #endif #ifdef HAS_DLL_BLOCKLIST DllBlocklist_Initialize(); #endif // We do this because of data in bug 771745 XPCOMGlueEnablePreload(); rv = XPCOMGlueStartup(exePath); if (NS_FAILED(rv)) { Output("Couldn't load XPCOM.\n"); return 255; } // Reset exePath so that it is the directory name and not the xpcom dll name *lastSlash = 0; rv = XPCOMGlueLoadXULFunctions(kXULFuncs); if (NS_FAILED(rv)) { Output("Couldn't load XRE functions.\n"); return 255; } int result; { ScopedLogging log; char **_argv; /* * Duplicate argument vector to conform non-const argv of * do_main() since XRE_main() is very stupid with non-const argv. */ _argv = new char *[argc + 1]; for (int i = 0; i < argc; i++) { size_t len = strlen(argv[i]) + 1; _argv[i] = new char[len]; MOZ_ASSERT(_argv[i] != nullptr); memcpy(_argv[i], argv[i], len); } _argv[argc] = nullptr; result = do_main(argc, _argv); for (int i = 0; i < argc; i++) { delete[] _argv[i]; } delete[] _argv; } return result; }