diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
commit | f7d30133221896638f7bf4f66c504255c4b14f48 (patch) | |
tree | 5f3e07a049f388a3a309a615b8884318f6668a98 /nsprpub/pr/tests/cleanup.c | |
parent | 26b297510a11758727438df4669357a2a2bc42ce (diff) | |
download | UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.gz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.lz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.xz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.zip |
Issue #1338 - Part 1: Update NSPR to 4.24
Diffstat (limited to 'nsprpub/pr/tests/cleanup.c')
-rw-r--r-- | nsprpub/pr/tests/cleanup.c | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/nsprpub/pr/tests/cleanup.c b/nsprpub/pr/tests/cleanup.c index 4079aae18..679fe59c9 100644 --- a/nsprpub/pr/tests/cleanup.c +++ b/nsprpub/pr/tests/cleanup.c @@ -36,7 +36,7 @@ int main(int argc, char **argv) { PLOptStatus os; PRBool cleanup = PR_FALSE; - PRThreadScope type = PR_LOCAL_THREAD; + PRThreadScope type = PR_LOCAL_THREAD; PRFileDesc *err = PR_GetSpecialFD(PR_StandardError); PLOptState *opt = PL_CreateOptState(argc, argv, "Ghs:S:t:cC:"); PRIntn concurrency = 1, child_sleep = 10, main_sleep = 5, threads = 1; @@ -44,55 +44,59 @@ int main(int argc, char **argv) PR_STDIO_INIT(); while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) { - if (PL_OPT_BAD == os) continue; + if (PL_OPT_BAD == os) { + continue; + } switch (opt->option) { - case 'c': /* call PR_Cleanup() before exiting */ - cleanup = PR_TRUE; - break; - case 'G': /* local vs global threads */ - type = PR_GLOBAL_THREAD; - break; - case 's': /* time to sleep */ - child_sleep = atoi(opt->value); - break; - case 'S': /* time to sleep */ - main_sleep = atoi(opt->value); - break; - case 'C': /* number of cpus to create */ - concurrency = atoi(opt->value); - break; - case 't': /* number of threads to create */ - threads = atoi(opt->value); - break; - case 'h': /* user wants some guidance */ - Help(); /* so give him an earful */ - return 2; /* but not a lot else */ - break; - default: - break; + case 'c': /* call PR_Cleanup() before exiting */ + cleanup = PR_TRUE; + break; + case 'G': /* local vs global threads */ + type = PR_GLOBAL_THREAD; + break; + case 's': /* time to sleep */ + child_sleep = atoi(opt->value); + break; + case 'S': /* time to sleep */ + main_sleep = atoi(opt->value); + break; + case 'C': /* number of cpus to create */ + concurrency = atoi(opt->value); + break; + case 't': /* number of threads to create */ + threads = atoi(opt->value); + break; + case 'h': /* user wants some guidance */ + Help(); /* so give him an earful */ + return 2; /* but not a lot else */ + break; + default: + break; } } PL_DestroyOptState(opt); PR_fprintf(err, "Cleanup settings\n"); PR_fprintf(err, "\tThread type: %s\n", - (PR_LOCAL_THREAD == type) ? "LOCAL" : "GLOBAL"); + (PR_LOCAL_THREAD == type) ? "LOCAL" : "GLOBAL"); PR_fprintf(err, "\tConcurrency: %d\n", concurrency); PR_fprintf(err, "\tNumber of threads: %d\n", threads); PR_fprintf(err, "\tThread sleep: %d\n", child_sleep); - PR_fprintf(err, "\tMain sleep: %d\n", main_sleep); - PR_fprintf(err, "\tCleanup will %sbe called\n\n", (cleanup) ? "" : "NOT "); + PR_fprintf(err, "\tMain sleep: %d\n", main_sleep); + PR_fprintf(err, "\tCleanup will %sbe called\n\n", (cleanup) ? "" : "NOT "); PR_SetConcurrency(concurrency); - while (threads-- > 0) - (void)PR_CreateThread( - PR_USER_THREAD, Thread, (void*)child_sleep, PR_PRIORITY_NORMAL, - type, PR_UNJOINABLE_THREAD, 0); + while (threads-- > 0) + (void)PR_CreateThread( + PR_USER_THREAD, Thread, (void*)child_sleep, PR_PRIORITY_NORMAL, + type, PR_UNJOINABLE_THREAD, 0); PR_Sleep(PR_SecondsToInterval(main_sleep)); - if (cleanup) PR_Cleanup(); + if (cleanup) { + PR_Cleanup(); + } PR_fprintf(err, "main() exiting\n"); return 0; |