Changeset eccd20e6 in mainline for uspace/lib/posix/time.c
- Timestamp:
- 2011-07-21T22:34:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c6f4681, e478cebf
- Parents:
- df0956ee (diff), cfbb5d18 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/time.c
rdf0956ee reccd20e6 31 31 * @{ 32 32 */ 33 /** @file 33 /** @file Time measurement support. 34 34 */ 35 35 … … 63 63 #define SECS_PER_DAY (SECS_PER_HOUR * HOURS_PER_DAY) 64 64 65 /** 66 * 67 * @param year 68 * @return 69 */ 65 70 static bool _is_leap_year(time_t year) 66 71 { … … 76 81 } 77 82 83 /** 84 * 85 * @param year 86 * @param mon 87 * @return 88 */ 78 89 static int _days_in_month(time_t year, time_t mon) 79 90 { … … 92 103 } 93 104 105 /** 106 * 107 * @param year 108 * @param mon 109 * @param mday 110 * @return 111 */ 94 112 static int _day_of_year(time_t year, time_t mon, time_t mday) 95 113 { … … 102 120 } 103 121 104 /* Integer division that rounds to negative infinity. 122 /** 123 * Integer division that rounds to negative infinity. 124 * 125 * @param op1 126 * @param op2 127 * @return 105 128 */ 106 129 static time_t _floor_div(time_t op1, time_t op2) … … 113 136 } 114 137 115 /* Modulo that rounds to negative infinity. 138 /** 139 * Modulo that rounds to negative infinity. 140 * 141 * @param op1 142 * @param op2 143 * @return 116 144 */ 117 145 static time_t _floor_mod(time_t op1, time_t op2) … … 132 160 } 133 161 162 /** 163 * 164 * @param year 165 * @param mon 166 * @param mday 167 * @return 168 */ 134 169 static time_t _days_since_epoch(time_t year, time_t mon, time_t mday) 135 170 { … … 139 174 } 140 175 141 /* Assumes normalized broken-down time. */ 176 /** 177 * Assumes normalized broken-down time. 178 * 179 * @param tm 180 * @return 181 */ 142 182 static time_t _secs_since_epoch(const struct posix_tm *tm) 143 183 { … … 147 187 } 148 188 189 /** 190 * 191 * @param year 192 * @param mon 193 * @param mday 194 * @return 195 */ 149 196 static int _day_of_week(time_t year, time_t mon, time_t mday) 150 197 { … … 165 212 }; 166 213 214 /** 215 * 216 * @param ltm 217 * @param ptm 218 */ 167 219 static void _posix_to_long_tm(struct _long_tm *ltm, struct posix_tm *ptm) 168 220 { … … 179 231 } 180 232 233 /** 234 * 235 * @param ptm 236 * @param ltm 237 */ 181 238 static void _long_to_posix_tm(struct posix_tm *ptm, struct _long_tm *ltm) 182 239 { … … 196 253 } 197 254 255 /** 256 * 257 * @param tm 258 */ 198 259 static void _normalize_time(struct _long_tm *tm) 199 260 { … … 241 302 } 242 303 243 /* Which day the week-based year starts on relative to the first calendar day. 304 /** 305 * Which day the week-based year starts on relative to the first calendar day. 244 306 * E.g. if the year starts on December 31st, the return value is -1. 307 * 308 * @param year 309 * @return 245 310 */ 246 311 static int _wbyear_offset(int year) … … 250 315 } 251 316 252 /* Returns week-based year of the specified time. 317 /** 318 * Returns week-based year of the specified time. 253 319 * Assumes normalized broken-down time. 320 * 321 * @param tm 322 * @return 254 323 */ 255 324 static int _wbyear(const struct posix_tm *tm) … … 268 337 } 269 338 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. 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. 273 343 * 274 344 * @param tm Normalized broken-down time. … … 281 351 } 282 352 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. 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. 288 359 * 289 360 * @param tm Normalized broken-down time. … … 305 376 } 306 377 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. 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. 310 382 * 311 383 * @param tm Normalized broken-down time. … … 324 396 char *posix_tzname[2]; 325 397 398 /** 399 * 400 */ 326 401 void posix_tzset(void) 327 402 { … … 333 408 } 334 409 410 /** 411 * 412 * @param time1 413 * @param time0 414 * @return 415 */ 335 416 double posix_difftime(time_t time1, time_t time0) 336 417 { … … 338 419 } 339 420 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. 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. 345 427 * @return time_t representation of the time, undefined value on overflow 346 428 */ … … 358 440 } 359 441 442 /** 443 * 444 * @param timer 445 * @return 446 */ 360 447 struct posix_tm *posix_gmtime(const time_t *timer) 361 448 { … … 364 451 } 365 452 453 /** 454 * 455 * @param timer 456 * @param result 457 * @return 458 */ 366 459 struct posix_tm *posix_gmtime_r(const time_t *restrict timer, 367 460 struct posix_tm *restrict result) … … 394 487 /** 395 488 * 396 * @param time p489 * @param timer 397 490 * @return 398 491 */ … … 403 496 } 404 497 498 /** 499 * 500 * @param timer 501 * @param result 502 * @return 503 */ 405 504 struct posix_tm *posix_localtime_r(const time_t *restrict timer, 406 505 struct posix_tm *restrict result) … … 413 512 /** 414 513 * 415 * @param t m514 * @param timeptr 416 515 * @return 417 516 */ … … 422 521 } 423 522 523 /** 524 * 525 * @param timeptr 526 * @param buf 527 * @return 528 */ 424 529 char *posix_asctime_r(const struct posix_tm *restrict timeptr, 425 530 char *restrict buf) … … 448 553 /** 449 554 * 450 * @param time p555 * @param timer 451 556 * @return 452 557 */ … … 460 565 } 461 566 567 /** 568 * 569 * @param timer 570 * @param buf 571 * @return 572 */ 462 573 char *posix_ctime_r(const time_t *timer, char *buf) 463 574 { … … 477 588 * @return 478 589 */ 479 size_t posix_strftime(char * s, size_t maxsize,480 const char * format, const struct posix_tm *tm)590 size_t posix_strftime(char *restrict s, size_t maxsize, 591 const char *restrict format, const struct posix_tm *restrict tm) 481 592 { 482 593 // TODO: use locale … … 655 766 } 656 767 768 /** 769 * 770 * @param s 771 * @param maxsize 772 * @param format 773 * @param tm 774 * @param loc 775 * @return 776 */ 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 // TODO 782 not_implemented(); 783 } 784 785 /** 786 * 787 * @param clock_id 788 * @param res 789 * @return 790 */ 657 791 int posix_clock_getres(posix_clockid_t clock_id, struct posix_timespec *res) 658 792 { … … 670 804 } 671 805 806 /** 807 * 808 * @param clock_id 809 * @param tp 810 * @return 811 */ 672 812 int posix_clock_gettime(posix_clockid_t clock_id, struct posix_timespec *tp) 673 813 { … … 688 828 } 689 829 830 /** 831 * 832 * @param clock_id 833 * @param tp 834 * @return 835 */ 690 836 int posix_clock_settime(posix_clockid_t clock_id, 691 837 const struct posix_timespec *tp) … … 706 852 } 707 853 854 /** 855 * 856 * @param clock_id 857 * @param flags 858 * @param rqtp 859 * @param rmtp 860 * @return 861 */ 708 862 int posix_clock_nanosleep(posix_clockid_t clock_id, int flags, 709 863 const struct posix_timespec *rqtp, struct posix_timespec *rmtp) … … 735 889 }; 736 890 891 /** 892 * 893 * @param clockid 894 * @param evp 895 * @param timerid 896 * @return 897 */ 737 898 int posix_timer_create(posix_clockid_t clockid, 738 899 struct posix_sigevent *restrict evp, … … 743 904 } 744 905 906 /** 907 * 908 * @param timerid 909 * @return 910 */ 745 911 int posix_timer_delete(posix_timer_t timerid) 746 912 { … … 749 915 } 750 916 917 /** 918 * 919 * @param timerid 920 * @return 921 */ 751 922 int posix_timer_getoverrun(posix_timer_t timerid) 752 923 { … … 755 926 } 756 927 928 /** 929 * 930 * @param timerid 931 * @param value 932 * @return 933 */ 757 934 int posix_timer_gettime(posix_timer_t timerid, 758 935 struct posix_itimerspec *value) … … 762 939 } 763 940 941 /** 942 * 943 * @param timerid 944 * @param flags 945 * @param value 946 * @param ovalue 947 * @return 948 */ 764 949 int posix_timer_settime(posix_timer_t timerid, int flags, 765 950 const struct posix_itimerspec *restrict value, … … 783 968 if (task_stats) { 784 969 total_cycles = (posix_clock_t) (task_stats->kcycles + task_stats->ucycles); 785 }786 free(task_stats);787 task_stats = 0;970 free(task_stats); 971 task_stats = 0; 972 } 788 973 789 974 return total_cycles;
Note:
See TracChangeset
for help on using the changeset viewer.