Module: xenomai-head
Branch: master
Commit: 9ad5e382b06a718d51616576f879d661256d2d8c
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=9ad5e382b06a718d51616576f879d661256d2d8c

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Nov 15 19:21:43 2009 +0100

bind: Replace bind.h with a convenience library.

---

 configure.in                       |    4 +
 include/asm-generic/bits/bind.h    |  301 +---------------------
 include/asm-generic/bits/current.h |    3 +
 src/skins/Makefile.am              |    2 +-
 src/skins/common/Makefile.am       |   12 +
 src/skins/common/Makefile.in       |  495 ++++++++++++++++++++++++++++++++++++
 src/skins/common/bind.c            |   78 ++++++
 src/skins/common/current.c         |   74 ++++++
 src/skins/common/sem_heap.c        |   88 +++++++
 src/skins/common/sem_heap.h        |   12 +
 src/skins/native/Makefile.am       |    2 +
 src/skins/posix/Makefile.am        |    2 +
 src/skins/psos+/Makefile.am        |    2 +
 src/skins/rtai/Makefile.am         |    2 +
 src/skins/rtdm/Makefile.am         |    2 +
 src/skins/uitron/Makefile.am       |    2 +
 src/skins/vrtx/Makefile.am         |    2 +
 src/skins/vxworks/Makefile.am      |    2 +
 18 files changed, 789 insertions(+), 296 deletions(-)

diff --git a/configure.in b/configure.in
index 9cce885..d0d9a1c 100644
--- a/configure.in
+++ b/configure.in
@@ -620,6 +620,8 @@ dnl
 test x$CONFIG_XENO_X86_SEP = xy && AC_DEFINE(CONFIG_XENO_X86_SEP,1,[config])
 test x$CONFIG_SMP = xy && AC_DEFINE(CONFIG_SMP,1,[config])
 test x$CONFIG_XENO_FASTSYNCH = xy && 
AC_DEFINE(CONFIG_XENO_FASTSYNCH,1,[config])
+AM_CONDITIONAL(CONFIG_XENO_FASTSYNCH,[test "$CONFIG_XENO_FASTSYNCH" = y])
+
 test x$CONFIG_X86_TSC = xy && AC_DEFINE(CONFIG_X86_TSC,1,[config])
 test -n "$CONFIG_XENO_ARM_ARCH" && 
AC_DEFINE_UNQUOTED(CONFIG_XENO_ARM_ARCH,$CONFIG_XENO_ARM_ARCH,[config])
 
@@ -628,6 +630,7 @@ test x$CONFIG_XENO_CPU_XSC3 = xy && 
AC_DEFINE(CONFIG_XENO_CPU_XSC3,1,[config])
 test $XNARCH_ARM_TSC_TYPE && 
AC_DEFINE_UNQUOTED(XNARCH_ARM_TSC_TYPE,$XNARCH_ARM_TSC_TYPE,[config])
 test x$CONFIG_XENO_ARM_EABI = xy && AC_DEFINE(CONFIG_XENO_ARM_EABI,1,[config])
 
+
 # Default sampling period (ns) used in various tests
 
AC_DEFINE_UNQUOTED(CONFIG_XENO_DEFAULT_PERIOD,$CONFIG_XENO_DEFAULT_PERIOD,[config])
 
