VirtualBox

Changeset 2101 in kBuild for trunk/src/kmk/job.c


Ignore:
Timestamp:
Nov 24, 2008 11:35:56 PM (17 years ago)
Author:
bird
Message:

kmk: Implemented new switch --print-time. Fixes #65.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/job.c

    r2056 r2101  
    209209static int job_next_command (struct child *);
    210210static int start_waiting_job (struct child *);
     211#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     212static void print_job_time (struct child *);
     213#endif
    211214
    212215
     
    901904free_child (struct child *child)
    902905{
     906#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     907  print_job_time (child);
     908#endif
    903909  if (!jobserver_tokens)
    904910    fatal (NILF, "INTERNAL: Freeing child 0x%08lx (%s) but no tokens left!\n",
     
    10641070  if (!child->command_ptr)
    10651071    goto next_command;
     1072
     1073#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     1074  if (child->start_ts == -1)
     1075    child->start_ts = nano_timestamp ();
     1076#endif
    10661077
    10671078  /* Combine the flags parsed for the line itself with
     
    18211832  c->command_lines = lines;
    18221833  c->sh_batch_file = NULL;
     1834#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     1835  c->start_ts = -1;
     1836#endif
    18231837
    18241838  /* Cache dontcare flag because file->dontcare can be changed once we
     
    34223436#endif /* !HAPE_DUP2 && !_AMIGA */
    34233437
     3438#ifdef CONFIG_WITH_PRINT_TIME_SWITCH
     3439/* Prints the time elapsed while executing the commands for the given job. */
     3440void print_job_time (struct child *c)
     3441{
     3442  if (   !handling_fatal_signal
     3443      && print_time_min != -1
     3444      && c->start_ts != -1)
     3445    {
     3446      big_int elapsed = nano_timestamp () - c->start_ts;
     3447      if (elapsed >= print_time_min * BIG_INT_C(1000000000))
     3448        {
     3449          char buf[64];
     3450          int len = format_elapsed_nano (buf, sizeof (buf), elapsed);
     3451          if (len > print_time_width)
     3452            print_time_width = len;
     3453          message (1, _("%*s - %s"), print_time_width, buf, c ->file->name);
     3454        }
     3455    }
     3456}
     3457#endif
     3458
    34243459/* On VMS systems, include special VMS functions.  */
    34253460
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette