Changeset 2b3dd78 in mainline for uspace/lib/posix/src/time.c


Ignore:
Timestamp:
2018-01-31T12:02:00Z (7 years ago)
Author:
Jenda <jenda.jzqk73@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5595841
Parents:
a0a9cc2 (diff), 14d789c (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.
Message:

Merge remote-tracking branch 'upstream/master' into forwardport

change tmon includes because of new stdlib

File:
1 moved

Legend:

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

    ra0a9cc2 r2b3dd78  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "internal/common.h"
    4037#include "posix/time.h"
     
    7067 * Set timezone conversion information.
    7168 */
    72 void posix_tzset(void)
     69void tzset(void)
    7370{
    7471        // TODO: read environment
     
    8077
    8178/**
    82  * Get the time in seconds
    83  *
    84  * @param t If t is non-NULL, the return value is also stored in the memory
    85  *          pointed to by t.
    86  * @return  On success, the value of time in seconds since the Epoch
    87  *          is returned. On error, (time_t)-1 is returned.
    88  */
    89 time_t posix_time(time_t *t)
    90 {
    91         return time(t);
    92 }
    93 
    94 /**
    9579 * Converts a time value to a broken-down UTC time.
    9680 *
     
    9983 * @return Value of result on success, NULL on overflow.
    10084 */
    101 struct tm *posix_gmtime_r(const time_t *restrict timer,
     85struct tm *gmtime_r(const time_t *restrict timer,
    10286    struct tm *restrict result)
    10387{
     
    117101 *               the result, NULL in case of error.
    118102 */
    119 struct tm *posix_gmtime(const time_t *restrict timep)
     103struct tm *gmtime(const time_t *restrict timep)
    120104{
    121105        static struct tm result;
    122106
    123         return posix_gmtime_r(timep, &result);
     107        return gmtime_r(timep, &result);
    124108}
    125109
     
    131115 * @return Value of result on success, NULL on overflow.
    132116 */
    133 struct tm *posix_localtime_r(const time_t *restrict timer,
     117struct tm *localtime_r(const time_t *restrict timer,
    134118    struct tm *restrict result)
    135119{
    136120        // TODO: deal with timezone
    137121        // currently assumes system and all times are in GMT
    138         return posix_gmtime_r(timer, result);
     122        return gmtime_r(timer, result);
    139123}
    140124
     
    147131 *                 the result, NULL in case of error.
    148132 */
    149 struct tm *posix_localtime(const time_t *restrict timep)
     133struct tm *localtime(const time_t *restrict timep)
    150134{
    151135        static struct tm result;
    152136
    153         return posix_localtime_r(timep, &result);
     137        return localtime_r(timep, &result);
    154138}
    155139
     
    163147 * @return Value of buf.
    164148 */
    165 char *posix_asctime_r(const struct tm *restrict timeptr,
     149char *asctime_r(const struct tm *restrict timeptr,
    166150    char *restrict buf)
    167151{
     
    179163 *                   the result, NULL in case of error.
    180164 */
    181 char *posix_asctime(const struct tm *restrict timeptr)
     165char *asctime(const struct tm *restrict timeptr)
    182166{
    183167        static char buf[ASCTIME_BUF_LEN];
    184168
    185         return posix_asctime_r(timeptr, buf);
     169        return asctime_r(timeptr, buf);
    186170}
    187171
     
    195179 * @return Pointer to buf on success, NULL on failure.
    196180 */
    197 char *posix_ctime_r(const time_t *timer, char *buf)
     181char *ctime_r(const time_t *timer, char *buf)
    198182{
    199183        if (failed(time_local2str(*timer, buf))) {
     
    213197 *                 the result, NULL in case of error.
    214198 */
    215 char *posix_ctime(const time_t *timep)
     199char *ctime(const time_t *timep)
    216200{
    217201        static char buf[ASCTIME_BUF_LEN];
    218202
    219         return posix_ctime_r(timep, buf);
     203        return ctime_r(timep, buf);
    220204}
    221205
     
    227211 * @return 0 on success, -1 with errno set on failure.
    228212 */
    229 int posix_clock_getres(posix_clockid_t clock_id, struct posix_timespec *res)
     213int clock_getres(clockid_t clock_id, struct timespec *res)
    230214{
    231215        assert(res != NULL);
     
    249233 * @return 0 on success, -1 with errno on failure.
    250234 */
    251 int posix_clock_gettime(posix_clockid_t clock_id, struct posix_timespec *tp)
     235int clock_gettime(clockid_t clock_id, struct timespec *tp)
    252236{
    253237        assert(tp != NULL);
     
    275259 * @return 0 on success, -1 with errno on failure.
    276260 */
    277 int posix_clock_settime(posix_clockid_t clock_id,
    278     const struct posix_timespec *tp)
     261int clock_settime(clockid_t clock_id,
     262    const struct timespec *tp)
    279263{
    280264        assert(tp != NULL);
     
    302286 * @return 0 on success, -1 with errno set on failure.
    303287 */
    304 int posix_clock_nanosleep(posix_clockid_t clock_id, int flags,
    305     const struct posix_timespec *rqtp, struct posix_timespec *rmtp)
     288int clock_nanosleep(clockid_t clock_id, int flags,
     289    const struct timespec *rqtp, struct timespec *rmtp)
    306290{
    307291        assert(rqtp != NULL);
     
    329313 * @return Consumed CPU cycles by this process or -1 if not available.
    330314 */
    331 posix_clock_t posix_clock(void)
    332 {
    333         posix_clock_t total_cycles = -1;
     315clock_t clock(void)
     316{
     317        clock_t total_cycles = -1;
    334318        stats_task_t *task_stats = stats_get_task(task_get_id());
    335319        if (task_stats) {
    336                 total_cycles = (posix_clock_t) (task_stats->kcycles +
     320                total_cycles = (clock_t) (task_stats->kcycles +
    337321                    task_stats->ucycles);
    338322                free(task_stats);
Note: See TracChangeset for help on using the changeset viewer.