forked from unikraft/app-helloworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
53 lines (45 loc) · 1.09 KB
/
main.c
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
/* Import user configuration: */
#ifdef __Unikraft__
#include <uk/config.h>
#endif /* __Unikraft__ */
#if CONFIG_APPHELLOWORLD_SPINNER
#include <time.h>
#include <errno.h>
#include "monkey.h"
static void millisleep(unsigned int millisec)
{
struct timespec ts;
int ret;
ts.tv_sec = millisec / 1000;
ts.tv_nsec = (millisec % 1000) * 1000000;
do
ret = nanosleep(&ts, &ts);
while (ret && errno == EINTR);
}
#endif /* CONFIG_APPHELLOWORLD_SPINNER */
int main(int argc, char *argv[])
{
#if CONFIG_APPHELLOWORLD_PRINTARGS || CONFIG_APPHELLOWORLD_SPINNER
int i;
#endif
printf("Hello world!\n");
#if CONFIG_APPHELLOWORLD_PRINTARGS
printf("Arguments: ");
for (i=0; i<argc; ++i)
printf(" \"%s\"", argv[i]);
printf("\n");
#endif /* CONFIG_APPHELLOWORLD_PRINTARGS */
#if CONFIG_APPHELLOWORLD_SPINNER
i = 0;
printf("\n\n\n");
for (;;) {
i %= (monkey3_frame_count * 3);
printf("\r\033[2A %s \n", monkey3[i++]);
printf(" %s \n", monkey3[i++]);
printf(" %s ", monkey3[i++]);
fflush(stdout);
millisleep(250);
}
#endif /* CONFIG_APPHELLOWORLD_SPINNER */
}