Module: xenomai-jki
Branch: for-upstream
Commit: 2d7425ceba5196d13a3edb48faacf66192e80e95
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=2d7425ceba5196d13a3edb48faacf66192e80e95

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Thu Jul 21 12:44:47 2011 +0200

posix: Wrap puts

The compiler uses puts for printing format-free strings. Wrap this
service to avoid user surprises.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 include/posix/stdio.h          |    2 ++
 src/skins/posix/posix.wrappers |    1 +
 src/skins/posix/printf.c       |   11 +++++++++++
 src/skins/posix/wrappers.c     |    6 ++++++
 4 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/posix/stdio.h b/include/posix/stdio.h
index 775742b..e4ad01c 100644
--- a/include/posix/stdio.h
+++ b/include/posix/stdio.h
@@ -19,6 +19,8 @@ int __real_fprintf(FILE *stream, const char *fmt, ...);
 
 int __real_printf(const char *fmt, ...);
 
+int __real_puts(const char *s);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/src/skins/posix/posix.wrappers b/src/skins/posix/posix.wrappers
index 636e6d8..2aa3d33 100644
--- a/src/skins/posix/posix.wrappers
+++ b/src/skins/posix/posix.wrappers
@@ -93,6 +93,7 @@
 --wrap vprintf
 --wrap fprintf
 --wrap printf
+--wrap puts
 --wrap syslog
 --wrap vsyslog
 --wrap malloc
diff --git a/src/skins/posix/printf.c b/src/skins/posix/printf.c
index 5343808..d838b8a 100644
--- a/src/skins/posix/printf.c
+++ b/src/skins/posix/printf.c
@@ -44,6 +44,17 @@ int __wrap_printf(const char *fmt, ...)
        return rc;
 }
 
+int __wrap_puts(const char *s)
+{
+       if (unlikely(xeno_get_current() != XN_NO_HANDLE &&
+                    !(xeno_get_current_mode() & XNRELAX)))
+               return rt_puts(s);
+       else {
+               rt_print_flush_buffers();
+               return puts(s);
+       }
+}
+
 void __wrap_vsyslog(int priority, const char *fmt, va_list ap)
 {
        if (unlikely(xeno_get_current() != XN_NO_HANDLE &&
diff --git a/src/skins/posix/wrappers.c b/src/skins/posix/wrappers.c
index dedf238..8b7a872 100644
--- a/src/skins/posix/wrappers.c
+++ b/src/skins/posix/wrappers.c
@@ -352,6 +352,12 @@ int __real_printf(const char *fmt, ...)
 }
 
 __attribute__ ((weak))
+int __real_puts(const char *s)
+{
+       return puts(s);
+}
+
+__attribute__ ((weak))
 void __real_syslog(int priority, const char *fmt, ...)
 {
        va_list args;


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

Reply via email to