Module: xenomai-head Branch: master Commit: 3b48d91453201a97fcbf690dad41867f69f9d831 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=3b48d91453201a97fcbf690dad41867f69f9d831
Author: Gilles Chanteperdrix <[email protected]> Date: Tue Jun 28 00:35:55 2011 +0200 posix: wrap calls to the rtdk library services --- include/posix/Makefile.am | 2 + include/posix/Makefile.in | 2 + include/posix/stdio.h | 26 ++++++++++++++++++ include/posix/syslog.h | 19 +++++++++++++ src/skins/posix/Makefile.am | 1 + src/skins/posix/Makefile.in | 12 +++++++- src/skins/posix/init.c | 3 ++ src/skins/posix/posix.wrappers | 9 ++++++ src/skins/posix/printf.c | 51 +++++++++++++++++++++++++++++++++++ src/skins/posix/wrappers.c | 57 ++++++++++++++++++++++++++++++++++++++++ 10 files changed, 181 insertions(+), 1 deletions(-) diff --git a/include/posix/Makefile.am b/include/posix/Makefile.am index f58ff8b..9819b2f 100644 --- a/include/posix/Makefile.am +++ b/include/posix/Makefile.am @@ -9,7 +9,9 @@ includesub_HEADERS = \ sched.h \ semaphore.h \ signal.h \ + stdio.h \ syscall.h \ + syslog.h \ time.h \ unistd.h diff --git a/include/posix/Makefile.in b/include/posix/Makefile.in index b7550f2..260f1d3 100644 --- a/include/posix/Makefile.in +++ b/include/posix/Makefile.in @@ -283,7 +283,9 @@ includesub_HEADERS = \ sched.h \ semaphore.h \ signal.h \ + stdio.h \ syscall.h \ + syslog.h \ time.h \ unistd.h diff --git a/include/posix/stdio.h b/include/posix/stdio.h new file mode 100644 index 0000000..15cda57 --- /dev/null +++ b/include/posix/stdio.h @@ -0,0 +1,26 @@ +#ifndef STDIO_H +#define STDIO_H + +#ifndef __KERNEL__ + +#include_next <stdio.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +int __real_vfprintf(FILE *stream, const char *fmt, va_list args); + +int __real_vprintf(const char *fmt, va_list args); + +int __real_fprintf(FILE *stream, const char *fmt, ...); + +int __real_printf(const char *fmt, ...); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* !__KERNEL__ */ + +#endif /* STDIO_H */ diff --git a/include/posix/syslog.h b/include/posix/syslog.h new file mode 100644 index 0000000..f647c89 --- /dev/null +++ b/include/posix/syslog.h @@ -0,0 +1,19 @@ +#ifndef SYSLOG_H +#define SYSLOG_H + +#include <stdarg.h> +#include_next <syslog.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +void __real_syslog(int priority, const char *fmt, ...); + +void __real_vsyslog(int priority, const char *fmt, va_list ap); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SYSLOG_H */ diff --git a/src/skins/posix/Makefile.am b/src/skins/posix/Makefile.am index d6a0912..e1c3f11 100644 --- a/src/skins/posix/Makefile.am +++ b/src/skins/posix/Makefile.am @@ -19,6 +19,7 @@ libpthread_rt_la_SOURCES = \ interrupt.c \ select.c \ rtdm.c \ + printf.c \ wrappers.c libpthread_rt_la_CPPFLAGS = \ diff --git a/src/skins/posix/Makefile.in b/src/skins/posix/Makefile.in index 3ce3825..4403e33 100644 --- a/src/skins/posix/Makefile.in +++ b/src/skins/posix/Makefile.in @@ -82,7 +82,8 @@ am_libpthread_rt_la_OBJECTS = libpthread_rt_la-init.lo \ libpthread_rt_la-cond.lo libpthread_rt_la-mq.lo \ libpthread_rt_la-mutex.lo libpthread_rt_la-shm.lo \ libpthread_rt_la-interrupt.lo libpthread_rt_la-select.lo \ - libpthread_rt_la-rtdm.lo libpthread_rt_la-wrappers.lo + libpthread_rt_la-rtdm.lo libpthread_rt_la-printf.lo \ + libpthread_rt_la-wrappers.lo libpthread_rt_la_OBJECTS = $(am_libpthread_rt_la_OBJECTS) libpthread_rt_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -274,6 +275,7 @@ libpthread_rt_la_SOURCES = \ interrupt.c \ select.c \ rtdm.c \ + printf.c \ wrappers.c libpthread_rt_la_CPPFLAGS = \ @@ -362,6 +364,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpthread_rt_la-interrupt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpthread_rt_la-mq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpthread_rt_la-mutex.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpthread_rt_la-printf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpthread_rt_la-rtdm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpthread_rt_la-select.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpthread_rt_la-semaphore.Plo@am__quote@ @@ -475,6 +478,13 @@ libpthread_rt_la-rtdm.lo: rtdm.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpthread_rt_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpthread_rt_la-rtdm.lo `test -f 'rtdm.c' || echo '$(srcdir)/'`rtdm.c +libpthread_rt_la-printf.lo: printf.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpthread_rt_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpthread_rt_la-printf.lo -MD -MP -MF $(DEPDIR)/libpthread_rt_la-printf.Tpo -c -o libpthread_rt_la-printf.lo `test -f 'printf.c' || echo '$(srcdir)/'`printf.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpthread_rt_la-printf.Tpo $(DEPDIR)/libpthread_rt_la-printf.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='printf.c' object='libpthread_rt_la-printf.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpthread_rt_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpthread_rt_la-printf.lo `test -f 'printf.c' || echo '$(srcdir)/'`printf.c + libpthread_rt_la-wrappers.lo: wrappers.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpthread_rt_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpthread_rt_la-wrappers.lo -MD -MP -MF $(DEPDIR)/libpthread_rt_la-wrappers.Tpo -c -o libpthread_rt_la-wrappers.lo `test -f 'wrappers.c' || echo '$(srcdir)/'`wrappers.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpthread_rt_la-wrappers.Tpo $(DEPDIR)/libpthread_rt_la-wrappers.Plo diff --git a/src/skins/posix/init.c b/src/skins/posix/init.c index 7ef48cf..196e3c3 100644 --- a/src/skins/posix/init.c +++ b/src/skins/posix/init.c @@ -28,6 +28,7 @@ #include <rtdm/syscall.h> #include <asm-generic/bits/sigshadow.h> #include <posix/mutex.h> +#include <rtdk.h> /* asm-generic/bits/bind.h uses the following functions, so we redefine them to be the __real variants */ @@ -52,6 +53,8 @@ void __init_posix_interface(void) #endif /* !CONFIG_XENO_LIBS_DLOPEN */ int muxid, err; + rt_print_auto_init(1); + muxid = xeno_bind_skin(PSE51_SKIN_MAGIC, "POSIX", "xeno_posix"); diff --git a/src/skins/posix/posix.wrappers b/src/skins/posix/posix.wrappers index 776c5d5..636e6d8 100644 --- a/src/skins/posix/posix.wrappers +++ b/src/skins/posix/posix.wrappers @@ -89,3 +89,12 @@ --wrap mmap64 --wrap munmap --wrap select +--wrap vfprintf +--wrap vprintf +--wrap fprintf +--wrap printf +--wrap syslog +--wrap vsyslog +--wrap malloc +--wrap free +--wrap gettimeofday diff --git a/src/skins/posix/printf.c b/src/skins/posix/printf.c new file mode 100644 index 0000000..e778bc7 --- /dev/null +++ b/src/skins/posix/printf.c @@ -0,0 +1,51 @@ +#include <stdio.h> +#include <syslog.h> +#include <rtdk.h> + +int __wrap_vfprintf(FILE *stream, const char *fmt, va_list args) +{ + return rt_vfprintf(stream, fmt, args); +} + +int __wrap_vprintf(const char *fmt, va_list args) +{ + return __wrap_vfprintf(stdout, fmt, args); +} + +int __wrap_fprintf(FILE *stream, const char *fmt, ...) +{ + va_list args; + int rc; + + va_start(args, fmt); + rc = __wrap_vfprintf(stream, fmt, args); + va_end(args); + + return rc; +} + +int __wrap_printf(const char *fmt, ...) +{ + va_list args; + int rc; + + va_start(args, fmt); + rc = __wrap_vfprintf(stdout, fmt, args); + va_end(args); + + return rc; +} + +void __wrap_vsyslog(int priority, const char *fmt, va_list ap) +{ + return rt_vsyslog(priority, fmt, ap); +} + +void __wrap_syslog(int priority, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + __wrap_vsyslog(priority, fmt, args); + va_end(args); +} diff --git a/src/skins/posix/wrappers.c b/src/skins/posix/wrappers.c index a3cc2d8..dedf238 100644 --- a/src/skins/posix/wrappers.c +++ b/src/skins/posix/wrappers.c @@ -20,7 +20,10 @@ * are fallback functions for __real* functions used by the library itself */ +#include <stdio.h> #include <stdarg.h> + +#include <syslog.h> #include <pthread.h> #include <semaphore.h> #include <limits.h> @@ -309,3 +312,57 @@ int __real_select (int __nfds, fd_set *__restrict __readfds, { return select(__nfds, __readfds, __writefds, __exceptfds, __timeout); } + +__attribute__ ((weak)) +int __real_vfprintf(FILE *stream, const char *fmt, va_list args) +{ + return vfprintf(stream, fmt, args); +} + +__attribute__ ((weak)) +int __real_vprintf(const char *fmt, va_list args) +{ + return vprintf(fmt, args); +} + +__attribute__ ((weak)) +int __real_fprintf(FILE *stream, const char *fmt, ...) +{ + va_list args; + int rc; + + va_start(args, fmt); + rc = vfprintf(stream, fmt, args); + va_end(args); + + return rc; +} + +__attribute__ ((weak)) +int __real_printf(const char *fmt, ...) +{ + va_list args; + int rc; + + va_start(args, fmt); + rc = vprintf(fmt, args); + va_end(args); + + return rc; +} + +__attribute__ ((weak)) +void __real_syslog(int priority, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vsyslog(priority, fmt, args); + va_end(args); +} + +__attribute__ ((weak)) +void __real_vsyslog(int priority, const char *fmt, va_list ap) +{ + vsyslog(priority, fmt, ap); +} _______________________________________________ Xenomai-git mailing list [email protected] https://mail.gna.org/listinfo/xenomai-git
