Changeset 1ab8539 in mainline for uspace/app


Ignore:
Timestamp:
2014-11-14T19:16:23Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5042706
Parents:
9696b01
Message:

remove system.uptime sysinfo entry since it is redundant
cleanup the time handling routines

  • still more cleanup is needed here, the code is a wild combination of quasi-POSIX API (with all the brain-dead types, etc.) and HelenOS API
Location:
uspace/app
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bnchmark/bnchmark.c

    r9696b01 r1ab8539  
    6262{
    6363        struct timeval start_time;
    64         int rc;
    65         rc = gettimeofday(&start_time, NULL);
    66         if (rc != EOK) {
    67                 fprintf(stderr, "gettimeofday failed\n");
    68                 return rc;
    69         }
    70        
    71         rc = fn(data);
     64        gettimeofday(&start_time, NULL);
     65       
     66        int rc = fn(data);
    7267        if (rc != EOK) {
    7368                fprintf(stderr, "measured function failed\n");
    7469                return rc;
    7570        }
    76 
     71       
    7772        struct timeval final_time;
    78         rc = gettimeofday(&final_time, NULL);
    79         if (rc != EOK) {
    80                 fprintf(stderr, "gettimeofday failed\n");
    81                 return rc;
    82         }
     73        gettimeofday(&final_time, NULL);
    8374       
    8475        /* Calculate time difference in milliseconds */
     
    9283        char *path = (char *) data;
    9384        char *buf = malloc(BUFSIZE);
    94 
    95         if (buf == NULL) {
     85       
     86        if (buf == NULL)
    9687                return ENOMEM;
    97         }
    9888       
    9989        FILE *file = fopen(path, "r");
  • uspace/app/nettest1/nettest1.c

    r9696b01 r1ab8539  
    402402       
    403403        struct timeval time_before;
    404         rc = gettimeofday(&time_before, NULL);
    405         if (rc != EOK) {
    406                 fprintf(stderr, "Get time of day error %d\n", rc);
    407                 return rc;
    408         }
     404        gettimeofday(&time_before, NULL);
    409405       
    410406        nettest1_test(socket_ids,       1,        1);
     
    414410       
    415411        struct timeval time_after;
    416         rc = gettimeofday(&time_after, NULL);
    417         if (rc != EOK) {
    418                 fprintf(stderr, "Get time of day error %d\n", rc);
    419                 return rc;
    420         }
     412        gettimeofday(&time_after, NULL);
    421413       
    422414        printf("Tested in %ld microseconds\n", tv_sub(&time_after,
  • uspace/app/nettest2/nettest2.c

    r9696b01 r1ab8539  
    356356       
    357357        struct timeval time_before;
    358         rc = gettimeofday(&time_before, NULL);
    359         if (rc != EOK) {
    360                 fprintf(stderr, "Get time of day error %d\n", rc);
    361                 return rc;
    362         }
     358        gettimeofday(&time_before, NULL);
    363359       
    364360        rc = sockets_sendto_recvfrom(verbose, socket_ids, sockets, address,
     
    368364       
    369365        struct timeval time_after;
    370         rc = gettimeofday(&time_after, NULL);
    371         if (rc != EOK) {
    372                 fprintf(stderr, "Get time of day error %d\n", rc);
    373                 return rc;
    374         }
     366        gettimeofday(&time_after, NULL);
    375367       
    376368        if (verbose)
     
    380372            tv_sub(&time_after, &time_before));
    381373       
    382         rc = gettimeofday(&time_before, NULL);
    383         if (rc != EOK) {
    384                 fprintf(stderr, "Get time of day error %d\n", rc);
    385                 return rc;
    386         }
     374        gettimeofday(&time_before, NULL);
    387375       
    388376        rc = sockets_sendto(verbose, socket_ids, sockets, address, addrlen,
     
    396384                return rc;
    397385       
    398         rc = gettimeofday(&time_after, NULL);
    399         if (rc != EOK) {
    400                 fprintf(stderr, "Get time of day error %d\n", rc);
    401                 return rc;
    402         }
     386        gettimeofday(&time_after, NULL);
    403387       
    404388        if (verbose)
  • uspace/app/stats/stats.c

    r9696b01 r1ab8539  
    191191static void print_uptime(void)
    192192{
    193         sysarg_t uptime = stats_get_uptime();
    194         printf("%s: Up %" PRIun " days, %" PRIun " hours, "
    195             "%" PRIun " minutes, %" PRIun " seconds\n", NAME,
    196             uptime / DAY, (uptime % DAY) / HOUR,
    197             (uptime % HOUR) / MINUTE, uptime % MINUTE);
     193        struct timeval uptime;
     194        getuptime(&uptime);
     195       
     196        printf("%s: Up %ld days, %ld hours, %ld minutes, %ld seconds\n",
     197            NAME, uptime.tv_sec / DAY, (uptime.tv_sec % DAY) / HOUR,
     198            (uptime.tv_sec % HOUR) / MINUTE, uptime.tv_sec % MINUTE);
    198199}
    199200
  • uspace/app/tester/ipc/ping_pong.c

    r9696b01 r1ab8539  
    4343       
    4444        struct timeval start;
    45         if (gettimeofday(&start, NULL) != 0) {
    46                 TPRINTF("\n");
    47                 return "Failed getting the time";
    48         }
     45        gettimeofday(&start, NULL);
    4946       
    5047        uint64_t count = 0;
    5148        while (true) {
    5249                struct timeval now;
    53                 if (gettimeofday(&now, NULL) != 0) {
    54                         TPRINTF("\n");
    55                         return "Failed getting the time";
    56                 }
     50                gettimeofday(&now, NULL);
    5751               
    5852                if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L)
  • uspace/app/tester/ipc/starve.c

    r9696b01 r1ab8539  
    4040        const char *err = NULL;
    4141        console_ctrl_t *console = console_init(stdin, stdout);
    42         if (console == NULL) {
     42        if (console == NULL)
    4343                return "Failed to init connection with console.";
    44         }
    4544       
    4645        struct timeval start;
    47         if (gettimeofday(&start, NULL) != 0) {
    48                 err = "Failed getting the time";
    49                 goto leave;
    50         }
     46        gettimeofday(&start, NULL);
    5147       
    5248        TPRINTF("Intensive computation shall be imagined (for %ds)...\n", DURATION_SECS);
     
    5450        while (true) {
    5551                struct timeval now;
    56                 if (gettimeofday(&now, NULL) != 0) {
    57                         err = "Failed getting the time";
    58                         goto leave;
    59                 }
     52                gettimeofday(&now, NULL);
    6053               
    6154                if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L)
     
    7063                }
    7164        }
    72 
     65       
    7366        // FIXME - unless a key was pressed, the answer leaked as no one
    7467        // will wait for it.
    7568        // We cannot use async_forget() directly, though. Something like
    7669        // console_forget_pending_kbd_event() shall come here.
    77 
     70       
    7871        TPRINTF("Terminating...\n");
    79 
    80 leave:
     72       
    8173        console_done(console);
    82 
     74       
    8375        return err;
    8476}
  • uspace/app/testread/testread.c

    r9696b01 r1ab8539  
    123123        struct timeval prev_time;
    124124        struct timeval start_time;
    125         int rc;
    126         rc = gettimeofday(&start_time, NULL);
    127         if (rc != EOK) {
    128                 printf("gettimeofday failed\n");
    129                 fclose(file);
    130                 free(buf);
    131                 return 1;
    132         }
     125        gettimeofday(&start_time, NULL);
    133126        prev_time = start_time;
    134127       
     
    155148                if (progress && offset >= next_mark) {
    156149                        struct timeval cur_time;
    157                         rc = gettimeofday(&cur_time, NULL);
    158                         if (rc != EOK) {
    159                                 printf("gettimeofday failed\n");
    160                                 fclose(file);
    161                                 free(buf);
    162                                 return 1;
    163                         }
     150                        gettimeofday(&cur_time, NULL);
     151                       
    164152                        uint32_t last_run = cur_time.tv_sec - prev_time.tv_sec;
    165153                        uint32_t total_time = cur_time.tv_sec - start_time.tv_sec;
     
    178166       
    179167        struct timeval final_time;
    180         rc = gettimeofday(&final_time, NULL);
    181         if (rc != EOK) {
    182                 printf("gettimeofday failed\n");
    183                 fclose(file);
    184                 free(buf);
    185                 return 1;
    186         }
     168        gettimeofday(&final_time, NULL);
    187169       
    188170        uint32_t total_run_time = final_time.tv_sec - start_time.tv_sec;
  • uspace/app/top/top.c

    r9696b01 r1ab8539  
    156156        /* Get current time */
    157157        struct timeval time;
    158         if (gettimeofday(&time, NULL) != EOK)
    159                 return "Cannot get time of day";
     158        gettimeofday(&time, NULL);
    160159       
    161160        target->hours = (time.tv_sec % DAY) / HOUR;
     
    164163       
    165164        /* Get uptime */
    166         sysarg_t uptime = stats_get_uptime();
    167         target->udays = uptime / DAY;
    168         target->uhours = (uptime % DAY) / HOUR;
    169         target->uminutes = (uptime % HOUR) / MINUTE;
    170         target->useconds = uptime % MINUTE;
     165        struct timeval uptime;
     166        getuptime(&uptime);
     167       
     168        target->udays = uptime.tv_sec / DAY;
     169        target->uhours = (uptime.tv_sec % DAY) / HOUR;
     170        target->uminutes = (uptime.tv_sec % HOUR) / MINUTE;
     171        target->useconds = uptime.tv_sec % MINUTE;
    171172       
    172173        /* Get load */
Note: See TracChangeset for help on using the changeset viewer.