Changeset b412168 in mainline for uspace/app


Ignore:
Timestamp:
2014-11-17T03:25:04Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6069061
Parents:
ef3da5a (diff), 5042706 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge mainline changes

Location:
uspace/app
Files:
32 added
11 edited

Legend:

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

    ref3da5a rb412168  
    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/init/init.c

    ref3da5a rb412168  
    355355        int rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER);
    356356        if (rc == EOK) {
     357                gui_start("/app/barber", HID_COMPOSITOR_SERVER);
    357358                gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER);
    358359                gui_start("/app/vterm", HID_COMPOSITOR_SERVER);
  • uspace/app/modplay/modplay.c

    ref3da5a rb412168  
    4040#include <stdio.h>
    4141#include <stdlib.h>
    42 #include <protracker.h>
    4342#include <trackmod.h>
    4443
     
    8887        con = console_init(stdin, stdout);
    8988
    90         rc = trackmod_protracker_load(argv[1], &mod);
     89        rc = trackmod_module_load(argv[1], &mod);
    9190        if (rc != EOK) {
    9291                printf("Error loading %s.\n", argv[1]);
  • uspace/app/nettest1/nettest1.c

    ref3da5a rb412168  
    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

    ref3da5a rb412168  
    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

    ref3da5a rb412168  
    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

    ref3da5a rb412168  
    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

    ref3da5a rb412168  
    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

    ref3da5a rb412168  
    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

    ref3da5a rb412168  
    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 */
  • uspace/app/vlaunch/vlaunch.c

    ref3da5a rb412168  
    3737#include <stdio.h>
    3838#include <malloc.h>
    39 #include <io/pixel.h>
    4039#include <task.h>
    41 #include <str.h>
    4240#include <str_error.h>
    43 #include <loc.h>
    44 #include <fibril_synch.h>
    45 #include <io/pixel.h>
    46 #include <device/led_dev.h>
    4741
    4842#include <window.h>
     
    6458#define LOGO_HEIGHT  66
    6559
    66 #define PERIOD  1000000
    67 #define COLORS  7
    68 
    6960static char *winreg = NULL;
    70 static fibril_timer_t *timer = NULL;
    71 static list_t led_devs;
    72 
    73 static pixel_t colors[COLORS] = {
    74         PIXEL(0xff, 0xff, 0x00, 0x00),
    75         PIXEL(0xff, 0x00, 0xff, 0x00),
    76         PIXEL(0xff, 0x00, 0x00, 0xff),
    77         PIXEL(0xff, 0xff, 0xff, 0x00),
    78         PIXEL(0xff, 0xff, 0x00, 0xff),
    79         PIXEL(0xff, 0x00, 0xff, 0xff),
    80         PIXEL(0xff, 0xff, 0xff, 0xff)
    81 };
    82 
    83 static unsigned int color = 0;
    84 
    85 typedef struct {
    86         link_t link;
    87         service_id_t svc_id;
    88         async_sess_t *sess;
    89 } led_dev_t;
    9061
    9162static int app_launch(const char *app)
     
    129100}
    130101
    131 static void timer_callback(void *data)
    132 {
    133         pixel_t next_color = colors[color];
    134        
    135         color++;
    136         if (color >= COLORS)
    137                 color = 0;
    138        
    139         list_foreach(led_devs, link, led_dev_t, dev) {
    140                 if (dev->sess)
    141                         led_dev_color_set(dev->sess, next_color);
    142         }
    143        
    144         fibril_timer_set(timer, PERIOD, timer_callback, NULL);
    145 }
    146 
    147 static void loc_callback(void)
    148 {
    149         category_id_t led_cat;
    150         int rc = loc_category_get_id("led", &led_cat, IPC_FLAG_BLOCKING);
    151         if (rc != EOK)
    152                 return;
    153        
    154         service_id_t *svcs;
    155         size_t count;
    156         rc = loc_category_get_svcs(led_cat, &svcs, &count);
    157         if (rc != EOK)
    158                 return;
    159        
    160         for (size_t i = 0; i < count; i++) {
    161                 bool known = false;
    162                
    163                 /* Determine whether we already know this device. */
    164                 list_foreach(led_devs, link, led_dev_t, dev) {
    165                         if (dev->svc_id == svcs[i]) {
    166                                 known = true;
    167                                 break;
    168                         }
    169                 }
    170                
    171                 if (!known) {
    172                         led_dev_t *dev = (led_dev_t *) calloc(1, sizeof(led_dev_t));
    173                         if (!dev)
    174                                 continue;
    175                        
    176                         link_initialize(&dev->link);
    177                         dev->svc_id = svcs[i];
    178                         dev->sess = loc_service_connect(EXCHANGE_SERIALIZE, svcs[i], 0);
    179                        
    180                         list_append(&dev->link, &led_devs);
    181                 }
    182         }
    183        
    184         // FIXME: Handle LED device removal
    185        
    186         free(svcs);
    187 }
    188 
    189102int main(int argc, char *argv[])
    190103{
    191104        if (argc < 2) {
    192105                printf("Compositor server not specified.\n");
    193                 return 1;
    194         }
    195        
    196         list_initialize(&led_devs);
    197         int rc = loc_register_cat_change_cb(loc_callback);
    198         if (rc != EOK) {
    199                 printf("Unable to register callback for device discovery.\n");
    200                 return 1;
    201         }
    202        
    203         timer = fibril_timer_create(NULL);
    204         if (!timer) {
    205                 printf("Unable to create timer.\n");
    206106                return 1;
    207107        }
     
    262162        window_exec(main_window);
    263163       
    264         fibril_timer_set(timer, PERIOD, timer_callback, NULL);
    265        
    266164        task_retval(0);
    267165        async_manager();
Note: See TracChangeset for help on using the changeset viewer.