Ignore:
Timestamp:
2013-02-25T19:11:50Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1935591
Parents:
c84f1a4
Message:

Libposix functions are without posix_ prefix

Prior this commit, libposix headers declared all functions as posix_*
and used macros to rename e.g. strncpy to posix_strncpy in all (ported)
sources.

After this change, libposix headers look as normal POSIX compliant headers
(well, almost) and no renaming is done in the source codei (of the ported
applications). Instead, the renaming is done at object files level to
bypass weird problems that are bound to happen if you use macros.

The scheme is following. libposix headers use special macro to declare
the names. When included from outside, the functions have their normal
(standard) names. When included from the libposix sources, posix_ prefix
is added. Thus, when libposix is compiled and linked, it contains the
posix_* naming while compiling of ported software uses the normal
non-prefixed versions. This way the posix_* can use HelenOS libc without
any problem. Before linking, the posix_* prefix is removed from all
symbols and special prefix helenos_libc_ is added to all functions
that exists in our (HelenOS) libc and its name clashes with the POSIX
one.

The following happens, for example, to the open() function that exists in
both libposix and in libc.

  • Headers and sources of libc are left intact.
  • Copy of libc.a is made and to all clashing functions is added the helenos_libc prefix. This library is called libc4posix.a.
  • POSIX_DEF(open)(const char *) is used in libposix headers. This macro expands to plain open when included from the "outside world". But it expands to posix_open when included from libposix sources.
  • Libposix is compiled and linked, containing posix_open() that internally calls open() [the original one from libc].
  • Libposix is transformed - all open() are replaced with prefix variant: helenos_libc_open() and all posix_open() are replaced with open(). The transformed library is stored as libposixaslibc.a

Binutils and PCC are then linked with libc4posix and libposixaslibc
libraries instead of libc and libposix as was done previously.

WARNING: it looks that binutils, PCC and MSIM still works but not all
architectures were tested.

File:
1 edited

Legend:

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

    rc84f1a4 rfdf97f6  
    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.