@@ -889,6 +892,7 @@ AC_CONFIG_FILES([ \
        src/Makefile \
        src/rtdk/Makefile \
        src/skins/Makefile \
+       src/skins/common/Makefile \
                src/skins/posix/Makefile \
                src/skins/native/Makefile \
                src/skins/vxworks/Makefile \
diff --git a/include/asm-generic/bits/bind.h b/include/asm-generic/bits/bind.h
index 3684b21..7da2c43 100644
--- a/include/asm-generic/bits/bind.h
+++ b/include/asm-generic/bits/bind.h
@@ -3,320 +3,31 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
 #include <signal.h>
-#include <pthread.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <nucleus/types.h>
-#include <asm/xenomai/syscall.h>
-
-#ifdef HAVE___THREAD
-__thread __attribute__ ((tls_model ("initial-exec"), weak))
-xnhandle_t xeno_current = XN_NO_HANDLE;
-__thread __attribute__ ((tls_model ("initial-exec"), weak))
-unsigned long xeno_current_mode;
-
-static inline void __xeno_set_current(xnhandle_t current)
-{
-       xeno_current = current;
-}
-#else /* !HAVE___THREAD */
-pthread_once_t xeno_init_current_keys_once __attribute__((weak));
-pthread_key_t xeno_current_key __attribute__ ((weak));
-pthread_key_t xeno_current_mode_key __attribute__ ((weak));
-
-static inline void __xeno_set_current(xnhandle_t current)
-{
-       pthread_setspecific(xeno_current_key, (void *)current);
-}
-
-__attribute__ ((weak))
-unsigned long *xeno_init_current_mode(void)
-{
-       unsigned long *mode = malloc(sizeof(unsigned long));
-       pthread_setspecific(xeno_current_mode_key, mode);
-       return mode;
-}
-
-static void cleanup_current_mode(void *ptr)
-{
-       free(ptr);
-}
-
-static void __init_current_keys(void)
-{
-       int err = pthread_key_create(&xeno_current_key, NULL);
-       if (err)
-               goto error_exit;
-
-       err = pthread_key_create(&xeno_current_mode_key, cleanup_current_mode);
-       if (err) {
-         error_exit:
-               fprintf(stderr, "Xenomai: error creating TSD key: %s\n",
-                       strerror(-err));
-               exit(1);
-       }
-}
-
-static __attribute__((constructor))
-void init_current_keys(void)
-{
-       pthread_once(&xeno_init_current_keys_once, __init_current_keys);
-}
-#endif /* !HAVE___THREAD */
-
-__attribute__ ((weak))
-void xeno_set_current(void)
-{
-       xnhandle_t current;
-       int err;
-
-       err = XENOMAI_SYSCALL1(__xn_sys_current, &current);
-       if (err) {
-               fprintf(stderr, "Xenomai: error obtaining handle for current "
-                       "thread: %s\n", strerror(-err));
-               exit(1);
-       }
-       __xeno_set_current(current);
-}
-
-#ifdef CONFIG_XENO_FASTSYNCH
-__attribute__ ((weak))
-unsigned long xeno_sem_heap[2] = { 0, 0 };
-#endif /* CONFIG_XENO_FASTSYNCH */
 
 void xeno_handle_mlock_alert(int sig);
 
-#ifdef CONFIG_XENO_FASTSYNCH
-static void *map_sem_heap(unsigned shared)
-{
-       struct heap_info {
-               void *addr;
-               unsigned size;
-       } hinfo;
-       int fd, err;
-
-#ifndef XENO_WRAPPED_OPEN
-       fd = open("/dev/rtheap", O_RDWR, 0);
-#else /* !XENO_WRAPPED_OPEN */
-       fd = __real_open("/dev/rtheap", O_RDWR, 0);
-#endif /* !XENO_WRAPPED_OPEN */
-       if (fd < 0) {
-               fprintf(stderr, "Xenomai: open: %m\n");
-               return MAP_FAILED;
-       }
-
-       err = XENOMAI_SYSCALL2(__xn_sys_sem_heap, &hinfo, shared);
-       if (err < 0) {
-               fprintf(stderr, "Xenomai: sys_sem_heap: %m\n");
-               return MAP_FAILED;
-       }
-
-       err = ioctl(fd, 0, hinfo.addr);
-       if (err < 0) {
-               fprintf(stderr, "Xenomai: ioctl: %m\n");
-               return MAP_FAILED;
-       }
-
-       hinfo.addr = mmap(NULL, hinfo.size,
-                         PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-       close(fd);
-
-       return hinfo.addr;
-}
-
-static void unmap_sem_heap(unsigned long heap_addr, unsigned shared)
-{
-       struct heap_info {
-               void *addr;
-               unsigned size;
-       } hinfo;
-       int err;
-
-       err = XENOMAI_SYSCALL2(__xn_sys_sem_heap, &hinfo, shared);
-       if (err < 0) {
-               fprintf(stderr, "Xenomai: sys_sem_heap: %m\n");
-               return;
-       }
-
-       munmap((void *) heap_addr, hinfo.size);
-}
-#endif /* CONFIG_XENO_FASTSYNCH */
-
-void __attribute__((weak)) xeno_sigill_handler(int sig)
-{
-       fprintf(stderr, "Xenomai or CONFIG_XENO_OPT_PERVASIVE disabled.\n"
-               "(modprobe xeno_nucleus?)\n");
-       exit(1);
-}
-
-struct xnfeatinfo xeno_featinfo;
+int 
+xeno_bind_skin_opt(unsigned skin_magic, const char *skin, const char *module);
 
-static inline int
+static inline int 
 xeno_bind_skin(unsigned skin_magic, const char *skin, const char *module)
 {
-       sighandler_t old_sigill_handler;
+       int muxid = xeno_bind_skin_opt(skin_magic, skin, module);
        struct sigaction sa;
-       xnfeatinfo_t finfo;
-       int muxid;
-
-       old_sigill_handler = signal(SIGILL, xeno_sigill_handler);
-       if (old_sigill_handler == SIG_ERR) {
-               perror("signal(SIGILL)");
-               exit(1);
-       }
-
-       muxid = XENOMAI_SYSBIND(skin_magic,
-                               XENOMAI_FEAT_DEP, XENOMAI_ABI_REV, &finfo);
-
-       signal(SIGILL, old_sigill_handler);
-
-       switch (muxid) {
-       case -EINVAL:
-
-               fprintf(stderr, "Xenomai: incompatible feature set\n");
-               fprintf(stderr,
-                       "(userland requires \"%s\", kernel provides \"%s\", 
missing=\"%s\").\n",
-                       finfo.feat_man_s, finfo.feat_all_s, finfo.feat_mis_s);
-               exit(1);
-
-       case -ENOEXEC:
-
-               fprintf(stderr, "Xenomai: incompatible ABI revision level\n");
-               fprintf(stderr, "(needed=%lu, current=%lu).\n",
-                       XENOMAI_ABI_REV, finfo.feat_abirev);
-               exit(1);
-
-       case -ENOSYS:
-       case -ESRCH:
 
+       if (muxid == -1) {
                fprintf(stderr,
                        "Xenomai: %s skin or CONFIG_XENO_OPT_PERVASIVE 
disabled.\n"
                        "(modprobe %s?)\n", skin, module);
-               exit(1);
-       }
-
-       if (muxid < 0) {
-               fprintf(stderr, "Xenomai: binding failed: %s.\n",
-                       strerror(-muxid));
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
-#ifdef xeno_arch_features_check
-       xeno_arch_features_check();
-#endif /* xeno_arch_features_check */
-
-       /* Install a SIGXCPU handler to intercept alerts about unlocked
-          process memory. */
-
        sa.sa_handler = &xeno_handle_mlock_alert;
        sigemptyset(&sa.sa_mask);
        sa.sa_flags = 0;
        sigaction(SIGXCPU, &sa, NULL);
 
-#ifdef CONFIG_XENO_FASTSYNCH
-       /* In case we forked, we need to map the new local semaphore heap */
-       if (xeno_sem_heap[0])
-               unmap_sem_heap(xeno_sem_heap[0], 0);
-       xeno_sem_heap[0] = (unsigned long) map_sem_heap(0);
-       if (xeno_sem_heap[0] == (unsigned long) MAP_FAILED) {
-               perror("Xenomai: mmap(local sem heap)");
-               exit(EXIT_FAILURE);
-       }
-
-       /* Even if we forked the global semaphore heap did not change, no need
-         to map it anew */
-       if (!xeno_sem_heap[1]) {
-               xeno_sem_heap[1] = (unsigned long) map_sem_heap(1);
-               if (xeno_sem_heap[1] == (unsigned long) MAP_FAILED) {
-                       perror("Xenomai: mmap(global sem heap)");
-                       exit(EXIT_FAILURE);
-               }
-       }
-#endif /* CONFIG_XENO_FASTSYNCH */
-
-       xeno_featinfo = finfo;
-
-       return muxid;
-}
-
-static inline int
-xeno_bind_skin_opt(unsigned skin_magic, const char *skin, const char *module)
-{
-       sighandler_t old_sigill_handler;
-       xnfeatinfo_t finfo;
-       int muxid;
-
-       old_sigill_handler = signal(SIGILL, xeno_sigill_handler);
-       if (old_sigill_handler == SIG_ERR) {
-               perror("signal(SIGILL)");
-               exit(1);
-       }
-
-       muxid = XENOMAI_SYSBIND(skin_magic,
-                               XENOMAI_FEAT_DEP, XENOMAI_ABI_REV, &finfo);
-
-       signal(SIGILL, old_sigill_handler);
-
-       switch (muxid) {
-       case -EINVAL:
-
-               fprintf(stderr, "Xenomai: incompatible feature set\n");
-               fprintf(stderr,
-                       "(userland requires \"%s\", kernel provides \"%s\", 
missing=\"%s\").\n",
-                       finfo.feat_man_s, finfo.feat_all_s, finfo.feat_mis_s);
-               exit(1);
-
-       case -ENOEXEC:
-
-               fprintf(stderr, "Xenomai: incompatible ABI revision level\n");
-               fprintf(stderr, "(needed=%lu, current=%lu).\n",
-                       XENOMAI_ABI_REV, finfo.feat_abirev);
-               exit(1);
-
-       case -ENOSYS:
-       case -ESRCH:
-
-               return -1;
-       }
-
-       if (muxid < 0) {
-               fprintf(stderr, "Xenomai: binding failed: %s.\n",
-                       strerror(-muxid));
-               exit(1);
-       }
-
-#ifdef xeno_arch_features_check
-       xeno_arch_features_check();
-#endif /* xeno_arch_features_check */
-
-#ifdef CONFIG_XENO_FASTSYNCH
-       /* In case we forked, we need to map the new local semaphore heap */
-       if (xeno_sem_heap[0])
-               unmap_sem_heap(xeno_sem_heap[0], 0);
-       xeno_sem_heap[0] = (unsigned long) map_sem_heap(0);
-       if (xeno_sem_heap[0] == (unsigned long) MAP_FAILED) {
-               perror("Xenomai: mmap(local sem heap)");
-               exit(EXIT_FAILURE);
-       }
-
-       /* Even if we forked the global semaphore heap did not change, no need
-         to map it anew */
-       if (!xeno_sem_heap[1]) {
-               xeno_sem_heap[1] = (unsigned long) map_sem_heap(1);
-               if (xeno_sem_heap[1] == (unsigned long) MAP_FAILED) {
-                       perror("Xenomai: mmap(global sem heap)");
-                       exit(EXIT_FAILURE);
-               }
-       }
-#endif /* CONFIG_XENO_FASTSYNCH */
-
-       xeno_featinfo = finfo;
-
        return muxid;
 }
 
diff --git a/include/asm-generic/bits/current.h 
b/include/asm-generic/bits/current.h
index 5f3378a..0c3166b 100644
--- a/include/asm-generic/bits/current.h
+++ b/include/asm-generic/bits/current.h
@@ -24,6 +24,7 @@ static inline unsigned long *xeno_init_current_mode(void)
        return &xeno_current_mode;
 }
 
+#define xeno_init_current_keys() do { } while (0)
 #else /* ! HAVE___THREAD */
 extern pthread_key_t xeno_current_key;
 extern pthread_key_t xeno_current_mode_key;
@@ -44,6 +45,8 @@ static inline unsigned long xeno_get_current_mode(void)
 }
 
 unsigned long *xeno_init_current_mode(void);
+
+void xeno_init_current_keys(void);
 #endif /* ! HAVE___THREAD */
 
 void xeno_set_current(void);
diff --git a/src/skins/Makefile.am b/src/skins/Makefile.am
index 0847b38..4bb71ce 100644
--- a/src/skins/Makefile.am
+++ b/src/skins/Makefile.am
@@ -1,2 +1,2 @@
 
-SUBDIRS = native posix rtdm vxworks psos+ vrtx rtai uitron
+SUBDIRS = common native posix rtdm vxworks psos+ vrtx rtai uitron
diff --git a/src/skins/common/Makefile.am b/src/skins/common/Makefile.am
new file mode 100644
index 0000000..f846c61
--- /dev/null
+++ b/src/skins/common/Makefile.am
@@ -0,0 +1,12 @@
+noinst_LTLIBRARIES = libxeno_common.la
+noinst_HEADERS = sem_heap.h
+
+libxeno_common_la_SOURCES = bind.c current.c
+
+if CONFIG_XENO_FASTSYNCH
+libxeno_common_la_SOURCES += sem_heap.c
+endif
+
+libxeno_common_la_CPPFLAGS = \
+       @XENO_USER_CFLAGS@ \
+       -I$(top_srcdir)/include
diff --git a/src/skins/common/Makefile.in b/src/skins/common/Makefile.in
new file mode 100644
index 0000000..f8c100f
--- /dev/null
+++ b/src/skins/common/Makefile.in
@@ -0,0 +1,495 @@
+# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+...@set_make@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+...@config_xeno_fastsynch_true@am__append_1 = sem_heap.c
+subdir = src/skins/common
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/config/ac_prog_cc_for_build.m4 \
+       $(top_srcdir)/config/docbook.m4 \
+       $(top_srcdir)/config/libtool.m4 \
+       $(top_srcdir)/config/ltoptions.m4 \
+       $(top_srcdir)/config/ltsugar.m4 \
+       $(top_srcdir)/config/ltversion.m4 \
+       $(top_srcdir)/config/lt~obsolete.m4 \
+       $(top_srcdir)/config/version $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/include/xeno_config.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libxeno_common_la_LIBADD =
+am__libxeno_common_la_SOURCES_DIST = bind.c current.c sem_heap.c
+...@config_xeno_fastsynch_true@am__objects_1 = sem_heap.lo
+am_libxeno_common_la_OBJECTS = bind.lo current.lo $(am__objects_1)
+libxeno_common_la_OBJECTS = $(am_libxeno_common_la_OBJECTS)
+DEFAULT_INCLUDES = -...@am__isrc@ -I$(top_builddir)/src/include
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+       $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(libxeno_common_la_SOURCES)
+DIST_SOURCES = $(am__libxeno_common_la_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADEOS_PATCH = @ADEOS_PATCH@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_EXEEXT = @BUILD_EXEEXT@
+BUILD_OBJEXT = @BUILD_OBJEXT@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+CFLAGS = @CFLAGS@
+CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CONFIG_STATUS_DEPENDENCIES = @CONFIG_STATUS_DEPENDENCIES@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
+CPP_FOR_BUILD = @CPP_FOR_BUILD@
+CYGPATH_W = @CYGPATH_W@
+DBX_DOC_ROOT = @DBX_DOC_ROOT@
+DBX_FOP = @DBX_FOP@
+DBX_GEN_DOC_ROOT = @DBX_GEN_DOC_ROOT@
+DBX_LINT = @DBX_LINT@
+DBX_MAYBE_NONET = @DBX_MAYBE_NONET@
+DBX_ROOT = @DBX_ROOT@
+DBX_XSLTPROC = @DBX_XSLTPROC@
+DBX_XSL_ROOT = @DBX_XSL_ROOT@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DOXYGEN = @DOXYGEN@
+DOXYGEN_HAVE_DOT = @DOXYGEN_HAVE_DOT@
+DOXYGEN_SHOW_INCLUDE_FILES = @DOXYGEN_SHOW_INCLUDE_FILES@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LATEX_BATCHMODE = @LATEX_BATCHMODE@
+LATEX_MODE = @LATEX_MODE@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LD_FILE_OPTION = @LD_FILE_OPTION@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LNDIR = @LNDIR@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XENO_BUILD_STRING = @XENO_BUILD_STRING@
+XENO_DLOPEN_CONSTRAINT = @XENO_DLOPEN_CONSTRAINT@
+XENO_HOST_STRING = @XENO_HOST_STRING@
+XENO_LINUX_ALL_TARGETS = @XENO_LINUX_ALL_TARGETS@
+XENO_LINUX_ARCH = @XENO_LINUX_ARCH@
+XENO_LINUX_IMAGE = @XENO_LINUX_IMAGE@
+XENO_LINUX_INSTALL_TARGET = @XENO_LINUX_INSTALL_TARGET@
+XENO_MAYBE_DOCDIR = @XENO_MAYBE_DOCDIR@
+XENO_POSIX_WRAPPERS = @XENO_POSIX_WRAPPERS@
+XENO_TARGET_ARCH = @XENO_TARGET_ARCH@
+XENO_USER_APP_CFLAGS = @XENO_USER_APP_CFLAGS@
+XENO_USER_APP_LDFLAGS = @XENO_USER_APP_LDFLAGS@
+XENO_USER_CFLAGS = @XENO_USER_CFLAGS@
+XENO_USER_LDFLAGS = @XENO_USER_LDFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = libxeno_common.la
+libxeno_common_la_SOURCES = bind.c current.c $(am__append_1)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  
$(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  
src/skins/common/Makefile'; \
+       cd $(top_srcdir) && \
+         $(AUTOMAKE) --foreign  src/skins/common/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 
$(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ 
$(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure 
$(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+libxeno_common.la: $(libxeno_common_la_OBJECTS) 
$(libxeno_common_la_DEPENDENCIES) 
+       $(LINK)  $(libxeno_common_la_OBJECTS) $(libxeno_common_la_LIBADD) 
$(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+...@amdep_true@@am__include@ @am__qu...@./$(DEPDIR)/bind....@am__quote@
+...@amdep_true@@am__include@ @am__qu...@./$(DEPDIR)/current....@am__quote@
+...@amdep_true@@am__include@ @am__qu...@./$(DEPDIR)/sem_heap....@am__quote@
+
+.c.o:
+...@am__fastdepcc_true@        $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo 
-c -o $@ $<
+...@am__fastdepcc_true@        mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+...@amdep_true@@am__fastdepCC_FALSE@   source='$<' object='$@' libtool=no 
@AMDEPBACKSLASH@
+...@amdep_true@@am__fastdepCC_FALSE@   DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+...@am__fastdepcc_false@       $(COMPILE) -c $<
+
+.c.obj:
+...@am__fastdepcc_true@        $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo 
-c -o $@ `$(CYGPATH_W) '$<'`
+...@am__fastdepcc_true@        mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+...@amdep_true@@am__fastdepCC_FALSE@   source='$<' object='$@' libtool=no 
@AMDEPBACKSLASH@
+...@amdep_true@@am__fastdepCC_FALSE@   DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+...@am__fastdepcc_false@       $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+...@am__fastdepcc_true@        $(LTCOMPILE) -MT $@ -MD -MP -MF 
$(DEPDIR)/$*.Tpo -c -o $@ $<
+...@am__fastdepcc_true@        mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+...@amdep_true@@am__fastdepCC_FALSE@   source='$<' object='$@' libtool=yes 
@AMDEPBACKSLASH@
+...@amdep_true@@am__fastdepCC_FALSE@   DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+...@am__fastdepcc_false@       $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+           $$tags $$unique; \
+       fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       tags=; \
+       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       unique=`for i in $$list; do \
+           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+         done | \
+         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$tags$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$tags $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && cd $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+           fi; \
+           cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+         else \
+           test -f $(distdir)/$$file \
+           || cp -p $$d/$$file $(distdir)/$$file \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         `test -z '$(STRIP)' || \
+           echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+       distclean-compile distclean-generic distclean-libtool \
+       distclean-tags distdir dvi dvi-am html html-am info info-am \
+       install install-am install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-html \
+       install-html-am install-info install-info-am install-man \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip installcheck installcheck-am installdirs \
+       maintainer-clean maintainer-clean-generic mostlyclean \
+       mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+       pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/skins/common/bind.c b/src/skins/common/bind.c
new file mode 100644
index 0000000..1315840
--- /dev/null
+++ b/src/skins/common/bind.c
@@ -0,0 +1,78 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+#include <errno.h>
+
+#include <asm/xenomai/syscall.h>
+#include <asm-generic/xenomai/bits/bind.h>
+#include <asm-generic/xenomai/bits/current.h>
+#include "sem_heap.h"
+
+void __attribute__((weak)) xeno_sigill_handler(int sig)
+{
+       fprintf(stderr, "Xenomai or CONFIG_XENO_OPT_PERVASIVE disabled.\n"
+               "(modprobe xeno_nucleus?)\n");
+       exit(EXIT_FAILURE);
+}
+
+struct xnfeatinfo xeno_featinfo;
+
+int 
+xeno_bind_skin_opt(unsigned skin_magic, const char *skin, const char *module)
+{
+       sighandler_t old_sigill_handler;
+       xnfeatinfo_t finfo;
+       int muxid;
+
+       old_sigill_handler = signal(SIGILL, xeno_sigill_handler);
+       if (old_sigill_handler == SIG_ERR) {
+               perror("signal(SIGILL)");
+               exit(EXIT_FAILURE);
+       }
+
+       muxid = XENOMAI_SYSBIND(skin_magic,
+                               XENOMAI_FEAT_DEP, XENOMAI_ABI_REV, &finfo);
+
+       signal(SIGILL, old_sigill_handler);
+
+       switch (muxid) {
+       case -EINVAL:
+
+               fprintf(stderr, "Xenomai: incompatible feature set\n");
+               fprintf(stderr,
+                       "(userland requires \"%s\", kernel provides \"%s\", 
missing=\"%s\").\n",
+                       finfo.feat_man_s, finfo.feat_all_s, finfo.feat_mis_s);
+               exit(EXIT_FAILURE);
+
+       case -ENOEXEC:
+
+               fprintf(stderr, "Xenomai: incompatible ABI revision level\n");
+               fprintf(stderr, "(needed=%lu, current=%lu).\n",
+                       XENOMAI_ABI_REV, finfo.feat_abirev);
+               exit(EXIT_FAILURE);
+
+       case -ENOSYS:
+       case -ESRCH:
+
+               return -1;
+       }
+
+       if (muxid < 0) {
+               fprintf(stderr, "Xenomai: binding failed: %s.\n",
+                       strerror(-muxid));
+               exit(EXIT_FAILURE);
+       }
+
+#ifdef xeno_arch_features_check
+       xeno_arch_features_check();
+#endif /* xeno_arch_features_check */
+
+       xeno_init_sem_heaps();
+
+       xeno_init_current_keys();
+
+       xeno_featinfo = finfo;
+
+       return muxid;
+}
diff --git a/src/skins/common/current.c b/src/skins/common/current.c
new file mode 100644
index 0000000..a371cab
--- /dev/null
+++ b/src/skins/common/current.c
@@ -0,0 +1,74 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <asm/xenomai/syscall.h>
+#include <nucleus/types.h>
+
+#ifdef HAVE___THREAD
+__thread __attribute__ ((tls_model ("initial-exec"), weak))
+xnhandle_t xeno_current = XN_NO_HANDLE;
+__thread __attribute__ ((tls_model ("initial-exec"), weak))
+unsigned long xeno_current_mode;
+
+static inline void __xeno_set_current(xnhandle_t current)
+{
+       xeno_current = current;
+}
+#else /* !HAVE___THREAD */
+#include <pthread.h>
+
+pthread_once_t xeno_init_current_keys_once __attribute__((weak));
+pthread_key_t xeno_current_key __attribute__ ((weak));
+pthread_key_t xeno_current_mode_key __attribute__ ((weak));
+
+static inline void __xeno_set_current(xnhandle_t current)
+{
+       pthread_setspecific(xeno_current_key, (void *)current);
+}
+
+__attribute__ ((weak))
+unsigned long *xeno_init_current_mode(void)
+{
+       unsigned long *mode = malloc(sizeof(unsigned long));
+       pthread_setspecific(xeno_current_mode_key, mode);
+       return mode;
+}
+
+__attribute__ ((weak)) 
+void init_current_keys(void)
+{
+       int err = pthread_key_create(&xeno_current_key, NULL);
+       if (err)
+               goto error_exit;
+
+       err = pthread_key_create(&xeno_current_mode_key, free);
+       if (err) {
+         error_exit:
+               fprintf(stderr, "Xenomai: error creating TSD key: %s\n",
+                       strerror(err));
+               exit(EXIT_FAILURE);
+       }
+}
+
+__attribute__ ((weak))
+void xeno_init_current_keys(void)
+{
+       pthread_once(&xeno_init_current_keys_once, init_current_keys);
+}
+#endif /* !HAVE___THREAD */
+
+__attribute__ ((weak))
+void xeno_set_current(void)
+{
+       xnhandle_t current;
+       int err;
+
+       err = XENOMAI_SYSCALL1(__xn_sys_current, &current);
+       if (err) {
+               fprintf(stderr, "Xenomai: error obtaining handle for current "
+                       "thread: %s\n", strerror(-err));
+               exit(EXIT_FAILURE);
+       }
+       __xeno_set_current(current);
+}
diff --git a/src/skins/common/sem_heap.c b/src/skins/common/sem_heap.c
new file mode 100644
index 0000000..89f325a
--- /dev/null
+++ b/src/skins/common/sem_heap.c
@@ -0,0 +1,88 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+#include <asm/xenomai/syscall.h>
+
+#include "sem_heap.h"
+
+__attribute__ ((weak))
+unsigned long xeno_sem_heap[2] = { 0, 0 };
+
+static void *map_sem_heap(unsigned shared)
+{
+       struct heap_info {
+               void *addr;
+               unsigned size;
+       } hinfo;
+       int fd, err;
+
+       fd = open("/dev/rtheap", O_RDWR, 0);
+       if (fd < 0) {
+               fprintf(stderr, "Xenomai: open: %m\n");
+               return MAP_FAILED;
+       }
+
+       err = XENOMAI_SYSCALL2(__xn_sys_sem_heap, &hinfo, shared);
+       if (err < 0) {
+               fprintf(stderr, "Xenomai: sys_sem_heap: %m\n");
+               return MAP_FAILED;
+       }
+
+       err = ioctl(fd, 0, hinfo.addr);
+       if (err < 0) {
+               fprintf(stderr, "Xenomai: ioctl: %m\n");
+               return MAP_FAILED;
+       }
+
+       hinfo.addr = mmap(NULL, hinfo.size,
+                         PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+       close(fd);
+
+       return hinfo.addr;
+}
+
+static void unmap_sem_heap(unsigned long heap_addr, unsigned shared)
+{
+       struct heap_info {
+               void *addr;
+               unsigned size;
+       } hinfo;
+       int err;
+
+       err = XENOMAI_SYSCALL2(__xn_sys_sem_heap, &hinfo, shared);
+       if (err < 0) {
+               fprintf(stderr, "Xenomai: sys_sem_heap: %m\n");
+               return;
+       }
+
+       munmap((void *) heap_addr, hinfo.size);
+}
+
+void xeno_init_sem_heaps(void)
+{
+       /* In case we forked, we need to map the new local semaphore heap */
+       if (xeno_sem_heap[0])
+               unmap_sem_heap(xeno_sem_heap[0], 0);
+       xeno_sem_heap[0] = (unsigned long) map_sem_heap(0);
+       if (xeno_sem_heap[0] == (unsigned long) MAP_FAILED) {
+               perror("Xenomai: mmap(local sem heap)");
+               exit(EXIT_FAILURE);
+       }
+
+       /* Even if we forked the global semaphore heap did not change, no need
+         to map it anew */
+       if (!xeno_sem_heap[1]) {
+               xeno_sem_heap[1] = (unsigned long) map_sem_heap(1);
+               if (xeno_sem_heap[1] == (unsigned long) MAP_FAILED) {
+                       perror("Xenomai: mmap(global sem heap)");
+                       exit(EXIT_FAILURE);
+               }
+       }
+}
diff --git a/src/skins/common/sem_heap.h b/src/skins/common/sem_heap.h
new file mode 100644
index 0000000..d799a37
--- /dev/null
+++ b/src/skins/common/sem_heap.h
@@ -0,0 +1,12 @@
+#ifndef XENO_SEM_HEAP_H
+#define XENO_SEM_HEAP_H
+
+#include <xeno_config.h>
+
+#ifdef CONFIG_XENO_FASTSYNCH
+void xeno_init_sem_heaps(void);
+#else /* !CONFIG_XENO_FASTSYNCH */
+#define xeno_init_sem_heaps()
+#endif /* !CONFIG_XENO_FASTSYNCH */
+
+#endif /* XENO_SEM_HEAP_H */
diff --git a/src/skins/native/Makefile.am b/src/skins/native/Makefile.am
index 3497f90..9778465 100644
--- a/src/skins/native/Makefile.am
+++ b/src/skins/native/Makefile.am
@@ -23,3 +23,5 @@ libnative_la_SOURCES = \
 libnative_la_CPPFLAGS = \
        @XENO_USER_CFLAGS@ \
        -I$(top_srcdir)/include
+
+libnative_la_LIBADD = ../common/libxeno_common.la
diff --git a/src/skins/posix/Makefile.am b/src/skins/posix/Makefile.am
index d6a0912..e912d9c 100644
--- a/src/skins/posix/Makefile.am
+++ b/src/skins/posix/Makefile.am
@@ -26,6 +26,8 @@ libpthread_rt_la_CPPFLAGS = \
        -I$(top_srcdir)/include \
        -I$(top_srcdir)/include/posix
 
+libpthread_rt_la_LIBADD = ../common/libxeno_common.la
+
 install-data-local:
        $(mkinstalldirs) $(DESTDIR)$(libdir)
        $(INSTALL_DATA) $(srcdir)/posix.wrappers $(DESTDIR)$(libdir)
diff --git a/src/skins/psos+/Makefile.am b/src/skins/psos+/Makefile.am
index 3e4464d..a4f75b5 100644
--- a/src/skins/psos+/Makefile.am
+++ b/src/skins/psos+/Makefile.am
@@ -14,3 +14,5 @@ libpsos_la_SOURCES = \
 libpsos_la_CPPFLAGS = \
        @XENO_USER_CFLAGS@ \
        -I$(top_srcdir)/include
+
+libpsos_la_LIBADD = ../common/libxeno_common.la
diff --git a/src/skins/rtai/Makefile.am b/src/skins/rtai/Makefile.am
index bae83c1..ba2532f 100644
--- a/src/skins/rtai/Makefile.am
+++ b/src/skins/rtai/Makefile.am
@@ -8,3 +8,5 @@ librtai_la_SOURCES = init.c \
 librtai_la_CPPFLAGS = \
        @XENO_USER_CFLAGS@ \
        -I$(top_srcdir)/include
+
+librtai_la_LIBADD = ../common/libxeno_common.la
diff --git a/src/skins/rtdm/Makefile.am b/src/skins/rtdm/Makefile.am
index 73f97cf..5daed5e 100644
--- a/src/skins/rtdm/Makefile.am
+++ b/src/skins/rtdm/Makefile.am
@@ -9,3 +9,5 @@ librtdm_la_SOURCES = \
 librtdm_la_CPPFLAGS = \
        @XENO_USER_CFLAGS@ \
        -I$(top_srcdir)/include
+
+librtdm_la_LIBADD = ../common/libxeno_common.la
diff --git a/src/skins/uitron/Makefile.am b/src/skins/uitron/Makefile.am
index a7ff65a..3f263ed 100644
--- a/src/skins/uitron/Makefile.am
+++ b/src/skins/uitron/Makefile.am
@@ -12,3 +12,5 @@ libuitron_la_SOURCES = \
 libuitron_la_CPPFLAGS = \
        @XENO_USER_CFLAGS@ \
        -I$(top_srcdir)/include
+
+libuitron_la_LIBADD = ../common/libxeno_common.la
diff --git a/src/skins/vrtx/Makefile.am b/src/skins/vrtx/Makefile.am
index 11c218d..871ae2e 100644
--- a/src/skins/vrtx/Makefile.am
+++ b/src/skins/vrtx/Makefile.am
@@ -19,3 +19,5 @@ libvrtx_la_SOURCES = \
 libvrtx_la_CPPFLAGS = \
        @XENO_USER_CFLAGS@ \
        -I$(top_srcdir)/include
+
+libvrtx_la_LIBADD = ../common/libxeno_common.la
diff --git a/src/skins/vxworks/Makefile.am b/src/skins/vxworks/Makefile.am
index b7b74e6..0e84717 100644
--- a/src/skins/vxworks/Makefile.am
+++ b/src/skins/vxworks/Makefile.am
@@ -20,3 +20,5 @@ libvxworks_la_SOURCES = \
 libvxworks_la_CPPFLAGS = \
        @XENO_USER_CFLAGS@ \
        -I$(top_srcdir)/include
+
+libvxworks_la_LIBADD = ../common/libxeno_common.la


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to