Changes in uspace/lib/posix/time.c [a12f7f1:3f466c33] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/time.c
ra12f7f1 r3f466c33 31 31 * @{ 32 32 */ 33 /** @file Time measurement support.33 /** @file 34 34 */ 35 35 … … 63 63 #define SECS_PER_DAY (SECS_PER_HOUR * HOURS_PER_DAY) 64 64 65 /**66 *67 * @param year68 * @return69 */70 65 static bool _is_leap_year(time_t year) 71 66 { … … 81 76 } 82 77 83 /**84 *85 * @param year86 * @param mon87 * @return88 */89 78 static int _days_in_month(time_t year, time_t mon) 90 79 { … … 103 92 } 104 93 105 /**106 *107 * @param year108 * @param mon109 * @param mday110 * @return111 */112 94 static int _day_of_year(time_t year, time_t mon, time_t mday) 113 95 { … … 120 102 } 121 103 122 /** 123 * Integer division that rounds to negative infinity. 124 * 125 * @param op1 126 * @param op2 127 * @return 104 /* Integer division that rounds to negative infinity. 128 105 */ 129 106 static time_t _floor_div(time_t op1, time_t op2) … … 136 113 } 137 114 138 /** 139 * Modulo that rounds to negative infinity. 140 * 141 * @param op1 142 * @param op2 143 * @return 115 /* Modulo that rounds to negative infinity. 144 116 */ 145 117 static time_t _floor_mod(time_t op1, time_t op2) … … 160 132 } 161 133 162 /**163 *164 * @param year165 * @param mon166 * @param mday167 * @return168 */169 134 static time_t _days_since_epoch(time_t year, time_t mon, time_t mday) 170 135 { … … 174 139 } 175 140 176 /** 177 * Assumes normalized broken-down time. 178 * 179 * @param tm 180 * @return 181 */ 141 /* Assumes normalized broken-down time. */ 182 142 static time_t _secs_since_epoch(const struct posix_tm *tm) 183 143 { … … 187 147 } 188 148 189 /**190 *191 * @param year192 * @param mon193 * @param mday194 * @return195 */196 149 static int _day_of_week(time_t year, time_t mon, time_t mday) 197 150 { … … 212 165 }; 213 166 214 /**215 *216 * @param ltm217 * @param ptm218 */219 167 static void _posix_to_long_tm(struct _long_tm *ltm, struct posix_tm *ptm) 220 168 { … … 231 179 } 232 180 233 /**234 *235 * @param ptm236 * @param ltm237 */238 181 static void _long_to_posix_tm(struct posix_tm *ptm, struct _long_tm *ltm) 239 182 { … … 253 196 } 254 197 255 /**256 *257 * @param tm258 */259 198 static void _normalize_time(struct _long_tm *tm) 260 199 { … … 302 241 } 303 242 304 /** 305 * Which day the week-based year starts on relative to the first calendar day. 243 /* Which day the week-based year starts on relative to the first calendar day. 306 244 * E.g. if the year starts on December 31st, the return value is -1. 307 *308 * @param year309 * @return310 245 */ 311 246 static int _wbyear_offset(int year) … … 315 250 } 316 251 317 /** 318 * Returns week-based year of the specified time. 252 /* Returns week-based year of the specified time. 319 253 * Assumes normalized broken-down time. 320 *321 * @param tm322 * @return323 254 */ 324 255 static int _wbyear(const struct posix_tm *tm) … … 337 268 } 338 269 339 /** 340 * Week number of the year, assuming weeks start on sunday. 341 * The first Sunday of January is the first day of week 1; 342 * days in the new year before this are in week 0. 270 /** Week number of the year, assuming weeks start on sunday. 271 * The first Sunday of January is the first day of week 1; 272 * days in the new year before this are in week 0. 343 273 * 344 274 * @param tm Normalized broken-down time. … … 351 281 } 352 282 353 /** 354 * Week number of the year, assuming weeks start on monday. 355 * If the week containing January 1st has four or more days in the new year, 356 * then it is considered week 1. Otherwise, it is the last week of the previous 357 * year, and the next week is week 1. Both January 4th and the first Thursday 358 * of January are always in week 1. 283 /** Week number of the year, assuming weeks start on monday. 284 * If the week containing January 1st has four or more days in the new year, 285 * then it is considered week 1. Otherwise, it is the last week of the previous 286 * year, and the next week is week 1. Both January 4th and the first Thursday 287 * of January are always in week 1. 359 288 * 360 289 * @param tm Normalized broken-down time. … … 376 305 } 377 306 378 /** 379 * Week number of the year, assuming weeks start on monday. 380 * The first Monday of January is the first day of week 1; 381 * days in the new year before this are in week 0. 307 /** Week number of the year, assuming weeks start on monday. 308 * The first Monday of January is the first day of week 1; 309 * days in the new year before this are in week 0. 382 310 * 383 311 * @param tm Normalized broken-down time. … … 396 324 char *posix_tzname[2]; 397 325 398 /**399 *400 */401 326 void posix_tzset(void) 402 327 { … … 408 333 } 409 334 410 /**411 *412 * @param time1413 * @param time0414 * @return415 */416 335 double posix_difftime(time_t time1, time_t time0) 417 336 { … … 419 338 } 420 339 421 /** 422 * This function first normalizes the provided broken-down time 423 * (moves all values to their proper bounds) and then tries to 424 * calculate the appropriate time_t representation. 425 * 426 * @param tm Broken-down time. 340 /** This function first normalizes the provided broken-down time 341 * (moves all values to their proper bounds) and then tries to 342 * calculate the appropriate time_t representation. 343 * 344 * @param timeptr Broken-down time. 427 345 * @return time_t representation of the time, undefined value on overflow 428 346 */ … … 440 358 } 441 359 442 /**443 *444 * @param timer445 * @return446 */447 360 struct posix_tm *posix_gmtime(const time_t *timer) 448 361 { … … 451 364 } 452 365 453 /**454 *455 * @param timer456 * @param result457 * @return458 */459 366 struct posix_tm *posix_gmtime_r(const time_t *restrict timer, 460 367 struct posix_tm *restrict result) … … 487 394 /** 488 395 * 489 * @param time r396 * @param timep 490 397 * @return 491 398 */ … … 496 403 } 497 404 498 /**499 *500 * @param timer501 * @param result502 * @return503 */504 405 struct posix_tm *posix_localtime_r(const time_t *restrict timer, 505 406 struct posix_tm *restrict result) … … 512 413 /** 513 414 * 514 * @param t imeptr415 * @param tm 515 416 * @return 516 417 */ … … 521 422 } 522 423 523 /**524 *525 * @param timeptr526 * @param buf527 * @return528 */529 424 char *posix_asctime_r(const struct posix_tm *restrict timeptr, 530 425 char *restrict buf) … … 553 448 /** 554 449 * 555 * @param time r450 * @param timep 556 451 * @return 557 452 */ … … 565 460 } 566 461 567 /**568 *569 * @param timer570 * @param buf571 * @return572 */573 462 char *posix_ctime_r(const time_t *timer, char *buf) 574 463 { … … 588 477 * @return 589 478 */ 590 size_t posix_strftime(char * restricts, size_t maxsize,591 const char * restrict format, const struct posix_tm *restricttm)479 size_t posix_strftime(char *s, size_t maxsize, 480 const char *format, const struct posix_tm *tm) 592 481 { 593 482 // TODO: use locale … … 766 655 } 767 656 768 /**769 *770 * @param s771 * @param maxsize772 * @param format773 * @param tm774 * @param loc775 * @return776 */777 extern size_t posix_strftime_l(char *restrict s, size_t maxsize,778 const char *restrict format, const struct posix_tm *restrict tm,779 posix_locale_t loc)780 {781 // TODO782 not_implemented();783 }784 785 /**786 *787 * @param clock_id788 * @param res789 * @return790 */791 657 int posix_clock_getres(posix_clockid_t clock_id, struct posix_timespec *res) 792 658 { … … 804 670 } 805 671 806 /**807 *808 * @param clock_id809 * @param tp810 * @return811 */812 672 int posix_clock_gettime(posix_clockid_t clock_id, struct posix_timespec *tp) 813 673 { … … 828 688 } 829 689 830 /**831 *832 * @param clock_id833 * @param tp834 * @return835 */836 690 int posix_clock_settime(posix_clockid_t clock_id, 837 691 const struct posix_timespec *tp) … … 852 706 } 853 707 854 /**855 *856 * @param clock_id857 * @param flags858 * @param rqtp859 * @param rmtp860 * @return861 */862 708 int posix_clock_nanosleep(posix_clockid_t clock_id, int flags, 863 709 const struct posix_timespec *rqtp, struct posix_timespec *rmtp) … … 889 735 }; 890 736 891 /**892 *893 * @param clockid894 * @param evp895 * @param timerid896 * @return897 */898 737 int posix_timer_create(posix_clockid_t clockid, 899 738 struct posix_sigevent *restrict evp, … … 904 743 } 905 744 906 /**907 *908 * @param timerid909 * @return910 */911 745 int posix_timer_delete(posix_timer_t timerid) 912 746 { … … 915 749 } 916 750 917 /**918 *919 * @param timerid920 * @return921 */922 751 int posix_timer_getoverrun(posix_timer_t timerid) 923 752 { … … 926 755 } 927 756 928 /**929 *930 * @param timerid931 * @param value932 * @return933 */934 757 int posix_timer_gettime(posix_timer_t timerid, 935 758 struct posix_itimerspec *value) … … 939 762 } 940 763 941 /**942 *943 * @param timerid944 * @param flags945 * @param value946 * @param ovalue947 * @return948 */949 764 int posix_timer_settime(posix_timer_t timerid, int flags, 950 765 const struct posix_itimerspec *restrict value, … … 968 783 if (task_stats) { 969 784 total_cycles = (posix_clock_t) (task_stats->kcycles + task_stats->ucycles); 970 free(task_stats);971 task_stats = 0;972 }785 } 786 free(task_stats); 787 task_stats = 0; 973 788 974 789 return total_cycles;
Note:
See TracChangeset
for help on using the changeset viewer.