iPXE
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...

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 FILE_SECBOOT (PERMITTED)
static int time_exec (int argc, char **argv)
 "time" command
 COMMAND (time, time_exec)
 "time" command

Variables

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

Detailed Description

Time commands.

Definition in file time_cmd.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ time_exec()

int time_exec ( int argc,
char ** argv )
static

"time" command

Parameters
argcArgument count
argvArgument list
Return values
rcReturn status code

Definition at line 58 of file time_cmd.c.

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

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

Referenced by COMMAND().

◆ COMMAND()

COMMAND ( time ,
time_exec  )

"time" command

References time_exec().

Variable Documentation

◆ time_opts

struct option_descriptor time_opts[] = {}
static

"time" option list

Definition at line 44 of file time_cmd.c.

44{};

◆ time_cmd

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

"time" command descriptor

Definition at line 47 of file time_cmd.c.

Referenced by PROVIDE_REQUIRING_SYMBOL(), and time_exec().