Changeset e6165be in mainline


Ignore:
Timestamp:
2011-08-17T17:47:47Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3e01316f, 55b1efd
Parents:
1b55da67
Message:

Documentation and changes to <time.h> implementation.

Location:
uspace/lib/posix
Files:
2 edited

Legend:

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

    r1b55da67 re6165be  
    5454// TODO: test everything in this file
    5555
     56/* In some places in this file, phrase "normalized broken-down time" is used.
     57 * This means time broken down to components (year, month, day, hour, min, sec),
     58 * in which every component is in its proper bounds. Non-normalized time could
     59 * e.g. be 2011-54-5 29:13:-5, which would semantically mean start of year 2011
     60 * + 53 months + 4 days + 29 hours + 13 minutes - 5 seconds.
     61 */
     62
     63
     64
    5665/* Helper functions ***********************************************************/
    5766
     
    6372#define SECS_PER_DAY (SECS_PER_HOUR * HOURS_PER_DAY)
    6473
    65 /**
    66  *
    67  * @param year
    68  * @return
     74/** Checks whether the year is a leap year.
     75 *
     76 * @param year Year since 1900 (e.g. for 1970, the value is 70).
     77 * @return true if year is a leap year, false otherwise
    6978 */
    7079static bool _is_leap_year(time_t year)
     
    8190}
    8291
    83 /**
    84  *
    85  * @param year
    86  * @param mon
    87  * @return
     92/** Returns how many days there are in the given month of the given year.
     93 *  Note that year is only taken into account if month is February.
     94 *
     95 * @param year Year since 1900 (can be negative).
     96 * @param mon Month of the year. 0 for January, 11 for December.
     97 * @return Number of days in the specified month.
    8898 */
    8999static int _days_in_month(time_t year, time_t mon)
    90100{
    91101        assert(mon >= 0 && mon <= 11);
    92         year += 1900;
    93102
    94103        static int month_days[] =
     
    96105
    97106        if (mon == 1) {
     107                year += 1900;
    98108                /* february */
    99109                return _is_leap_year(year) ? 29 : 28;
     
    103113}
    104114
    105 /**
    106  *
    107  * @param year
    108  * @param mon
    109  * @param mday
    110  * @return
     115/** For specified year, month and day of month, returns which day of that year
     116 *  it is.
     117 *
     118 * For example, given date 2011-01-03, the corresponding expression is:
     119 *     _day_of_year(111, 0, 3) == 2
     120 *
     121 * @param year Year (year 1900 = 0, can be negative).
     122 * @param mon Month (January = 0).
     123 * @param mday Day of month (First day is 1).
     124 * @return Day of year (First day is 0).
    111125 */
    112126static int _day_of_year(time_t year, time_t mon, time_t mday)
     
    120134}
    121135
    122 /**
    123  * Integer division that rounds to negative infinity.
     136/** Integer division that rounds to negative infinity.
     137 *  Used by some functions in this file.
    124138 *
    125139 * @param op1
     
    136150}
    137151
    138 /**
    139  * Modulo that rounds to negative infinity.
     152/** Modulo that rounds to negative infinity.
     153 *  Used by some functions in this file.
    140154 *
    141155 * @param op1
     
    160174}
    161175
    162 /**
    163  *
    164  * @param year
    165  * @param mon
    166  * @param mday
    167  * @return
     176/** Number of days since the Epoch.
     177 *  Epoch is 1970-01-01, which is also equal to day 0.
     178 *
     179 * @param year Year (year 1900 = 0, may be negative).
     180 * @param mon Month (January = 0).
     181 * @param mday Day of month (first day = 1).
     182 * @return Number of days since the Epoch.
    168183 */
    169184static time_t _days_since_epoch(time_t year, time_t mon, time_t mday)
     
    174189}
    175190
    176 /**
    177  * Assumes normalized broken-down time.
    178  *
    179  * @param tm
    180  * @return
     191/** Seconds since the Epoch. see also _days_since_epoch().
     192 *
     193 * @param tm Normalized broken-down time.
     194 * @return Number of seconds since the epoch, not counting leap seconds.
    181195 */
    182196static time_t _secs_since_epoch(const struct posix_tm *tm)
     
    187201}
    188202
    189 /**
    190  *
    191  * @param year
    192  * @param mon
    193  * @param mday
    194  * @return
     203/** Which day of week the specified date is.
     204 *
     205 * @param year Year (year 1900 = 0).
     206 * @param mon Month (January = 0).
     207 * @param mday Day of month (first = 1).
     208 * @return Day of week (Sunday = 0).
    195209 */
    196210static int _day_of_week(time_t year, time_t mon, time_t mday)
    197211{
    198212        /* 1970-01-01 is Thursday */
    199         return (_days_since_epoch(year, mon, mday) + 4) % 7;
    200 }
    201 
    202 struct _long_tm {
    203         time_t tm_sec;
    204         time_t tm_min;
    205         time_t tm_hour;
    206         time_t tm_mday;
    207         time_t tm_mon;
    208         time_t tm_year;
    209         int tm_wday;
    210         int tm_yday;
    211         int tm_isdst;
    212 };
    213 
    214 /**
    215  *
    216  * @param ltm
    217  * @param ptm
    218  */
    219 static void _posix_to_long_tm(struct _long_tm *ltm, struct posix_tm *ptm)
    220 {
    221         assert(ltm != NULL && ptm != NULL);
    222         ltm->tm_sec = ptm->tm_sec;
    223         ltm->tm_min = ptm->tm_min;
    224         ltm->tm_hour = ptm->tm_hour;
    225         ltm->tm_mday = ptm->tm_mday;
    226         ltm->tm_mon = ptm->tm_mon;
    227         ltm->tm_year = ptm->tm_year;
    228         ltm->tm_wday = ptm->tm_wday;
    229         ltm->tm_yday = ptm->tm_yday;
    230         ltm->tm_isdst = ptm->tm_isdst;
    231 }
    232 
    233 /**
    234  *
    235  * @param ptm
    236  * @param ltm
    237  */
    238 static void _long_to_posix_tm(struct posix_tm *ptm, struct _long_tm *ltm)
    239 {
    240         assert(ltm != NULL && ptm != NULL);
    241         // FIXME: the cast should be unnecessary, libarch/common.h brain-damage
    242         assert((ltm->tm_year >= (int) INT_MIN) && (ltm->tm_year <= (int) INT_MAX));
    243 
    244         ptm->tm_sec = ltm->tm_sec;
    245         ptm->tm_min = ltm->tm_min;
    246         ptm->tm_hour = ltm->tm_hour;
    247         ptm->tm_mday = ltm->tm_mday;
    248         ptm->tm_mon = ltm->tm_mon;
    249         ptm->tm_year = ltm->tm_year;
    250         ptm->tm_wday = ltm->tm_wday;
    251         ptm->tm_yday = ltm->tm_yday;
    252         ptm->tm_isdst = ltm->tm_isdst;
    253 }
    254 
    255 /**
    256  *
    257  * @param tm
    258  */
    259 static void _normalize_time(struct _long_tm *tm)
     213        return _floor_mod((_days_since_epoch(year, mon, mday) + 4), 7);
     214}
     215
     216/** Normalizes the broken-down time and optionally adds specified amount of
     217 *  seconds.
     218 *
     219 * @param tm Broken-down time to normalize.
     220 * @param sec_add Seconds to add.
     221 * @return 0 on success, -1 on overflow
     222 */
     223static int _normalize_time(struct posix_tm *tm, time_t sec_add)
    260224{
    261225        // TODO: DST correction
    262226
     227        /* Set initial values. */
     228        time_t sec = tm->tm_sec + sec_add;
     229        time_t min = tm->tm_min;
     230        time_t hour = tm->tm_hour;
     231        time_t day = tm->tm_mday - 1;
     232        time_t mon = tm->tm_mon;
     233        time_t year = tm->tm_year;
     234
    263235        /* Adjust time. */
    264         tm->tm_min += _floor_div(tm->tm_sec, SECS_PER_MIN);
    265         tm->tm_sec = _floor_mod(tm->tm_sec, SECS_PER_MIN);
    266         tm->tm_hour += _floor_div(tm->tm_min, MINS_PER_HOUR);
    267         tm->tm_min = _floor_mod(tm->tm_min, MINS_PER_HOUR);
    268         tm->tm_mday += _floor_div(tm->tm_hour, HOURS_PER_DAY);
    269         tm->tm_hour = _floor_mod(tm->tm_hour, HOURS_PER_DAY);
     236        min += _floor_div(sec, SECS_PER_MIN);
     237        sec = _floor_mod(sec, SECS_PER_MIN);
     238        hour += _floor_div(min, MINS_PER_HOUR);
     239        min = _floor_mod(min, MINS_PER_HOUR);
     240        day += _floor_div(hour, HOURS_PER_DAY);
     241        hour = _floor_mod(hour, HOURS_PER_DAY);
    270242
    271243        /* Adjust month. */
    272         tm->tm_year += _floor_div(tm->tm_mon, 12);
    273         tm->tm_mon = _floor_mod(tm->tm_mon, 12);
     244        year += _floor_div(mon, 12);
     245        mon = _floor_mod(mon, 12);
    274246
    275247        /* Now the difficult part - days of month. */
    276         /* Slow, but simple. */
    277         // FIXME: do this faster
    278 
    279         while (tm->tm_mday < 1) {
    280                 tm->tm_mon--;
    281                 if (tm->tm_mon == -1) {
    282                         tm->tm_mon = 11;
    283                         tm->tm_year--;
     248       
     249        /* First, deal with whole cycles of 400 years = 146097 days. */
     250        year += _floor_div(day, 146097) * 400;
     251        day = _floor_mod(day, 146097);
     252       
     253        /* Then, go in one year steps. */
     254        if (mon <= 1) {
     255                /* January and February. */
     256                while (day > 365) {
     257                        day -= _is_leap_year(year) ? 366 : 365;
     258                        year++;
    284259                }
    285                
    286                 tm->tm_mday += _days_in_month(tm->tm_year, tm->tm_mon);
    287         }
    288 
    289         while (tm->tm_mday > _days_in_month(tm->tm_year, tm->tm_mon)) {
    290                 tm->tm_mday -= _days_in_month(tm->tm_year, tm->tm_mon);
    291                
    292                 tm->tm_mon++;
    293                 if (tm->tm_mon == 12) {
    294                         tm->tm_mon = 0;
    295                         tm->tm_year++;
     260        } else {
     261                /* Rest of the year. */
     262                while (day > 365) {
     263                        day -= _is_leap_year(year + 1) ? 366 : 365;
     264                        year++;
    296265                }
    297266        }
    298 
     267       
     268        /* Finally, finish it off month per month. */
     269        while (day >= _days_in_month(year, mon)) {
     270                day -= _days_in_month(year, mon);
     271                mon++;
     272                if (mon >= 12) {
     273                        mon -= 12;
     274                        year++;
     275                }
     276        }
     277       
    299278        /* Calculate the remaining two fields. */
    300         tm->tm_yday = _day_of_year(tm->tm_year, tm->tm_mon, tm->tm_mday);
    301         tm->tm_wday = _day_of_week(tm->tm_year, tm->tm_mon, tm->tm_mday);
    302 }
    303 
    304 /**
    305  * Which day the week-based year starts on relative to the first calendar day.
    306  * E.g. if the year starts on December 31st, the return value is -1.
    307  *
    308  * @param year
    309  * @return
     279        tm->tm_yday = _day_of_year(year, mon, day + 1);
     280        tm->tm_wday = _day_of_week(year, mon, day + 1);
     281       
     282        /* And put the values back to the struct. */
     283        tm->tm_sec = (int) sec;
     284        tm->tm_min = (int) min;
     285        tm->tm_hour = (int) hour;
     286        tm->tm_mday = (int) day + 1;
     287        tm->tm_mon = (int) mon;
     288       
     289        /* Casts to work around libc brain-damage. */
     290        if (year > ((int)INT_MAX) || year < ((int)INT_MIN)) {
     291                tm->tm_year = (year < 0) ? ((int)INT_MIN) : ((int)INT_MAX);
     292                return -1;
     293        }
     294       
     295        tm->tm_year = (int) year;
     296        return 0;
     297}
     298
     299/** Which day the week-based year starts on, relative to the first calendar day.
     300 *  E.g. if the year starts on December 31st, the return value is -1.
     301 *
     302 * @param Year since 1900.
     303 * @return Offset of week-based year relative to calendar year.
    310304 */
    311305static int _wbyear_offset(int year)
     
    315309}
    316310
    317 /**
    318  * Returns week-based year of the specified time.
    319  * Assumes normalized broken-down time.
    320  *
    321  * @param tm
    322  * @return
     311/** Returns week-based year of the specified time.
     312 *
     313 * @param tm Normalized broken-down time.
     314 * @return Week-based year.
    323315 */
    324316static int _wbyear(const struct posix_tm *tm)
     
    337329}
    338330
    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.
     331/** Week number of the year, assuming weeks start on sunday.
     332 *  The first Sunday of January is the first day of week 1;
     333 *  days in the new year before this are in week 0.
    343334 *
    344335 * @param tm Normalized broken-down time.
     
    351342}
    352343
    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.
     344/** Week number of the year, assuming weeks start on monday.
     345 *  If the week containing January 1st has four or more days in the new year,
     346 *  then it is considered week 1. Otherwise, it is the last week of the previous
     347 *  year, and the next week is week 1. Both January 4th and the first Thursday
     348 *  of January are always in week 1.
    359349 *
    360350 * @param tm Normalized broken-down time.
     
    376366}
    377367
    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.
     368/** Week number of the year, assuming weeks start on monday.
     369 *  The first Monday of January is the first day of week 1;
     370 *  days in the new year before this are in week 0.
    382371 *
    383372 * @param tm Normalized broken-down time.
     
    396385char *posix_tzname[2];
    397386
    398 /**
     387/** Set timezone conversion information.
    399388 *
    400389 */
     
    408397}
    409398
    410 /**
     399/** Calculate the difference between two times, in seconds.
    411400 *
    412401 * @param time1
    413402 * @param time0
    414  * @return
     403 * @return Time in seconds.
    415404 */
    416405double posix_difftime(time_t time1, time_t time0)
     
    419408}
    420409
    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.
     410/** This function first normalizes the provided broken-down time
     411 *  (moves all values to their proper bounds) and then tries to
     412 *  calculate the appropriate time_t representation.
    425413 *
    426414 * @param tm Broken-down time.
     
    432420        // TODO: detect overflow
    433421
    434         struct _long_tm ltm;
    435         _posix_to_long_tm(&ltm, tm);
    436         _normalize_time(&ltm);
    437         _long_to_posix_tm(tm, &ltm);
    438 
     422        _normalize_time(tm, 0);
    439423        return _secs_since_epoch(tm);
    440424}
    441425
    442 /**
    443  *
    444  * @param timer
    445  * @return
     426/** Converts a time value to a broken-down UTC time.
     427 *
     428 * @param timer Time to convert.
     429 * @return Normalized broken-down time in UTC, NULL on overflow.
    446430 */
    447431struct posix_tm *posix_gmtime(const time_t *timer)
    448432{
     433        assert(timer != NULL);
     434
    449435        static struct posix_tm result;
    450436        return posix_gmtime_r(timer, &result);
    451437}
    452438
    453 /**
    454  *
    455  * @param timer
    456  * @param result
    457  * @return
     439/** Converts a time value to a broken-down UTC time.
     440 *
     441 * @param timer Time to convert.
     442 * @param result Structure to store the result to.
     443 * @return Value of result on success, NULL on overflow.
    458444 */
    459445struct posix_tm *posix_gmtime_r(const time_t *restrict timer,
     
    463449        assert(result != NULL);
    464450
    465         /* Set epoch and seconds to _long_tm struct and normalize to get
    466          * correct values.
    467          */
    468         struct _long_tm ltm = {
    469                 .tm_sec = *timer,
    470                 .tm_min = 0,
    471                 .tm_hour = 0, /* 00:00:xx */
    472                 .tm_mday = 1,
    473                 .tm_mon = 0, /* January 1st */
    474                 .tm_year = 70, /* 1970 */
    475         };
    476         _normalize_time(&ltm);
    477 
    478         if (ltm.tm_year < (int) INT_MIN || ltm.tm_year > (int) INT_MAX) {
     451        /* Set result to epoch. */
     452        result->tm_sec = 0;
     453        result->tm_min = 0;
     454        result->tm_hour = 0;
     455        result->tm_mday = 1;
     456        result->tm_mon = 0;
     457        result->tm_year = 70; /* 1970 */
     458
     459        if (_normalize_time(result, *timer) == -1) {
    479460                errno = EOVERFLOW;
    480461                return NULL;
    481462        }
    482463
    483         _long_to_posix_tm(result, &ltm);
    484464        return result;
    485465}
    486466
    487 /**
    488  *
    489  * @param timer
    490  * @return
     467/** Converts a time value to a broken-down local time.
     468 *
     469 * @param timer Time to convert.
     470 * @return Normalized broken-down time in local timezone, NULL on overflow.
    491471 */
    492472struct posix_tm *posix_localtime(const time_t *timer)
     
    496476}
    497477
    498 /**
    499  *
    500  * @param timer
    501  * @param result
    502  * @return
     478/** Converts a time value to a broken-down local time.
     479 *
     480 * @param timer Time to convert.
     481 * @param result Structure to store the result to.
     482 * @return Value of result on success, NULL on overflow.
    503483 */
    504484struct posix_tm *posix_localtime_r(const time_t *restrict timer,
     
    510490}
    511491
    512 /**
    513  *
    514  * @param timeptr
    515  * @return
     492/** Converts broken-down time to a string in format
     493 *  "Sun Jan 1 00:00:00 1970\n". (Obsolete)
     494 *
     495 * @param timeptr Broken-down time structure.
     496 * @return Pointer to a statically allocated string.
    516497 */
    517498char *posix_asctime(const struct posix_tm *timeptr)
     
    521502}
    522503
    523 /**
    524  *
    525  * @param timeptr
    526  * @param buf
    527  * @return
     504/** Converts broken-down time to a string in format
     505 *  "Sun Jan 1 00:00:00 1970\n". (Obsolete)
     506 *
     507 * @param timeptr Broken-down time structure.
     508 * @param buf Buffer to store string to, must be at least ASCTIME_BUF_LEN
     509 *     bytes long.
     510 * @return Value of buf.
    528511 */
    529512char *posix_asctime_r(const struct posix_tm *restrict timeptr,
     
    551534}
    552535
    553 /**
    554  *
    555  * @param timer
    556  * @return
     536/** Equivalent to asctime(localtime(clock)).
     537 *
     538 * @param timer Time to convert.
     539 * @return Pointer to a statically allocated string holding the date.
    557540 */
    558541char *posix_ctime(const time_t *timer)
     
    565548}
    566549
    567 /**
    568  *
    569  * @param timer
    570  * @param buf
    571  * @return
     550/** Reentrant variant of ctime().
     551 *
     552 * @param timer Time to convert.
     553 * @param buf Buffer to store string to. Must be at least ASCTIME_BUF_LEN
     554 *     bytes long.
     555 * @return Pointer to buf on success, NULL on falure.
    572556 */
    573557char *posix_ctime_r(const time_t *timer, char *buf)
     
    580564}
    581565
    582 /**
    583  *
    584  * @param s
    585  * @param maxsize
    586  * @param format
    587  * @param tm
    588  * @return
     566/** Convert time and date to a string, based on a specified format and
     567 *  current locale.
     568 *
     569 * @param s Buffer to write string to.
     570 * @param maxsize Size of the buffer.
     571 * @param format Format of the output.
     572 * @param tm Broken-down time to format.
     573 * @return Number of bytes written.
    589574 */
    590575size_t posix_strftime(char *restrict s, size_t maxsize,
    591576    const char *restrict format, const struct posix_tm *restrict tm)
    592577{
     578        assert(s != NULL);
     579        assert(format != NULL);
     580        assert(tm != NULL);
     581
    593582        // TODO: use locale
    594583        static const char *wday_abbr[] = {
     
    766755}
    767756
    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
     757/** Get clock resolution. Only CLOCK_REALTIME is supported.
     758 *
     759 * @param clock_id Clock ID.
     760 * @param res Pointer to the variable where the resolution is to be written.
     761 * @return 0 on success, -1 with errno set on failure.
    790762 */
    791763int posix_clock_getres(posix_clockid_t clock_id, struct posix_timespec *res)
     
    804776}
    805777
    806 /**
    807  *
    808  * @param clock_id
    809  * @param tp
     778/** Get time. Only CLOCK_REALTIME is supported.
     779 *
     780 * @param clock_id ID of the clock to query.
     781 * @param tp Pointer to the variable where the time is to be written.
    810782 * @return
    811783 */
     
    828800}
    829801
    830 /**
    831  *
    832  * @param clock_id
    833  * @param tp
    834  * @return
     802/** Set time on a specified clock. As HelenOS doesn't support this yet,
     803 *  this function always fails.
     804 *
     805 * @param clock_id ID of the clock to set.
     806 * @param tp Time to set.
     807 * @return 0 on success, -1 with errno on failure.
    835808 */
    836809int posix_clock_settime(posix_clockid_t clock_id,
     
    852825}
    853826
    854 /**
    855  *
    856  * @param clock_id
    857  * @param flags
    858  * @param rqtp
    859  * @param rmtp
    860  * @return
     827/** Sleep on a specified clock.
     828 *
     829 * @param clock_id ID of the clock to sleep on (only CLOCK_REALTIME supported).
     830 * @param flags Flags (none supported).
     831 * @param rqtp Sleep time.
     832 * @param rmtp Remaining time is written here if sleep is interrupted.
     833 * @return 0 on success, -1 with errno set on failure.
    861834 */
    862835int posix_clock_nanosleep(posix_clockid_t clock_id, int flags,
     
    882855}
    883856
    884 #if 0
    885 
    886 struct __posix_timer {
    887         posix_clockid_t clockid;
    888         struct posix_sigevent evp;
    889 };
    890 
    891 /**
    892  *
    893  * @param clockid
    894  * @param evp
    895  * @param timerid
    896  * @return
    897  */
    898 int posix_timer_create(posix_clockid_t clockid,
    899     struct posix_sigevent *restrict evp,
    900     posix_timer_t *restrict timerid)
    901 {
    902         // TODO
    903         not_implemented();
    904 }
    905 
    906 /**
    907  *
    908  * @param timerid
    909  * @return
    910  */
    911 int posix_timer_delete(posix_timer_t timerid)
    912 {
    913         // TODO
    914         not_implemented();
    915 }
    916 
    917 /**
    918  *
    919  * @param timerid
    920  * @return
    921  */
    922 int posix_timer_getoverrun(posix_timer_t timerid)
    923 {
    924         // TODO
    925         not_implemented();
    926 }
    927 
    928 /**
    929  *
    930  * @param timerid
    931  * @param value
    932  * @return
    933  */
    934 int posix_timer_gettime(posix_timer_t timerid,
    935     struct posix_itimerspec *value)
    936 {
    937         // TODO
    938         not_implemented();
    939 }
    940 
    941 /**
    942  *
    943  * @param timerid
    944  * @param flags
    945  * @param value
    946  * @param ovalue
    947  * @return
    948  */
    949 int posix_timer_settime(posix_timer_t timerid, int flags,
    950     const struct posix_itimerspec *restrict value,
    951     struct posix_itimerspec *restrict ovalue)
    952 {
    953         // TODO
    954         not_implemented();
    955 }
    956 
    957 #endif
    958 
    959 /**
    960  * Get CPU time used since the process invocation.
     857/** Get CPU time used since the process invocation.
    961858 *
    962859 * @return Consumed CPU cycles by this process or -1 if not available.
  • uspace/lib/posix/time.h

    r1b55da67 re6165be  
    119119extern size_t posix_strftime(char *restrict s, size_t maxsize,
    120120    const char *restrict format, const struct posix_tm *restrict tm);
    121 extern size_t posix_strftime_l(char *restrict s, size_t maxsize,
    122     const char *restrict format, const struct posix_tm *restrict tm,
    123     posix_locale_t loc);
    124121
    125122/* Clocks */
     
    132129extern int posix_clock_nanosleep(posix_clockid_t clock_id, int flags,
    133130    const struct posix_timespec *rqtp, struct posix_timespec *rmtp);
    134 
    135 #if 0
    136 
    137 /* Timers */
    138 extern int posix_timer_create(posix_clockid_t clockid,
    139     struct posix_sigevent *restrict evp,
    140     posix_timer_t *restrict timerid);
    141 extern int posix_timer_delete(posix_timer_t timerid);
    142 extern int posix_timer_getoverrun(posix_timer_t timerid);
    143 extern int posix_timer_gettime(posix_timer_t timerid,
    144     struct posix_itimerspec *value);
    145 extern int posix_timer_settime(posix_timer_t timerid, int flags,
    146     const struct posix_itimerspec *restrict value,
    147     struct posix_itimerspec *restrict ovalue);
    148 
    149 #endif
    150131
    151132/* CPU Time */
     
    176157        #define ctime_r posix_ctime_r
    177158        #define strftime posix_strftime
    178         #define strftime_l posix_strftime_l
    179159
    180160        #define clock_getres posix_clock_getres
Note: See TracChangeset for help on using the changeset viewer.