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

    rc84f1a4 rfdf97f6  
    3737#define POSIX_STRINGS_H_
    3838
     39#ifndef __POSIX_DEF__
     40#define __POSIX_DEF__(x) x
     41#endif
     42
    3943/* Search Functions */
    4044#ifndef POSIX_STRING_H_
    41 extern int posix_ffs(int i);
     45extern int __POSIX_DEF__(ffs)(int i);
    4246#endif
    4347
    4448/* String/Array Comparison */
    4549#ifndef POSIX_STRING_H_
    46 extern int posix_strcasecmp(const char *s1, const char *s2);
    47 extern int posix_strncasecmp(const char *s1, const char *s2, size_t n);
     50extern int __POSIX_DEF__(strcasecmp)(const char *s1, const char *s2);
     51extern int __POSIX_DEF__(strncasecmp)(const char *s1, const char *s2, size_t n);
    4852#endif
    4953
     
    5559
    5660/* Legacy Functions */
    57 extern int posix_bcmp(const void *mem1, const void *mem2, size_t n);
    58 extern void posix_bcopy(const void *src, void *dest, size_t n);
    59 extern void posix_bzero(void *mem, size_t n);
    60 extern char *posix_index(const char *s, int c);
    61 extern char *posix_rindex(const char *s, int c);
     61extern int __POSIX_DEF__(bcmp)(const void *mem1, const void *mem2, size_t n);
     62extern void __POSIX_DEF__(bcopy)(const void *src, void *dest, size_t n);
     63extern void __POSIX_DEF__(bzero)(void *mem, size_t n);
     64extern char *__POSIX_DEF__(index)(const char *s, int c);
     65extern char *__POSIX_DEF__(rindex)(const char *s, int c);
    6266
    63 #ifndef LIBPOSIX_INTERNAL
    64         #define ffs posix_ffs
    65 
    66         #define strcasecmp posix_strcasecmp
    67         #define strncasecmp posix_strncasecmp
    68 
    69         #define bcmp posix_bcmp
    70         #define bcopy posix_bcopy
    71         #undef bzero
    72         #define bzero posix_bzero
    73         #define index posix_index
    74         #define rindex posix_rindex
    75 #endif
    7667
    7768#endif  // POSIX_STRINGS_H_
Note: See TracChangeset for help on using the changeset viewer.