20 main (
int argc,
char *argv[])
51 format_my_node_frame (
u8 * s, va_list * va)
57 s =
format (s,
"scalar %d, vector { ", g->scalar);
59 s =
format (s,
"%d, ", g->vector[i]);
80 f, format_my_node_frame, f);
92 for (i = 0; i < 5; i++)
98 y->vector[
i] = y->scalar +
i;
115 .scalar_size =
sizeof (my_frame_t),
128 .scalar_size =
sizeof (my_frame_t),
141 } my_process_completion_type_t;
147 } my_process_event_data_t;
150 format_my_process_event_data (
u8 * s, va_list * va)
152 my_process_event_data_t *d = va_arg (*va, my_process_event_data_t *);
153 return format (s,
"{ a %d b %.6f}", d->a, d->b);
166 for (i = 0; i < 5; i++)
176 uword n_events_seen, type, *data = 0;
178 for (n_events_seen = 0; n_events_seen < 2;)
182 n_events_seen +=
vec_len (data);
193 uword n_events_seen,
i, type;
194 my_process_event_data_t *data;
195 for (n_events_seen = 0; n_events_seen < 2;)
204 format_my_process_event_data, data);
206 n_events_seen +=
vec_len (data);
231 i == 1 ? MY_EVENT_TYPE1 : MY_EVENT_TYPE2,
235 my_process_event_data_t *d;
257 .function = my_proc_input,
259 .name =
"my-proc-input",
266 u32 prec = va_arg (*args,
u32);
267 f64 *result = va_arg (*args,
f64 *);
272 "+%U",
"-%U",
"/%U",
"*%U",
"^%U",
279 for (p = prec; p <
ARRAY_LEN (binops); p++)
281 if (
unformat (
i, binops[p], _unformat_farith, prec + 0, &tmp[1]))
283 switch (binops[p][0])
286 result[0] = tmp[0] + tmp[1];
289 result[0] = tmp[0] - tmp[1];
292 result[0] = tmp[0] / tmp[1];
295 result[0] = tmp[0] * tmp[1];
298 result[0] = pow (tmp[0], tmp[1]);
310 else if (
unformat (
i,
"-%U", _unformat_farith, prec + 0, &tmp[0]))
316 else if (
unformat (
i,
"(%U)", _unformat_farith, 0, &tmp[0]))
333 f64 *result = va_arg (*args,
f64 *);
341 u32 *data = va_arg (*args,
u32 *);
347 .name =
"decimal_integer",.short_help =
353 .name =
"float_expression",.short_help =
354 "floating point expression",.unformat_function =
355 unformat_farith,.data_size =
sizeof (
f64),};
391 .path =
"bar %decimal_integer",
392 .short_help =
"bar1 command",
393 .function = bar_command,
397 .path =
"bar %decimal_integer %decimal_integer",
398 .short_help =
"bar2 command",
399 .function = bar_command,
403 .path =
"zap %float_expression",
404 .short_help =
"bar3 command",
405 .function = bar_command,
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
#define VLIB_CLI_PARSE_RULE(x)
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
static void * vlib_cli_get_parse_rule_result(vlib_main_t *vm, uword index)
static f64 vlib_time_now(vlib_main_t *vm)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
add_epi add_epi sub_epi sub_epi adds_epu subs_epu i16x8 y
int main(int argc, char *argv[])
static clib_error_t * unix_cli_init(vlib_main_t *vm)
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
#define VLIB_INIT_FUNCTION(x)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
#define vlib_call_init_function(vm, x)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
u32 node_index
Node index.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static void * vlib_process_signal_event_at_time(vlib_main_t *vm, f64 dt, uword node_index, uword type_opaque, uword n_data_elts, uword n_data_elt_bytes)
#define vec_free(V)
Free vector's memory (no header).
#define VLIB_CLI_COMMAND(x,...)
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
static void * vlib_process_get_event_data(vlib_main_t *vm, uword *return_event_type_opaque)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * unix_physmem_init(vlib_main_t *vm, int physical_memory_required)
#define VLIB_REGISTER_NODE(x,...)
static void vlib_process_put_event_data(vlib_main_t *vm, void *event_data)
#define STRUCT_SIZE_OF(t, f)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static clib_error_t * main_stub_init(vlib_main_t *vm)
int vlib_unix_main(int argc, char *argv[])