Rizin
unix-like reverse engineering framework and cli tools
main.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <unistd.h>
4
5
#include <
uv.h
>
6
7
#define FIB_UNTIL 25
8
uv_loop_t
*
loop
;
9
10
long
fib_
(
long
t) {
11
if
(t == 0 || t == 1)
12
return
1;
13
else
14
return
fib_
(t-1) +
fib_
(t-2);
15
}
16
17
void
fib
(
uv_work_t
*
req
) {
18
int
n
= *(
int
*)
req
->data;
19
if
(random() % 2)
20
sleep(1);
21
else
22
sleep(3);
23
long
fib
=
fib_
(
n
);
24
fprintf(stderr,
"%dth fibonacci is %lu\n"
,
n
,
fib
);
25
}
26
27
void
after_fib
(
uv_work_t
*
req
,
int
status
) {
28
fprintf(stderr,
"Done calculating %dth fibonacci\n"
, *(
int
*)
req
->data);
29
}
30
31
int
main
() {
32
loop
=
uv_default_loop
();
33
34
int
data[
FIB_UNTIL
];
35
uv_work_t
req
[
FIB_UNTIL
];
36
int
i
;
37
for
(
i
= 0;
i
<
FIB_UNTIL
;
i
++) {
38
data[
i
] =
i
;
39
req
[
i
].data = (
void
*) &data[
i
];
40
uv_queue_work
(
loop
, &
req
[
i
],
fib
,
after_fib
);
41
}
42
43
return
uv_run
(
loop
,
UV_RUN_DEFAULT
);
44
}
i
lzma_index ** i
Definition:
index.h:629
req
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
Definition:
sflib.h:128
main
int main(int argc, const char **argv)
Definition:
main.c:340
status
static const char struct stat static buf struct stat static buf static vhangup int status
Definition:
sflib.h:145
n
int n
Definition:
mipsasm.c:19
uv_loop_s
Definition:
uv.h:1780
uv_work_s
Definition:
uv.h:1066
loop
uv_loop_t * loop
Definition:
main.c:7
fib_
long fib_(long t)
Definition:
main.c:11
fib
void fib(uv_work_t *req)
Definition:
main.c:18
after_fib
void after_fib(uv_work_t *req, int status)
Definition:
main.c:28
FIB_UNTIL
#define FIB_UNTIL
Definition:
main.c:7
uv.h
UV_RUN_DEFAULT
@ UV_RUN_DEFAULT
Definition:
uv.h:255
uv_run
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition:
core.c:365
uv_queue_work
UV_EXTERN int uv_queue_work(uv_loop_t *loop, uv_work_t *req, uv_work_cb work_cb, uv_after_work_cb after_work_cb)
Definition:
threadpool.c:338
uv_default_loop
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition:
uv-common.c:763
if
if(dbg->bits==RZ_SYS_BITS_64)
Definition:
windows-arm64.h:4
subprojects
libuv-v1.40.0
docs
code
queue-work
main.c
Generated by
1.9.1