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/locale.h

    rc84f1a4 rfdf97f6  
    3636#define POSIX_LOCALE_H_
    3737
     38#ifndef __POSIX_DEF__
     39#define __POSIX_DEF__(x) x
     40#endif
     41
    3842#ifndef NULL
    3943        #define NULL ((void *) 0)
     
    4246#ifndef __locale_t_defined
    4347        #define __locale_t_defined
    44         typedef struct __posix_locale *posix_locale_t;
     48        typedef struct __posix_locale *__POSIX_DEF__(locale_t);
    4549        #ifndef LIBPOSIX_INTERNAL
    46                 #define locale_t posix_locale_t
     50                #define locale_t __POSIX_DEF__(locale_t)
    4751        #endif
    4852#endif
     
    8286#define LC_GLOBAL_LOCALE NULL
    8387
    84 struct posix_lconv {
     88struct __POSIX_DEF__(lconv) {
    8589        char *currency_symbol;
    8690        char *decimal_point;
     
    109113};
    110114
    111 extern char *posix_setlocale(int category, const char *locale);
    112 extern struct posix_lconv *posix_localeconv(void);
     115extern char *__POSIX_DEF__(setlocale)(int category, const char *locale);
     116extern struct __POSIX_DEF__(lconv) *__POSIX_DEF__(localeconv)(void);
    113117
    114118/* POSIX Extensions */
    115 extern posix_locale_t posix_duplocale(posix_locale_t locobj);
    116 extern void posix_freelocale(posix_locale_t locobj);
    117 extern posix_locale_t posix_newlocale(int category_mask, const char *locale,
    118     posix_locale_t base);
    119 extern posix_locale_t posix_uselocale(posix_locale_t newloc);
     119extern __POSIX_DEF__(locale_t) __POSIX_DEF__(duplocale)(__POSIX_DEF__(locale_t) locobj);
     120extern void __POSIX_DEF__(freelocale)(__POSIX_DEF__(locale_t) locobj);
     121extern __POSIX_DEF__(locale_t) __POSIX_DEF__(newlocale)(int category_mask, const char *locale,
     122    __POSIX_DEF__(locale_t) base);
     123extern __POSIX_DEF__(locale_t) __POSIX_DEF__(uselocale)(__POSIX_DEF__(locale_t) newloc);
    120124
    121 #ifndef LIBPOSIX_INTERNAL
    122         #define lconv posix_lconv
    123 
    124         #define setlocale posix_setlocale
    125         #define localeconv posix_localeconv
    126 
    127         #define newlocale posix_newlocale
    128         #define uselocale posix_uselocale
    129         #define duplocale posix_duplocale
    130         #define freelocale posix_freelocale
    131 #endif
    132125
    133126#endif /* POSIX_LOCALE_H_ */
Note: See TracChangeset for help on using the changeset viewer.