Changeset bd41ac52 in mainline for uspace/app
- Timestamp:
- 2018-08-25T22:21:25Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cca80a2
- Parents:
- e2625b1a
- Location:
- uspace/app
- Files:
-
- 15 edited
-
barber/barber.c (modified) (4 diffs)
-
bdsh/cmds/modules/sleep/sleep.c (modified) (6 diffs)
-
bnchmark/bnchmark.c (modified) (4 diffs)
-
modplay/modplay.c (modified) (1 diff)
-
stats/stats.c (modified) (1 diff)
-
tester/ipc/ping_pong.c (modified) (2 diffs)
-
tester/ipc/starve.c (modified) (2 diffs)
-
testread/testread.c (modified) (3 diffs)
-
tetris/scores.h (modified) (1 diff)
-
tetris/screen.c (modified) (2 diffs)
-
tetris/tetris.c (modified) (2 diffs)
-
top/screen.c (modified) (6 diffs)
-
top/screen.h (modified) (1 diff)
-
top/top.c (modified) (3 diffs)
-
wavplay/dplay.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/barber/barber.c
re2625b1a rbd41ac52 130 130 } 131 131 132 static void plan_frame_timer( suseconds_t render_time)132 static void plan_frame_timer(usec_t render_time) 133 133 { 134 134 /* … … 139 139 */ 140 140 141 suseconds_t delta = 1000000 / fps;141 usec_t delta = 1000000 / fps; 142 142 load_t load = get_load(); 143 143 … … 190 190 static void frame_timer_callback(void *data) 191 191 { 192 struct time valprev;192 struct timespec prev; 193 193 getuptime(&prev); 194 194 … … 199 199 update_canvas(frame_canvas, frames[frame]); 200 200 201 struct time valcur;201 struct timespec cur; 202 202 getuptime(&cur); 203 203 204 plan_frame_timer( tv_sub_diff(&cur, &prev));204 plan_frame_timer(NSEC2USEC(ts_sub_diff(&cur, &prev))); 205 205 } 206 206 -
uspace/app/bdsh/cmds/modules/sleep/sleep.c
re2625b1a rbd41ac52 57 57 } 58 58 59 /** Convert string containing decimal seconds to usec onds_t.59 /** Convert string containing decimal seconds to usec_t. 60 60 * 61 61 * @param nptr Pointer to string. … … 63 63 * @return EOK if conversion was successful. 64 64 */ 65 static errno_t decimal_to_useconds(const char *nptr, usec onds_t *result)65 static errno_t decimal_to_useconds(const char *nptr, usec_t *result) 66 66 { 67 67 errno_t ret; 68 uint64_t whole_seconds;69 u int64_t frac_seconds;68 sec_t whole_seconds; 69 usec_t frac_seconds; 70 70 const char *endptr; 71 71 … … 75 75 endptr = (char *)nptr; 76 76 } else { 77 ret = str_ uint64_t(nptr, &endptr, 10, false, &whole_seconds);77 ret = str_int64_t(nptr, &endptr, 10, false, &whole_seconds); 78 78 if (ret != EOK) 79 79 return ret; … … 87 87 } else if (*endptr == '.') { 88 88 nptr = endptr + 1; 89 ret = str_ uint64_t(nptr, &endptr, 10, true, &frac_seconds);89 ret = str_int64_t(nptr, &endptr, 10, true, &frac_seconds); 90 90 if (ret != EOK) 91 91 return ret; … … 101 101 102 102 /* Check for overflow */ 103 usec onds_t total = whole_seconds * 1000000+ frac_seconds;104 if ( total / 1000000!= whole_seconds)103 usec_t total = SEC2USEC(whole_seconds) + frac_seconds; 104 if (USEC2SEC(total) != whole_seconds) 105 105 return EOVERFLOW; 106 106 … … 115 115 errno_t ret; 116 116 unsigned int argc; 117 usec onds_t duration = 0;117 usec_t duration = 0; 118 118 119 119 /* Count the arguments */ -
uspace/app/bnchmark/bnchmark.c
re2625b1a rbd41ac52 56 56 57 57 typedef errno_t (*measure_func_t)(void *); 58 typedef unsigned long umseconds_t; /* milliseconds */59 58 60 59 static void syntax_print(void); 61 60 62 static errno_t measure(measure_func_t fn, void *data, umseconds_t *result)63 { 64 struct time valstart_time;65 get timeofday(&start_time, NULL);61 static errno_t measure(measure_func_t fn, void *data, msec_t *result) 62 { 63 struct timespec start_time; 64 getuptime(&start_time); 66 65 67 66 errno_t rc = fn(data); … … 71 70 } 72 71 73 struct time valfinal_time;74 get timeofday(&final_time, NULL);72 struct timespec final_time; 73 getuptime(&final_time); 75 74 76 75 /* Calculate time difference in milliseconds */ 77 *result = ((final_time.tv_usec - start_time.tv_usec) / 1000) + 78 ((final_time.tv_sec - start_time.tv_sec) * 1000); 76 *result = NSEC2USEC(ts_sub_diff(&final_time, &start_time)); 79 77 return EOK; 80 78 } … … 133 131 { 134 132 errno_t rc; 135 umseconds_t milliseconds_taken = 0;133 msec_t milliseconds_taken = 0; 136 134 char *path = NULL; 137 135 measure_func_t fn = NULL; … … 194 192 } 195 193 196 printf("%s;%s;%s;%l u;ms\n", test_type, path, log_str, milliseconds_taken);194 printf("%s;%s;%s;%lld;ms\n", test_type, path, log_str, milliseconds_taken); 197 195 } 198 196 -
uspace/app/modplay/modplay.c
re2625b1a rbd41ac52 75 75 console_ctrl_t *con; 76 76 cons_event_t event; 77 suseconds_t timeout;77 usec_t timeout; 78 78 pcm_format_t format; 79 79 void *buffer; -
uspace/app/stats/stats.c
re2625b1a rbd41ac52 190 190 static void print_uptime(void) 191 191 { 192 struct time valuptime;192 struct timespec uptime; 193 193 getuptime(&uptime); 194 194 195 printf("%s: Up %l d days, %ld hours, %ld minutes, %ld seconds\n",195 printf("%s: Up %lld days, %lld hours, %lld minutes, %lld seconds\n", 196 196 NAME, uptime.tv_sec / DAY, (uptime.tv_sec % DAY) / HOUR, 197 197 (uptime.tv_sec % HOUR) / MINUTE, uptime.tv_sec % MINUTE); -
uspace/app/tester/ipc/ping_pong.c
re2625b1a rbd41ac52 29 29 #include <stdio.h> 30 30 #include <stdlib.h> 31 #include < sys/time.h>31 #include <time.h> 32 32 #include <ns.h> 33 33 #include <async.h> … … 42 42 TPRINTF("Pinging ns server for %d seconds...", DURATION_SECS); 43 43 44 struct time valstart;45 get timeofday(&start, NULL);44 struct timespec start; 45 getuptime(&start); 46 46 47 47 uint64_t count = 0; 48 48 while (true) { 49 struct time valnow;50 get timeofday(&now, NULL);49 struct timespec now; 50 getuptime(&now); 51 51 52 if ( tv_sub_diff(&now, &start) >= DURATION_SECS * 1000000L)52 if (NSEC2SEC(ts_sub_diff(&now, &start)) >= DURATION_SECS) 53 53 break; 54 54 -
uspace/app/tester/ipc/starve.c
re2625b1a rbd41ac52 29 29 #include <stdio.h> 30 30 #include <stdlib.h> 31 #include < sys/time.h>31 #include <time.h> 32 32 #include <io/console.h> 33 33 #include <async.h> … … 43 43 return "Failed to init connection with console."; 44 44 45 struct time valstart;46 get timeofday(&start, NULL);45 struct timespec start; 46 getuptime(&start); 47 47 48 48 TPRINTF("Intensive computation shall be imagined (for %ds)...\n", DURATION_SECS); 49 49 TPRINTF("Press a key to terminate prematurely...\n"); 50 50 while (true) { 51 struct time valnow;52 get timeofday(&now, NULL);51 struct timespec now; 52 getuptime(&now); 53 53 54 if ( tv_sub_diff(&now, &start) >= DURATION_SECS * 1000000L)54 if (NSEC2SEC(ts_sub_diff(&now, &start)) >= DURATION_SECS) 55 55 break; 56 56 57 57 cons_event_t ev; 58 suseconds_t timeout = 0;58 usec_t timeout = 0; 59 59 bool has_event = console_get_event_timeout(console, &ev, &timeout); 60 60 if (has_event && ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { -
uspace/app/testread/testread.c
re2625b1a rbd41ac52 126 126 next_mark = 0; 127 127 last_mark = 0; 128 struct time valprev_time;129 struct time valstart_time;130 get timeofday(&start_time, NULL);128 struct timespec prev_time; 129 struct timespec start_time; 130 getuptime(&start_time); 131 131 prev_time = start_time; 132 132 … … 152 152 153 153 if (progress && offset >= next_mark) { 154 struct time valcur_time;155 get timeofday(&cur_time, NULL);154 struct timespec cur_time; 155 getuptime(&cur_time); 156 156 157 157 uint32_t last_run = cur_time.tv_sec - prev_time.tv_sec; … … 170 170 } 171 171 172 struct time valfinal_time;173 get timeofday(&final_time, NULL);172 struct timespec final_time; 173 getuptime(&final_time); 174 174 175 175 uint32_t total_run_time = final_time.tv_sec - start_time.tv_sec; -
uspace/app/tetris/scores.h
re2625b1a rbd41ac52 54 54 */ 55 55 56 #include < sys/time.h>56 #include <time.h> 57 57 #include <str.h> 58 58 -
uspace/app/tetris/screen.c
re2625b1a rbd41ac52 75 75 static const struct shape *lastshape; 76 76 77 static suseconds_t timeleft = 0;77 static usec_t timeleft = 0; 78 78 79 79 console_ctrl_t *console; … … 340 340 void tsleep(void) 341 341 { 342 suseconds_t timeout = fallrate;342 usec_t timeout = fallrate; 343 343 344 344 while (timeout > 0) { -
uspace/app/tetris/tetris.c
re2625b1a rbd41ac52 55 55 "\tThe Regents of the University of California. All rights reserved.\n"; 56 56 57 #include < sys/time.h>57 #include <time.h> 58 58 #include <errno.h> 59 59 #include <stdbool.h> … … 170 170 static void srandomdev(void) 171 171 { 172 struct time val tv;173 174 get timeofday(&tv, NULL);175 srand(t v.tv_sec + tv.tv_usec / 100000);172 struct timespec ts; 173 174 getrealtime(&ts); 175 srand(ts.tv_sec + ts.tv_nsec / 100000000); 176 176 } 177 177 -
uspace/app/top/screen.c
re2625b1a rbd41ac52 49 49 #include "top.h" 50 50 51 #define USEC_COUNT 1000000 52 53 static suseconds_t timeleft = 0; 51 static usec_t timeleft = 0; 54 52 55 53 console_ctrl_t *console; … … 57 55 static sysarg_t warning_col = 0; 58 56 static sysarg_t warning_row = 0; 59 static suseconds_t warning_timeleft = 0;57 static usec_t warning_timeleft = 0; 60 58 static char *warning_text = NULL; 61 59 … … 179 177 static inline void print_global_head(data_t *data) 180 178 { 181 printf("top - %02l u:%02lu:%02luup "179 printf("top - %02lld:%02lld:%02lld up " 182 180 "%" PRIun " days, %02" PRIun ":%02" PRIun ":%02" PRIun ", " 183 181 "load average:", … … 527 525 va_end(args); 528 526 529 warning_timeleft = 2 * USEC_COUNT;527 warning_timeleft = SEC2USEC(2); 530 528 531 529 screen_moveto(warning_col, warning_row); … … 537 535 * 538 536 */ 539 int tgetchar( unsigned int sec)537 int tgetchar(sec_t sec) 540 538 { 541 539 /* … … 544 542 545 543 if (timeleft <= 0) 546 timeleft = sec * USEC_COUNT;544 timeleft = SEC2USEC(sec); 547 545 548 546 /* -
uspace/app/top/screen.h
re2625b1a rbd41ac52 47 47 _HELENOS_PRINTF_ATTRIBUTE(1, 2); 48 48 49 extern int tgetchar( unsigned int);49 extern int tgetchar(sec_t); 50 50 51 51 #endif -
uspace/app/top/top.c
re2625b1a rbd41ac52 39 39 #include <stdlib.h> 40 40 #include <task.h> 41 #include < sys/time.h>41 #include <time.h> 42 42 #include <errno.h> 43 43 #include <gsort.h> … … 154 154 155 155 /* Get current time */ 156 struct time valtime;157 get timeofday(&time, NULL);156 struct timespec time; 157 getrealtime(&time); 158 158 159 159 target->hours = (time.tv_sec % DAY) / HOUR; … … 162 162 163 163 /* Get uptime */ 164 struct time valuptime;164 struct timespec uptime; 165 165 getuptime(&uptime); 166 166 -
uspace/app/wavplay/dplay.c
re2625b1a rbd41ac52 42 42 #include <pcm/format.h> 43 43 #include <as.h> 44 #include < sys/time.h>44 #include <time.h> 45 45 #include <inttypes.h> 46 46 #include <stdbool.h> … … 242 242 243 243 #define DPRINTF(f, ...) \ 244 printf("%.2lu:%.6lu "f, time.tv_sec % 100, time.tv_usec, __VA_ARGS__) 244 printf("%.2lld:%.6lld "f, time.tv_sec % 100, \ 245 NSEC2USEC(time.tv_nsec), __VA_ARGS__) 245 246 246 247 /** … … 255 256 printf("Playing: %dHz, %s, %d channel(s).\n", pb->f.sampling_rate, 256 257 pcm_sample_format_str(pb->f.sample_format), pb->f.channels); 257 usec onds_t work_time = 50000; /* 50 ms */258 usec_t work_time = 50000; /* 50 ms */ 258 259 bool started = false; 259 260 size_t pos = 0; 260 struct time valtime = { 0 };261 struct timespec time = { 0 }; 261 262 getuptime(&time); 262 263 while (true) { … … 303 304 } 304 305 const size_t to_play = buffer_occupied(pb, pos); 305 const useconds_t usecs = 306 pcm_format_size_to_usec(to_play, &pb->f); 306 const usec_t usecs = pcm_format_size_to_usec(to_play, &pb->f); 307 307 308 308 /* Compute delay time */ 309 const usec onds_t real_delay = (usecs > work_time) ?309 const usec_t real_delay = (usecs > work_time) ? 310 310 usecs - work_time : 0; 311 DPRINTF("POS %zu: % u usecs (%u) to play %zu bytes.\n",311 DPRINTF("POS %zu: %lld usecs (%lld) to play %zu bytes.\n", 312 312 pos, usecs, real_delay, to_play); 313 313 if (real_delay)
Note:
See TracChangeset
for help on using the changeset viewer.
