summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/tests/sleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/tests/sleep.c')
-rw-r--r--nsprpub/pr/tests/sleep.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/nsprpub/pr/tests/sleep.c b/nsprpub/pr/tests/sleep.c
index 43ef34cd8..3e00acab0 100644
--- a/nsprpub/pr/tests/sleep.c
+++ b/nsprpub/pr/tests/sleep.c
@@ -30,58 +30,66 @@ static void Other(void *unused)
fprintf(stderr, ".");
didit += 1;
}
- if (didit < 5) rv = 1;
+ if (didit < 5) {
+ rv = 1;
+ }
}
int main(int argc, char **argv)
{
PRUint32 elapsed;
PRThread *thread;
- struct timeval timein, timeout;
+ struct timeval timein, timeout;
PRInt32 onePercent = 3000000UL / 100UL;
- fprintf (stderr, "First sleep will sleep 3 seconds.\n");
- fprintf (stderr, " sleep 1 begin\n");
+ fprintf (stderr, "First sleep will sleep 3 seconds.\n");
+ fprintf (stderr, " sleep 1 begin\n");
(void)GTOD(&timein);
- sleep (3);
+ sleep (3);
(void)GTOD(&timeout);
- fprintf (stderr, " sleep 1 end\n");
+ fprintf (stderr, " sleep 1 end\n");
elapsed = 1000000UL * (timeout.tv_sec - timein.tv_sec);
elapsed += (timeout.tv_usec - timein.tv_usec);
fprintf(stderr, "elapsed %u usecs\n", elapsed);
- if (labs(elapsed - 3000000UL) > onePercent) rv = 1;
+ if (labs(elapsed - 3000000UL) > onePercent) {
+ rv = 1;
+ }
- PR_Init (PR_USER_THREAD, PR_PRIORITY_NORMAL, 100);
+ PR_Init (PR_USER_THREAD, PR_PRIORITY_NORMAL, 100);
PR_STDIO_INIT();
- fprintf (stderr, "Second sleep should do the same (does it?).\n");
- fprintf (stderr, " sleep 2 begin\n");
+ fprintf (stderr, "Second sleep should do the same (does it?).\n");
+ fprintf (stderr, " sleep 2 begin\n");
(void)GTOD(&timein);
- sleep (3);
+ sleep (3);
(void)GTOD(&timeout);
- fprintf (stderr, " sleep 2 end\n");
+ fprintf (stderr, " sleep 2 end\n");
elapsed = 1000000UL * (timeout.tv_sec - timein.tv_sec);
elapsed += (timeout.tv_usec - timein.tv_usec);
fprintf(stderr, "elapsed %u usecs\n", elapsed);
- if (labs(elapsed - 3000000UL) > onePercent) rv = 1;
+ if (labs(elapsed - 3000000UL) > onePercent) {
+ rv = 1;
+ }
- fprintf (stderr, "What happens to other threads?\n");
- fprintf (stderr, "You should see dots every quarter second.\n");
- fprintf (stderr, "If you don't, you're probably running on classic NSPR.\n");
+ fprintf (stderr, "What happens to other threads?\n");
+ fprintf (stderr, "You should see dots every quarter second.\n");
+ fprintf (stderr, "If you don't, you're probably running on classic NSPR.\n");
thread = PR_CreateThread(
- PR_USER_THREAD, Other, NULL, PR_PRIORITY_NORMAL,
- PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
- fprintf (stderr, " sleep 2 begin\n");
+ PR_USER_THREAD, Other, NULL, PR_PRIORITY_NORMAL,
+ PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
+ fprintf (stderr, " sleep 2 begin\n");
(void)GTOD(&timein);
- sleep (3);
+ sleep (3);
(void)GTOD(&timeout);
- fprintf (stderr, " sleep 2 end\n");
+ fprintf (stderr, " sleep 2 end\n");
PR_Interrupt(thread);
PR_JoinThread(thread);
elapsed = 1000000UL * (timeout.tv_sec - timein.tv_sec);
elapsed += (timeout.tv_usec - timein.tv_usec);
fprintf(stderr, "elapsed %u usecs\n", elapsed);
- if (labs(elapsed - 3000000UL) > onePercent) rv = 1;
+ if (labs(elapsed - 3000000UL) > onePercent) {
+ rv = 1;
+ }
fprintf(stderr, "%s\n", (0 == rv) ? "PASSED" : "FAILED");
return rv;
}
@@ -90,7 +98,7 @@ int main(int argc, char **argv)
PRIntn main()
{
- return 2;
+ return 2;
}
#endif /* defined(XP_UNIX) */