Data Structures | Functions | Variables
time_cmd.c File Reference

Time commands. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/timer.h>

Go to the source code of this file.

Data Structures

struct  time_options
 "time" options More...


static int time_exec (int argc, char **argv)
 "time" command More...


static struct option_descriptor time_opts [] = {}
 "time" option list More...
static struct command_descriptor time_cmd
 "time" command descriptor More...
struct command time_command __command
 "time" command More...

Detailed Description

Time commands.

Definition in file time_cmd.c.

Function Documentation



◆ time_exec()

static int time_exec ( int  argc,
char **  argv 

"time" command

argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 57 of file time_cmd.c.

57  {
58  struct time_options opts;
59  unsigned long start;
60  unsigned long elapsed;
61  int decisecs;
62  int rc;
64  /* Parse options */
65  if ( ( rc = parse_options ( argc, argv, &time_cmd, &opts ) ) != 0 )
66  return rc;
68  start = currticks();
69  rc = execv ( argv[1], argv + 1 );
70  elapsed = ( currticks() - start );
71  decisecs = ( 10 * elapsed / TICKS_PER_SEC );
73  printf ( "%s: %d.%ds\n", argv[0],
74  ( decisecs / 10 ), ( decisecs % 10 ) );
76  return rc;
77 }
static struct command_descriptor time_cmd
"time" command descriptor
Definition: time_cmd.c:46
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Number of ticks per second.
Definition: timer.h:15
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
"time" options
Definition: time_cmd.c:40
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:447
uint32_t start
Starting offset.
Definition: netvsc.h:12
static union @423 opts
"cert<xxx>" option list
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
int execv(const char *command, char *const argv[])
Execute command.
Definition: exec.c:60

References currticks(), execv(), opts, parse_options(), printf(), rc, start, TICKS_PER_SEC, and time_cmd.

Variable Documentation

◆ time_opts

struct option_descriptor time_opts[] = {}

"time" option list

Definition at line 43 of file time_cmd.c.

◆ time_cmd

struct command_descriptor time_cmd
Initial value:
"<command>" )
"time" options
Definition: time_cmd.c:40
static struct option_descriptor time_opts[]
"time" option list
Definition: time_cmd.c:43
No maximum number of arguments.
Definition: parseopt.h:96
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:107

"time" command descriptor

Definition at line 46 of file time_cmd.c.

Referenced by time_exec().

◆ __command

struct command time_command __command
Initial value:
= {
.name = "time",
.exec = time_exec,
static int time_exec(int argc, char **argv)
"time" command
Definition: time_cmd.c:57

"time" command

Definition at line 80 of file time_cmd.c.