summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/tests/sleep.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/sleep.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/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) */