Rizin
unix-like reverse engineering framework and cli tools
main.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <uv.h>

Go to the source code of this file.

Macros

#define FIB_UNTIL   25
 

Functions

long fib_ (long t)
 
void fib (uv_work_t *req)
 
void after_fib (uv_work_t *req, int status)
 
int main ()
 

Variables

uv_loop_tloop
 

Macro Definition Documentation

◆ FIB_UNTIL

#define FIB_UNTIL   25

Definition at line 7 of file main.c.

Function Documentation

◆ after_fib()

void after_fib ( uv_work_t req,
int  status 
)

Definition at line 27 of file main.c.

27  {
28  fprintf(stderr, "Done calculating %dth fibonacci\n", *(int *) req->data);
29 }
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

References req.

◆ fib()

void fib ( uv_work_t req)

Definition at line 17 of file main.c.

17  {
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 }
int n
Definition: mipsasm.c:19
long fib_(long t)
Definition: main.c:11
void fib(uv_work_t *req)
Definition: main.c:18
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4

References fib(), fib_(), if(), n, and req.

◆ fib_()

long fib_ ( long  t)

Definition at line 10 of file main.c.

10  {
11  if (t == 0 || t == 1)
12  return 1;
13  else
14  return fib_(t-1) + fib_(t-2);
15 }

References fib_().

◆ main()

int main ( void  )

Definition at line 31 of file main.c.

31  {
33 
34  int data[FIB_UNTIL];
36  int i;
37  for (i = 0; i < FIB_UNTIL; i++) {
38  data[i] = i;
39  req[i].data = (void *) &data[i];
41  }
42 
43  return uv_run(loop, UV_RUN_DEFAULT);
44 }
lzma_index ** i
Definition: index.h:629
Definition: uv.h:1066
uv_loop_t * loop
Definition: main.c:7
void after_fib(uv_work_t *req, int status)
Definition: main.c:28
#define FIB_UNTIL
Definition: main.c:7
@ UV_RUN_DEFAULT
Definition: uv.h:255
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition: core.c:365
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_EXTERN uv_loop_t * uv_default_loop(void)
Definition: uv-common.c:763

References after_fib(), fib(), FIB_UNTIL, i, loop, req, uv_default_loop(), uv_queue_work(), uv_run(), and UV_RUN_DEFAULT.

Variable Documentation

◆ loop

uv_loop_t* loop

Definition at line 8 of file main.c.