Changeset 324d46b in mainline for uspace/lib/posix/time.h


Ignore:
Timestamp:
2011-07-07T01:32:53Z (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:
3f466c33
Parents:
08053f7
Message:

Partial time.h implementation (WIP, untested)

File:
1 edited

Legend:

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

    r08053f7 r324d46b  
    3838
    3939#include "libc/time.h"
     40#include "sys/types.h"
    4041
    4142#ifndef NULL
     
    4344#endif
    4445
    45 #undef CLOCKS_PER_SEC
    46 #define CLOCKS_PER_SEC 1000000L
     46#ifndef CLOCKS_PER_SEC
     47        #define CLOCKS_PER_SEC (1000000L)
     48#endif
     49
     50#ifndef __locale_t_defined
     51        #define __locale_t_defined
     52        typedef struct __posix_locale *posix_locale_t;
     53        #ifndef LIBPOSIX_INTERNAL
     54                #define locale_t posix_locale_t
     55        #endif
     56#endif
     57
     58#undef ASCTIME_BUF_LEN
     59#define ASCTIME_BUF_LEN 26
     60
     61#undef CLOCK_REALTIME
     62#define CLOCK_REALTIME ((posix_clockid_t) 0)
    4763
    4864struct posix_tm {
     
    5874};
    5975
     76// FIXME: should be in sys/types.h
    6077typedef long posix_clock_t;
    6178
     79struct posix_timespec {
     80        time_t tv_sec; /* Seconds. */
     81        long tv_nsec; /* Nanoseconds. */
     82};
     83
     84struct posix_itimerspec {
     85        struct posix_timespec it_interval; /* Timer period. */
     86        struct posix_timespec it_value; /* Timer expiration. */
     87};
     88
     89/* Timezones */
     90
     91extern int posix_daylight;
     92extern long posix_timezone;
     93extern char *posix_tzname[2];
     94
     95extern void posix_tzset(void);
     96
     97/* time_t */
     98
     99extern double posix_difftime(time_t time1, time_t time0);
     100
    62101/* Broken-down Time */
     102extern time_t posix_mktime(struct posix_tm *timeptr);
    63103extern struct posix_tm *posix_localtime(const time_t *timep);
    64 
     104extern struct posix_tm *posix_localtime_r(const time_t *restrict timer,
     105    struct posix_tm *restrict result);
    65106/* Formatting Calendar Time */
    66 extern char *posix_asctime(const struct posix_tm *tm);
     107extern char *posix_asctime(const struct posix_tm *timeptr);
     108extern char *posix_asctime_r(const struct posix_tm *restrict timeptr,
     109    char *restrict buf);
    67110extern char *posix_ctime(const time_t *timep);
    68 extern size_t posix_strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct posix_tm *restrict tm);
     111extern size_t posix_strftime(char *restrict s, size_t maxsize,
     112    const char *restrict format, const struct posix_tm *restrict tm);
    69113
    70114/* CPU Time */
    71115extern posix_clock_t posix_clock(void);
     116
    72117
    73118#ifndef LIBPOSIX_INTERNAL
     
    75120
    76121        #define clock_t posix_clock_t
     122        #define timespec posix_timespec
     123        #define itimerspec posix_itimerspec
    77124
     125        #define difftime posix_difftime
     126        #define mktime posix_mktime
    78127        #define localtime posix_localtime
     128        #define localtime_r posix_localtime_r
     129
     130        #define daylight posix_daylight
     131        #define timezone posix_timezone
     132        #define tzname posix_tzname
     133        #define tzset posix_tzset
    79134
    80135        #define asctime posix_asctime
     136        #define asctime_r posix_asctime_r
    81137        #define ctime posix_ctime
    82138        #define strftime posix_strftime
Note: See TracChangeset for help on using the changeset viewer.