Rizin
unix-like reverse engineering framework and cli tools
ticker.h
Go to the documentation of this file.
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
3 
4 typedef struct ticker_s ticker_t;
5 
6 #endif /* JEMALLOC_H_TYPES */
7 /******************************************************************************/
8 #ifdef JEMALLOC_H_STRUCTS
9 
10 struct ticker_s {
11  int32_t tick;
12  int32_t nticks;
13 };
14 
15 #endif /* JEMALLOC_H_STRUCTS */
16 /******************************************************************************/
17 #ifdef JEMALLOC_H_EXTERNS
18 
19 #endif /* JEMALLOC_H_EXTERNS */
20 /******************************************************************************/
21 #ifdef JEMALLOC_H_INLINES
22 
23 #ifndef JEMALLOC_ENABLE_INLINE
24 void ticker_init(ticker_t *ticker, int32_t nticks);
25 void ticker_copy(ticker_t *ticker, const ticker_t *other);
26 int32_t ticker_read(const ticker_t *ticker);
27 bool ticker_ticks(ticker_t *ticker, int32_t nticks);
28 bool ticker_tick(ticker_t *ticker);
29 #endif
30 
31 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_TICKER_C_))
32 JEMALLOC_INLINE void
33 ticker_init(ticker_t *ticker, int32_t nticks)
34 {
35 
36  ticker->tick = nticks;
37  ticker->nticks = nticks;
38 }
39 
40 JEMALLOC_INLINE void
41 ticker_copy(ticker_t *ticker, const ticker_t *other)
42 {
43 
44  *ticker = *other;
45 }
46 
48 ticker_read(const ticker_t *ticker)
49 {
50 
51  return (ticker->tick);
52 }
53 
54 JEMALLOC_INLINE bool
55 ticker_ticks(ticker_t *ticker, int32_t nticks)
56 {
57 
58  if (unlikely(ticker->tick < nticks)) {
59  ticker->tick = ticker->nticks;
60  return (true);
61  }
62  ticker->tick -= nticks;
63  return(false);
64 }
65 
66 JEMALLOC_INLINE bool
67 ticker_tick(ticker_t *ticker)
68 {
69 
70  return (ticker_ticks(ticker, 1));
71 }
72 #endif
73 
74 #endif /* JEMALLOC_H_INLINES */
75 /******************************************************************************/
#define JEMALLOC_INLINE
#define unlikely(expr)
Definition: lz4.c:177
#define ticker_copy
#define ticker_read
#define ticker_init
#define ticker_ticks
#define ticker_tick
int int32_t
Definition: sftypes.h:33
uv_timer_t tick
Definition: main.c:8