Changeset 4cf8ca6 in mainline for uspace/lib/posix/time.c


Ignore:
Timestamp:
2011-07-20T21:52:22Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aa5acd47
Parents:
102a729
Message:

Various minor commenting (no change in functionality).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/time.c

    r102a729 r4cf8ca6  
    3131 * @{
    3232 */
    33 /** @file
     33/** @file Time measurement support.
    3434 */
    3535
     
    6363#define SECS_PER_DAY (SECS_PER_HOUR * HOURS_PER_DAY)
    6464
     65/**
     66 *
     67 * @param year
     68 * @return
     69 */
    6570static bool _is_leap_year(time_t year)
    6671{
     
    7681}
    7782
     83/**
     84 *
     85 * @param year
     86 * @param mon
     87 * @return
     88 */
    7889static int _days_in_month(time_t year, time_t mon)
    7990{
     
    92103}
    93104
     105/**
     106 *
     107 * @param year
     108 * @param mon
     109 * @param mday
     110 * @return
     111 */
    94112static int _day_of_year(time_t year, time_t mon, time_t mday)
    95113{
     
    102120}
    103121
    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
    105128 */
    106129static time_t _floor_div(time_t op1, time_t op2)
     
    113136}
    114137
    115 /* Modulo that rounds to negative infinity.
     138/**
     139 * Modulo that rounds to negative infinity.
     140 *
     141 * @param op1
     142 * @param op2
     143 * @return
    116144 */
    117145static time_t _floor_mod(time_t op1, time_t op2)
     
    132160}
    133161
     162/**
     163 *
     164 * @param year
     165 * @param mon
     166 * @param mday
     167 * @return
     168 */
    134169static time_t _days_since_epoch(time_t year, time_t mon, time_t mday)
    135170{
     
    139174}
    140175
    141 /* Assumes normalized broken-down time. */
     176/**
     177 * Assumes normalized broken-down time.
     178 *
     179 * @param tm
     180 * @return
     181 */
    142182static time_t _secs_since_epoch(const struct posix_tm *tm)
    143183{
     
    147187}
    148188
     189/**
     190 *
     191 * @param year
     192 * @param mon
     193 * @param mday
     194 * @return
     195 */
    149196static int _day_of_week(time_t year, time_t mon, time_t mday)
    150197{
     
    165212};
    166213
     214/**
     215 *
     216 * @param ltm
     217 * @param ptm
     218 */
    167219static void _posix_to_long_tm(struct _long_tm *ltm, struct posix_tm *ptm)
    168220{
     
    179231}
    180232
     233/**
     234 *
     235 * @param ptm
     236 * @param ltm
     237 */
    181238static void _long_to_posix_tm(struct posix_tm *ptm, struct _long_tm *ltm)
    182239{
     
    196253}
    197254
     255/**
     256 *
     257 * @param tm
     258 */
    198259static void _normalize_time(struct _long_tm *tm)
    199260{
     
    241302}
    242303
    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.
    244306 * E.g. if the year starts on December 31st, the return value is -1.
     307 *
     308 * @param year
     309 * @return
    245310 */
    246311static int _wbyear_offset(int year)
     
    250315}
    251316
    252 /* Returns week-based year of the specified time.
     317/**
     318 * Returns week-based year of the specified time.
    253319 * Assumes normalized broken-down time.
     320 *
     321 * @param tm
     322 * @return
    254323 */
    255324static int _wbyear(const struct posix_tm *tm)
     
    268337}
    269338
    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.
    273343 *
    274344 * @param tm Normalized broken-down time.
     
    281351}
    282352
    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.
    288359 *
    289360 * @param tm Normalized broken-down time.
     
    305376}
    306377
    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.
    310382 *
    311383 * @param tm Normalized broken-down time.
     
    324396char *posix_tzname[2];
    325397
     398/**
     399 *
     400 */
    326401void posix_tzset(void)
    327402{
     
    333408}
    334409
     410/**
     411 *
     412 * @param time1
     413 * @param time0
     414 * @return
     415 */
    335416double posix_difftime(time_t time1, time_t time0)
    336417{
     
    338419}
    339420
    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.
    345427 * @return time_t representation of the time, undefined value on overflow
    346428 */
     
    358440}
    359441
     442/**
     443 *
     444 * @param timer
     445 * @return
     446 */
    360447struct posix_tm *posix_gmtime(const time_t *timer)
    361448{
     
    364451}
    365452
     453/**
     454 *
     455 * @param timer
     456 * @param result
     457 * @return
     458 */
    366459struct posix_tm *posix_gmtime_r(const time_t *restrict timer,
    367460    struct posix_tm *restrict result)
     
    394487/**
    395488 *
    396  * @param timep
     489 * @param timer
    397490 * @return
    398491 */
     
    403496}
    404497
     498/**
     499 *
     500 * @param timer
     501 * @param result
     502 * @return
     503 */
    405504struct posix_tm *posix_localtime_r(const time_t *restrict timer,
    406505    struct posix_tm *restrict result)
     
    413512/**
    414513 *
    415  * @param tm
     514 * @param timeptr
    416515 * @return
    417516 */
     
    422521}
    423522
     523/**
     524 *
     525 * @param timeptr
     526 * @param buf
     527 * @return
     528 */
    424529char *posix_asctime_r(const struct posix_tm *restrict timeptr,
    425530    char *restrict buf)
     
    448553/**
    449554 *
    450  * @param timep
     555 * @param timer
    451556 * @return
    452557 */
     
    460565}
    461566
     567/**
     568 *
     569 * @param timer
     570 * @param buf
     571 * @return
     572 */
    462573char *posix_ctime_r(const time_t *timer, char *buf)
    463574{
     
    477588 * @return
    478589 */
    479 size_t posix_strftime(char *s, size_t maxsize,
    480     const char *format, const struct posix_tm *tm)
     590size_t posix_strftime(char *restrict s, size_t maxsize,
     591    const char *restrict format, const struct posix_tm *restrict tm)
    481592{
    482593        // TODO: use locale
     
    655766}
    656767
     768/**
     769 *
     770 * @param s
     771 * @param maxsize
     772 * @param format
     773 * @param tm
     774 * @param loc
     775 * @return
     776 */
     777extern 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 */
    657791int posix_clock_getres(posix_clockid_t clock_id, struct posix_timespec *res)
    658792{
     
    670804}
    671805
     806/**
     807 *
     808 * @param clock_id
     809 * @param tp
     810 * @return
     811 */
    672812int posix_clock_gettime(posix_clockid_t clock_id, struct posix_timespec *tp)
    673813{
     
    688828}
    689829
     830/**
     831 *
     832 * @param clock_id
     833 * @param tp
     834 * @return
     835 */
    690836int posix_clock_settime(posix_clockid_t clock_id,
    691837    const struct posix_timespec *tp)
     
    706852}
    707853
     854/**
     855 *
     856 * @param clock_id
     857 * @param flags
     858 * @param rqtp
     859 * @param rmtp
     860 * @return
     861 */
    708862int posix_clock_nanosleep(posix_clockid_t clock_id, int flags,
    709863    const struct posix_timespec *rqtp, struct posix_timespec *rmtp)
     
    735889};
    736890
     891/**
     892 *
     893 * @param clockid
     894 * @param evp
     895 * @param timerid
     896 * @return
     897 */
    737898int posix_timer_create(posix_clockid_t clockid,
    738899    struct posix_sigevent *restrict evp,
     
    743904}
    744905
     906/**
     907 *
     908 * @param timerid
     909 * @return
     910 */
    745911int posix_timer_delete(posix_timer_t timerid)
    746912{
     
    749915}
    750916
     917/**
     918 *
     919 * @param timerid
     920 * @return
     921 */
    751922int posix_timer_getoverrun(posix_timer_t timerid)
    752923{
     
    755926}
    756927
     928/**
     929 *
     930 * @param timerid
     931 * @param value
     932 * @return
     933 */
    757934int posix_timer_gettime(posix_timer_t timerid,
    758935    struct posix_itimerspec *value)
     
    762939}
    763940
     941/**
     942 *
     943 * @param timerid
     944 * @param flags
     945 * @param value
     946 * @param ovalue
     947 * @return
     948 */
    764949int posix_timer_settime(posix_timer_t timerid, int flags,
    765950    const struct posix_itimerspec *restrict value,
Note: See TracChangeset for help on using the changeset viewer.