Ignore:
Timestamp:
2013-07-10T08:58:49Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3908355, 4c53333
Parents:
30c1b75 (diff), 98abd40 (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:

Extending POSIX library

Merge from lp:~vojtech-horky/helenos/gcc-port.

This is work-in-progress merge from branch aimed at bringing GCC to run
inside HelenOS.

The most notable change is dealing with the name clashes in libposix and
libc. For ported applications, the libposix headers looks as normal
POSIX headers and there is no need to do preprocessor-based renaming inside
the ported application. The renaming is done inside object files instead.
See revision 1745 in lp:~vojtech-horky/helenos/gcc-port [1] for more
detailed explanation.
The solution is definitely not perfect but shall deal with the naming
conflicts in much safer manner than using the redefines.

There were some other changes as well, mostly small ones.

  • Add some functions, some as ToDo ones (i.e. empty implementation).
  • Add more POSIX headers, split some existing.

[1] http://bazaar.launchpad.net/~vojtech-horky/helenos/gcc-port/revision/1745

File:
1 edited

Legend:

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

    r30c1b75 rc8bb1633  
    3737#define POSIX_TIME_H_
    3838
     39#ifndef __POSIX_DEF__
     40#define __POSIX_DEF__(x) x
     41#endif
     42
    3943#include "sys/types.h"
    4044
     
    4953#ifndef __locale_t_defined
    5054        #define __locale_t_defined
    51         typedef struct __posix_locale *posix_locale_t;
     55        typedef struct __posix_locale *__POSIX_DEF__(locale_t);
    5256        #ifndef LIBPOSIX_INTERNAL
    53                 #define locale_t posix_locale_t
     57                #define locale_t __POSIX_DEF__(locale_t)
    5458        #endif
    5559#endif
    5660
    5761#ifndef POSIX_SIGNAL_H_
    58         struct posix_sigevent;
     62        struct __POSIX_DEF__(sigevent);
    5963        #ifndef LIBPOSIX_INTERNAL
    60                 #define sigevent posix_sigevent
     64                #define sigevent __POSIX_DEF__(sigevent)
    6165        #endif
    6266#endif
    6367
    6468#undef CLOCK_REALTIME
    65 #define CLOCK_REALTIME ((posix_clockid_t) 0)
     69#define CLOCK_REALTIME ((__POSIX_DEF__(clockid_t)) 0)
    6670
    67 struct posix_timespec {
     71struct __POSIX_DEF__(timespec) {
    6872        time_t tv_sec; /* Seconds. */
    6973        long tv_nsec; /* Nanoseconds. */
    7074};
    7175
    72 struct posix_itimerspec {
    73         struct posix_timespec it_interval; /* Timer period. */
    74         struct posix_timespec it_value; /* Timer expiration. */
     76struct __POSIX_DEF__(itimerspec) {
     77        struct __POSIX_DEF__(timespec) it_interval; /* Timer period. */
     78        struct __POSIX_DEF__(timespec) it_value; /* Timer expiration. */
    7579};
    7680
    77 typedef struct __posix_timer *posix_timer_t;
     81typedef struct __posix_timer *__POSIX_DEF__(timer_t);
    7882
    7983/* Timezones */
    80 extern int posix_daylight;
    81 extern long posix_timezone;
    82 extern char *posix_tzname[2];
    83 extern void posix_tzset(void);
     84extern int __POSIX_DEF__(daylight);
     85extern long __POSIX_DEF__(timezone);
     86extern char *__POSIX_DEF__(tzname)[2];
     87extern void __POSIX_DEF__(tzset)(void);
    8488
    8589/* Broken-down Time */
    86 extern struct tm *posix_gmtime_r(const time_t *restrict timer,
     90extern struct tm *__POSIX_DEF__(gmtime_r)(const time_t *restrict timer,
    8791    struct tm *restrict result);
    88 extern struct tm *posix_gmtime(const time_t *restrict timep);
    89 extern struct tm *posix_localtime_r(const time_t *restrict timer,
     92extern struct tm *__POSIX_DEF__(gmtime)(const time_t *restrict timep);
     93extern struct tm *__POSIX_DEF__(localtime_r)(const time_t *restrict timer,
    9094    struct tm *restrict result);
    91 extern struct tm *posix_localtime(const time_t *restrict timep);
     95extern struct tm *__POSIX_DEF__(localtime)(const time_t *restrict timep);
    9296
    9397/* Formatting Calendar Time */
    94 extern char *posix_asctime_r(const struct tm *restrict timeptr,
     98extern char *__POSIX_DEF__(asctime_r)(const struct tm *restrict timeptr,
    9599    char *restrict buf);
    96 extern char *posix_asctime(const struct tm *restrict timeptr);
    97 extern char *posix_ctime_r(const time_t *timer, char *buf);
    98 extern char *posix_ctime(const time_t *timer);
     100extern char *__POSIX_DEF__(asctime)(const struct tm *restrict timeptr);
     101extern char *__POSIX_DEF__(ctime_r)(const time_t *timer, char *buf);
     102extern char *__POSIX_DEF__(ctime)(const time_t *timer);
    99103
    100104/* Clocks */
    101 extern int posix_clock_getres(posix_clockid_t clock_id,
    102     struct posix_timespec *res);
    103 extern int posix_clock_gettime(posix_clockid_t clock_id,
    104     struct posix_timespec *tp);
    105 extern int posix_clock_settime(posix_clockid_t clock_id,
    106     const struct posix_timespec *tp);
    107 extern int posix_clock_nanosleep(posix_clockid_t clock_id, int flags,
    108     const struct posix_timespec *rqtp, struct posix_timespec *rmtp);
     105extern int __POSIX_DEF__(clock_getres)(__POSIX_DEF__(clockid_t) clock_id,
     106    struct __POSIX_DEF__(timespec) *res);
     107extern int __POSIX_DEF__(clock_gettime)(__POSIX_DEF__(clockid_t) clock_id,
     108    struct __POSIX_DEF__(timespec) *tp);
     109extern int __POSIX_DEF__(clock_settime)(__POSIX_DEF__(clockid_t) clock_id,
     110    const struct __POSIX_DEF__(timespec) *tp);
     111extern int __POSIX_DEF__(clock_nanosleep)(__POSIX_DEF__(clockid_t) clock_id, int flags,
     112    const struct __POSIX_DEF__(timespec) *rqtp, struct __POSIX_DEF__(timespec) *rmtp);
    109113
    110114/* CPU Time */
    111 extern posix_clock_t posix_clock(void);
     115extern __POSIX_DEF__(clock_t) __POSIX_DEF__(clock)(void);
    112116
    113 #ifndef LIBPOSIX_INTERNAL
    114         #define timespec    posix_timespec
    115         #define itimerspec  posix_itimerspec
    116         #define timer_t     posix_timer_t
    117 
    118         #define daylight    posix_daylight
    119         #define timezone    posix_timezone
    120         #define tzname      posix_tzname
    121         #define tzset       posix_tzset
    122 
    123         #define gmtime_r    posix_gmtime_r
    124         #define gmtime      posix_gmtime
    125         #define localtime_r posix_localtime_r
    126         #define localtime   posix_localtime
    127 
    128         #define asctime_r   posix_asctime_r
    129         #define asctime     posix_asctime
    130         #define ctime_r     posix_ctime_r
    131         #define ctime       posix_ctime
    132 
    133         #define clock_getres posix_clock_getres
    134         #define clock_gettime posix_clock_gettime
    135         #define clock_settime posix_clock_settime
    136         #define clock_nanosleep posix_clock_nanosleep
    137 
    138         #define clock posix_clock
    139 #endif
    140117
    141118#endif  // POSIX_TIME_H_
Note: See TracChangeset for help on using the changeset viewer.