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

    rc84f1a4 rfdf97f6  
    3636#define POSIX_SIGNAL_H_
    3737
     38#ifndef __POSIX_DEF__
     39#define __POSIX_DEF__(x) x
     40#endif
     41
    3842#include "sys/types.h"
    3943
     
    5155#define SIG_IGN ((void (*)(int)) __posix_ignore_signal_handler)
    5256
    53 typedef int posix_sig_atomic_t;
    54 typedef uint32_t posix_sigset_t;
    55 typedef struct posix_mcontext {
     57typedef int __POSIX_DEF__(sig_atomic_t);
     58typedef uint32_t __POSIX_DEF__(sigset_t);
     59typedef struct __POSIX_DEF__(mcontext) {
    5660        /* must not be empty to avoid compiler warnings (-pedantic) */
    5761        int dummy;
    58 } posix_mcontext_t;
    59 
    60 union posix_sigval {
     62} __POSIX_DEF__(mcontext_t);
     63
     64union __POSIX_DEF__(sigval) {
    6165        int sival_int;
    6266        void *sival_ptr;
    6367};
    6468
    65 struct posix_sigevent {
     69struct __POSIX_DEF__(sigevent) {
    6670        int sigev_notify; /* Notification type. */
    6771        int sigev_signo; /* Signal number. */
    68         union posix_sigval sigev_value; /* Signal value. */
    69         void (*sigev_notify_function)(union posix_sigval); /* Notification function. */
    70         posix_thread_attr_t *sigev_notify_attributes; /* Notification attributes. */
     72        union __POSIX_DEF__(sigval) sigev_value; /* Signal value. */
     73        void (*sigev_notify_function)(union __POSIX_DEF__(sigval)); /* Notification function. */
     74        __POSIX_DEF__(thread_attr_t) *sigev_notify_attributes; /* Notification attributes. */
    7175};
    7276
     
    7781        int si_errno;
    7882
    79         posix_pid_t si_pid;
    80         posix_uid_t si_uid;
     83        __POSIX_DEF__(pid_t) si_pid;
     84        __POSIX_DEF__(uid_t) si_uid;
    8185        void *si_addr;
    8286        int si_status;
     
    8488        long si_band;
    8589
    86         union posix_sigval si_value;
    87 } posix_siginfo_t;
    88 
    89 struct posix_sigaction {
     90        union __POSIX_DEF__(sigval) si_value;
     91} __POSIX_DEF__(siginfo_t);
     92
     93struct __POSIX_DEF__(sigaction) {
    9094        void (*sa_handler)(int);
    91         posix_sigset_t sa_mask;
     95        __POSIX_DEF__(sigset_t) sa_mask;
    9296        int sa_flags;
    93         void (*sa_sigaction)(int, posix_siginfo_t *, void *);
     97        void (*sa_sigaction)(int, __POSIX_DEF__(siginfo_t) *, void *);
    9498};
    9599
     
    98102        size_t ss_size;
    99103        int ss_flags;
    100 } posix_stack_t;
    101 
    102 typedef struct posix_ucontext {
    103         struct posix_ucontext *uc_link;
    104         posix_sigset_t uc_sigmask;
    105         posix_stack_t uc_stack;
    106         posix_mcontext_t uc_mcontext;
    107 } posix_ucontext_t;
    108 
    109 /* Values of posix_sigevent::sigev_notify */
     104} __POSIX_DEF__(stack_t);
     105
     106typedef struct __POSIX_DEF__(ucontext) {
     107        struct __POSIX_DEF__(ucontext) *uc_link;
     108        __POSIX_DEF__(sigset_t) uc_sigmask;
     109        __POSIX_DEF__(stack_t) uc_stack;
     110        __POSIX_DEF__(mcontext_t) uc_mcontext;
     111} __POSIX_DEF__(ucontext_t);
     112
     113/* Values of __POSIX_DEF__(sigevent)::sigev_notify */
    110114#undef SIGEV_NONE
    111115#undef SIGEV_SIGNAL
     
    255259};
    256260
    257 extern int posix_sigaction(int sig, const struct posix_sigaction *restrict act,
    258     struct posix_sigaction *restrict oact);
    259 
    260 extern void (*posix_signal(int sig, void (*func)(int)))(int);
    261 extern int posix_raise(int sig);
    262 extern int posix_kill(posix_pid_t pid, int sig);
    263 extern int posix_killpg(posix_pid_t pid, int sig);
    264 
    265 extern void posix_psiginfo(const posix_siginfo_t *pinfo, const char *message);
    266 extern void posix_psignal(int signum, const char *message);
    267 
    268 extern int posix_sigemptyset(posix_sigset_t *set);
    269 extern int posix_sigfillset(posix_sigset_t *set);
    270 extern int posix_sigaddset(posix_sigset_t *set, int signo);
    271 extern int posix_sigdelset(posix_sigset_t *set, int signo);
    272 extern int posix_sigismember(const posix_sigset_t *set, int signo);
    273 
    274 extern int posix_thread_sigmask(int how, const posix_sigset_t *restrict set,
    275     posix_sigset_t *restrict oset);
    276 extern int posix_sigprocmask(int how, const posix_sigset_t *restrict set,
    277     posix_sigset_t *restrict oset);
    278 
    279 #ifndef LIBPOSIX_INTERNAL
    280         #define sig_atomic_t posix_sig_atomic_t
    281         #define sigset_t posix_sigset_t
    282         #define sigval posix_sigval
    283         #ifndef sigevent
    284                 #define sigevent posix_sigevent
    285         #endif
    286         #define mcontext_t posix_mcontext_t
    287         #define ucontext_t posix_ucontext_t
    288         #define stack_t posix_stack_t
    289         #define siginfo_t posix_siginfo_t
    290 
    291         #define sigaction posix_sigaction
    292 
    293         #define signal posix_signal
    294         #define raise posix_raise
    295         #define kill posix_kill
    296         #define killpg posix_killpg
    297 
    298         #define psiginfo posix_psiginfo
    299         #define psignal posix_psignal
    300 
    301         #define sigemptyset posix_sigemptyset
    302         #define sigfillset posix_sigfillset
    303         #define sigaddset posix_sigaddset
    304         #define sigdelset posix_sigdelset
    305         #define sigismember posix_sigismember
    306 
    307         #define pthread_sigmask posix_thread_sigmask
    308         #define sigprocmask posix_sigprocmask
    309 #endif
     261extern int __POSIX_DEF__(sigaction)(int sig, const struct __POSIX_DEF__(sigaction) *restrict act,
     262    struct __POSIX_DEF__(sigaction) *restrict oact);
     263
     264extern void (*__POSIX_DEF__(signal)(int sig, void (*func)(int)))(int);
     265extern int __POSIX_DEF__(raise)(int sig);
     266extern int __POSIX_DEF__(kill)(__POSIX_DEF__(pid_t) pid, int sig);
     267extern int __POSIX_DEF__(killpg)(__POSIX_DEF__(pid_t) pid, int sig);
     268
     269extern void __POSIX_DEF__(psiginfo)(const __POSIX_DEF__(siginfo_t) *pinfo, const char *message);
     270extern void __POSIX_DEF__(psignal)(int signum, const char *message);
     271
     272extern int __POSIX_DEF__(sigemptyset)(__POSIX_DEF__(sigset_t) *set);
     273extern int __POSIX_DEF__(sigfillset)(__POSIX_DEF__(sigset_t) *set);
     274extern int __POSIX_DEF__(sigaddset)(__POSIX_DEF__(sigset_t) *set, int signo);
     275extern int __POSIX_DEF__(sigdelset)(__POSIX_DEF__(sigset_t) *set, int signo);
     276extern int __POSIX_DEF__(sigismember)(const __POSIX_DEF__(sigset_t) *set, int signo);
     277
     278extern int __POSIX_DEF__(thread_sigmask)(int how, const __POSIX_DEF__(sigset_t) *restrict set,
     279    __POSIX_DEF__(sigset_t) *restrict oset);
     280extern int __POSIX_DEF__(sigprocmask)(int how, const __POSIX_DEF__(sigset_t) *restrict set,
     281    __POSIX_DEF__(sigset_t) *restrict oset);
     282
    310283
    311284#endif /* POSIX_SIGNAL_H_ */
Note: See TracChangeset for help on using the changeset viewer.