summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/tests/priotest.c
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2020-01-02 21:01:38 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-01-02 21:01:38 +0100
commitf7d30133221896638f7bf4f66c504255c4b14f48 (patch)
tree5f3e07a049f388a3a309a615b8884318f6668a98 /nsprpub/pr/tests/priotest.c
parent26b297510a11758727438df4669357a2a2bc42ce (diff)
downloadUXP-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/priotest.c')
-rw-r--r--nsprpub/pr/tests/priotest.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/nsprpub/pr/tests/priotest.c b/nsprpub/pr/tests/priotest.c
index 577d55333..1e2249de6 100644
--- a/nsprpub/pr/tests/priotest.c
+++ b/nsprpub/pr/tests/priotest.c
@@ -34,8 +34,9 @@ static PRBool debug_mode = PR_FALSE;
static PRUint32 PerSecond(PRIntervalTime timein)
{
PRUint32 loop = 0;
- while (((PRIntervalTime)(PR_IntervalNow()) - timein) < oneSecond)
+ while (((PRIntervalTime)(PR_IntervalNow()) - timein) < oneSecond) {
loop += 1;
+ }
return loop;
} /* PerSecond */
@@ -66,9 +67,9 @@ static void PR_CALLBACK High(void *arg)
static void Help(void)
{
PR_fprintf(
- debug_out, "Usage: priotest [-d] [-c n]\n");
+ debug_out, "Usage: priotest [-d] [-c n]\n");
PR_fprintf(
- debug_out, "-c n\tduration of test in seconds (default: %d)\n", DEFAULT_DURATION);
+ debug_out, "-c n\tduration of test in seconds (default: %d)\n", DEFAULT_DURATION);
PR_fprintf(
debug_out, "-d\tturn on debugging output (default: FALSE)\n");
} /* Help */
@@ -84,7 +85,7 @@ static void RudimentaryTests(void)
PR_SetThreadPriority(PR_GetCurrentThread(), PR_PRIORITY_URGENT);
priority = PR_GetThreadPriority(PR_GetCurrentThread());
failed = ((PR_TRUE == failed) || (PR_PRIORITY_URGENT != priority))
- ? PR_TRUE : PR_FALSE;
+ ? PR_TRUE : PR_FALSE;
if (debug_mode && (PR_PRIORITY_URGENT != priority))
{
PR_fprintf(debug_out, "PR_[S/G]etThreadPriority() failed\n");
@@ -95,7 +96,7 @@ static void RudimentaryTests(void)
PR_GetCurrentThread(), (PRThreadPriority)(PR_PRIORITY_FIRST - 1));
priority = PR_GetThreadPriority(PR_GetCurrentThread());
failed = ((PR_TRUE == failed) || (PR_PRIORITY_FIRST != priority))
- ? PR_TRUE : PR_FALSE;
+ ? PR_TRUE : PR_FALSE;
if (debug_mode && (PR_PRIORITY_FIRST != priority))
{
PR_fprintf(debug_out, "PR_SetThreadPriority(-1) failed\n");
@@ -105,7 +106,7 @@ static void RudimentaryTests(void)
PR_GetCurrentThread(), (PRThreadPriority)(PR_PRIORITY_LAST + 1));
priority = PR_GetThreadPriority(PR_GetCurrentThread());
failed = ((PR_TRUE == failed) || (PR_PRIORITY_LAST != priority))
- ? PR_TRUE : PR_FALSE;
+ ? PR_TRUE : PR_FALSE;
if (debug_mode && (PR_PRIORITY_LAST != priority))
{
PR_fprintf(debug_out, "PR_SetThreadPriority(+1) failed\n");
@@ -128,32 +129,36 @@ int main(int argc, char **argv)
PLOptStatus os;
PRIntn duration = DEFAULT_DURATION;
PRUint32 totalCount, highCount = 0, lowCount = 0;
- PLOptState *opt = PL_CreateOptState(argc, argv, "hdc:");
+ PLOptState *opt = PL_CreateOptState(argc, argv, "hdc:");
debug_out = PR_STDOUT;
oneSecond = PR_SecondsToInterval(1);
- while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
+ while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
- if (PL_OPT_BAD == os) continue;
+ if (PL_OPT_BAD == os) {
+ continue;
+ }
switch (opt->option)
{
- case 'd': /* debug mode */
- debug_mode = PR_TRUE;
- break;
- case 'c': /* test duration */
- duration = atoi(opt->value);
- break;
- case 'h': /* help message */
- default:
- Help();
- return 2;
+ case 'd': /* debug mode */
+ debug_mode = PR_TRUE;
+ break;
+ case 'c': /* test duration */
+ duration = atoi(opt->value);
+ break;
+ case 'h': /* help message */
+ default:
+ Help();
+ return 2;
}
}
- PL_DestroyOptState(opt);
+ PL_DestroyOptState(opt);
PR_STDIO_INIT();
- if (duration == 0) duration = DEFAULT_DURATION;
+ if (duration == 0) {
+ duration = DEFAULT_DURATION;
+ }
RudimentaryTests();
@@ -167,9 +172,9 @@ int main(int argc, char **argv)
if (debug_mode)
{
PR_fprintf(debug_out,
- "The high priority thread should get approximately three\n");
+ "The high priority thread should get approximately three\n");
PR_fprintf( debug_out,
- "times what the low priority thread manages. A maximum of \n");
+ "times what the low priority thread manages. A maximum of \n");
PR_fprintf( debug_out, "%d cycles are available.\n\n", totalCount);
}
@@ -178,16 +183,19 @@ int main(int argc, char **argv)
while (duration--)
{
PRIntn loop = 5;
- while (loop--) PR_Sleep(oneSecond);
- if (debug_mode)
+ while (loop--) {
+ PR_Sleep(oneSecond);
+ }
+ if (debug_mode) {
PR_fprintf(debug_out, "high : low :: %d : %d\n", highCount, lowCount);
+ }
}
PR_ProcessExit((failed) ? 1 : 0);
- PR_NOT_REACHED("You can't get here -- but you did!");
- return 1; /* or here */
+ PR_NOT_REACHED("You can't get here -- but you did!");
+ return 1; /* or here */
} /* main */