Rizin
unix-like reverse engineering framework and cli tools
mytime.h File Reference

Time handling functions. More...

Go to the source code of this file.

Functions

void mytime_set_start_time (void)
 Store the time when (de)compression was started. More...
 
uint64_t mytime_get_elapsed (void)
 Get the number of milliseconds since the operation started. More...
 
void mytime_set_flush_time (void)
 Store the time of when compressor was flushed. More...
 
int mytime_get_flush_timeout (void)
 Get the number of milliseconds until the next flush. More...
 

Variables

uint64_t opt_flush_timeout
 Number of milliseconds to between LZMA_SYNC_FLUSHes. More...
 

Detailed Description

Time handling functions.

Definition in file mytime.h.

Function Documentation

◆ mytime_get_elapsed()

uint64_t mytime_get_elapsed ( void  )

Get the number of milliseconds since the operation started.

Definition at line 59 of file mytime.c.

60 {
61  return mytime_now() - start_time;
62 }
static uint64_t start_time
Definition: mytime.c:21
static uint64_t mytime_now(void)
Get the current time as milliseconds.
Definition: mytime.c:29

References mytime_now(), and start_time.

Referenced by message_progress_update(), and progress_flush().

◆ mytime_get_flush_timeout()

int mytime_get_flush_timeout ( void  )

Get the number of milliseconds until the next flush.

This returns -1 if no timed flushing is used.

The return value is intended for use with poll().

Definition at line 74 of file mytime.c.

75 {
77  return -1;
78 
79  const uint64_t now = mytime_now();
80  if (now >= next_flush)
81  return 0;
82 
83  const uint64_t remaining = next_flush - now;
84  return remaining > INT_MAX ? INT_MAX : (int)remaining;
85 }
enum operation_mode opt_mode
Definition: coder.c:24
@ MODE_COMPRESS
Definition: coder.h:14
#define INT_MAX
Definition: cp-demangle.c:131
uint64_t opt_flush_timeout
Number of milliseconds to between LZMA_SYNC_FLUSHes.
Definition: mytime.c:19
static uint64_t next_flush
Definition: mytime.c:22
static int
Definition: sfsocketcall.h:114
unsigned long uint64_t
Definition: sftypes.h:28

References int, INT_MAX, MODE_COMPRESS, mytime_now(), next_flush, opt_flush_timeout, and opt_mode.

Referenced by io_read().

◆ mytime_set_flush_time()

void mytime_set_flush_time ( void  )

Store the time of when compressor was flushed.

Definition at line 66 of file mytime.c.

67 {
69  return;
70 }

References mytime_now(), next_flush, and opt_flush_timeout.

Referenced by io_read().

◆ mytime_set_start_time()

void mytime_set_start_time ( void  )

Store the time when (de)compression was started.

The start time is also stored as the time of the first flush.

Definition at line 51 of file mytime.c.

52 {
54  return;
55 }

References mytime_now(), and start_time.

Referenced by coder_run().

Variable Documentation

◆ opt_flush_timeout

uint64_t opt_flush_timeout
extern

Number of milliseconds to between LZMA_SYNC_FLUSHes.

If 0, timed flushing is disabled. Otherwise if no more input is available and not at the end of the file and at least opt_flush_timeout milliseconds has elapsed since the start of compression or the previous flushing (LZMA_SYNC_FLUSH or LZMA_FULL_FLUSH), set LZMA_SYNC_FLUSH to flush the pending data.

Definition at line 19 of file mytime.c.

Referenced by coder_init(), mytime_get_flush_timeout(), mytime_set_flush_time(), and parse_real().