Changeset 5b3394c in mainline


Ignore:
Timestamp:
2012-04-23T21:54:49Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8219eb9
Parents:
c2b0e10
Message:

libc: move gmtime() from libposix to libc

Location:
uspace/lib
Files:
4 edited

Legend:

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

    rc2b0e10 r5b3394c  
    776776}
    777777
     778struct tm *gmtime(const time_t *timer)
     779{
     780        assert(timer != NULL);
     781
     782        static struct tm result;
     783
     784        /* Set result to epoch. */
     785        result.tm_sec = 0;
     786        result.tm_min = 0;
     787        result.tm_hour = 0;
     788        result.tm_mday = 1;
     789        result.tm_mon = 0;
     790        result.tm_year = 70; /* 1970 */
     791
     792        if (_normalize_time(&result, *timer) == -1) {
     793                errno = EOVERFLOW;
     794                return NULL;
     795        }
     796
     797        return &result;
     798
     799}
     800
    778801
    779802/** @}
  • uspace/lib/c/include/sys/time.h

    rc2b0e10 r5b3394c  
    7777
    7878extern void udelay(useconds_t);
     79
    7980extern time_t mktime(struct tm *tm);
     81extern struct tm *gmtime(const time_t *timer);
    8082extern size_t strftime(char *restrict s, size_t maxsize,
    8183    const char *restrict format, const struct tm *restrict tm);
  • uspace/lib/posix/time.c

    rc2b0e10 r5b3394c  
    324324/**
    325325 * Converts a time value to a broken-down UTC time.
    326  *
    327  * @param timer Time to convert.
    328  * @return Normalized broken-down time in UTC, NULL on overflow.
    329  */
    330 struct tm *posix_gmtime(const time_t *timer)
    331 {
    332         assert(timer != NULL);
    333 
    334         static struct tm result;
    335         return posix_gmtime_r(timer, &result);
    336 }
    337 
    338 /**
    339  * Converts a time value to a broken-down UTC time.
    340326 *
    341327 * @param timer Time to convert.
  • uspace/lib/posix/time.h

    rc2b0e10 r5b3394c  
    9191
    9292/* Broken-down Time */
    93 extern struct tm *posix_gmtime(const time_t *timer);
    9493extern struct tm *posix_gmtime_r(const time_t *restrict timer,
    9594    struct tm *restrict result);
     
    130129        #define difftime posix_difftime
    131130
    132         #define gmtime posix_gmtime
    133131        #define gmtime_r posix_gmtime_r
    134132        #define localtime posix_localtime
Note: See TracChangeset for help on using the changeset viewer.