Module: xenomai-3
Branch: next
Commit: a7cf6c90af4c66550281cac019fc3ba97c6f14e6
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a7cf6c90af4c66550281cac019fc3ba97c6f14e6

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Jul 24 16:17:43 2015 +0200

lib/cobalt: move rt_print_auto_init() to the compat API

The reason(s) to delay the automatic initialization of the stdio
support when a Xenomai process starts are all gone now, so no need to
keep the switch routine in the current API. rt_print_auto_init() has
moved to libtrank.

---

 include/cobalt/stdio.h    |    2 --
 include/trank/rtdm/rtdm.h |    5 +++++
 lib/cobalt/printf.c       |   21 +++------------------
 3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h
index b7407fd..6642b40 100644
--- a/include/cobalt/stdio.h
+++ b/include/cobalt/stdio.h
@@ -110,8 +110,6 @@ int rt_print_init(size_t buffer_size, const char *name);
 
 void rt_print_cleanup(void);
 
-void rt_print_auto_init(int enable);
-
 const char *rt_print_buffer_name(void);
 
 void rt_print_flush_buffers(void);
diff --git a/include/trank/rtdm/rtdm.h b/include/trank/rtdm/rtdm.h
index 9a0c965..8e3e125 100644
--- a/include/trank/rtdm/rtdm.h
+++ b/include/trank/rtdm/rtdm.h
@@ -24,6 +24,11 @@
 extern "C" {
 #endif
 
+static inline void rt_print_auto_init(int enable)
+{
+       /* stdio support is automatically enabled by libcobalt. */
+}
+
 #ifndef RTDM_NO_DEFAULT_USER_API
 
 #define rt_dev_call(__call, __args...) \
diff --git a/lib/cobalt/printf.c b/lib/cobalt/printf.c
index 7c9f61b..3381b2a 100644
--- a/lib/cobalt/printf.c
+++ b/lib/cobalt/printf.c
@@ -78,7 +78,6 @@ static struct print_buffer *first_buffer;
 static int buffers;
 static uint32_t seq_no;
 static struct timespec print_period;
-static int auto_init;
 static pthread_mutex_t buffer_lock;
 static pthread_cond_t printer_wakeup;
 static pthread_key_t buffer_key;
@@ -104,12 +103,7 @@ vprint_to_buffer(FILE *stream, int fortify_level, int 
priority,
        int res = 0;
 
        if (!buffer) {
-               res = 0;
-               if (auto_init)
-                       res = rt_print_init(0, NULL);
-               else
-                       res = EIO;
-
+               res = rt_print_init(0, NULL);
                if (res) {
                        errno = res;
                        return -1;
@@ -467,11 +461,6 @@ int rt_print_init(size_t buffer_size, const char 
*buffer_name)
        return 0;
 }
 
-void rt_print_auto_init(int enable)
-{
-       auto_init = enable;
-}
-
 void rt_print_cleanup(void)
 {
        struct print_buffer *buffer = pthread_getspecific(buffer_key);
@@ -492,13 +481,10 @@ void rt_print_cleanup(void)
 const char *rt_print_buffer_name(void)
 {
        struct print_buffer *buffer = pthread_getspecific(buffer_key);
+       int res;
 
        if (!buffer) {
-               int res = -1;
-
-               if (auto_init)
-                       res = rt_print_init(0, NULL);
-
+               res = rt_print_init(0, NULL);
                if (res)
                        return NULL;
 
@@ -784,7 +770,6 @@ void cobalt_print_init(void)
 
        spawn_printer_thread();
 
-       rt_print_auto_init(1);
        atexit(rt_print_flush_buffers);
 }
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to