forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsleep.c
More file actions
31 lines (26 loc) · 827 Bytes
/
sleep.c
File metadata and controls
31 lines (26 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* Copyright 2011 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
int main() {
time_t start;
time_t taken;
start = time(0);
printf("sleep(2) ret: %d\n", sleep(2));
taken = time(0) - start;
printf("after sleep(2) between 2 and 3: %d\n", taken >= 2 && taken <= 3);
printf("errno: %d\n", errno);
errno = 0;
start = time(0);
printf("usleep(3000000) ret: %d\n", usleep(3000000));
taken = time(0) - start;
printf("after usleep(3000000) between 3 and 4: %d\n", taken >= 3 && taken <= 4);
printf("errno: %d\n", errno);
return 0;
}