The ovm_timeval_t type

The ovm_timeval_t type is the OrchIDS incarnation of the data type struct timeval of times and durations.

It is defined this way in src/lang.h:

typedef struct ovm_timeval_s ovm_timeval_t;
struct ovm_timeval_s
  gc_header_t gc;
  struct timeval time;

This is a type of garbage-collectable data. To allocate a new object of type ovm_timeval_t, use the function:

ovm_var_t *ovm_timeval_new(gc_t *gc_ctx);

This creates a new ovm_timeval_t object at the time of the epoch (tv_sec=tv_usec=0). Its return type is the universal type ovm_var_t instead of ovm_timeval_t, for practical reasons. Calling res the result, one always has TYPE(res)==T_TIMEVAL.

The result is created white, and much be gc_touch()ed before storing it into a garbage-collectable object.

The returned ovm_timeval_t object res is modifiable. One can read from or write from it by using the TIMEVAL() macro (e.g., long sec=TIMEVAL(res).tv_sec, usec=TIMEVAL(res).tv_usec; TIMEVAL(res).tv_sec = 352; TIMEVAL(res).tv_usec = 537260;).