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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Jun 28 11:06:11 2014 +0200

include/cobalt: export public inner calls

---

 include/cobalt/Makefile.am |    1 +
 include/cobalt/Makefile.in |    1 +
 include/cobalt/cobalt.h    |   43 +++++++++++++++++++++++++++++++++++++++++++
 include/cobalt/signal.h    |    6 +++++-
 lib/cobalt/cond.c          |    2 +-
 lib/cobalt/current.c       |    4 ++--
 lib/cobalt/internal.c      |    7 +++----
 lib/cobalt/internal.h      |   17 +++--------------
 lib/cobalt/mutex.c         |    2 +-
 lib/cobalt/semaphore.c     |    3 ++-
 lib/cobalt/thread.c        |    8 ++++----
 11 files changed, 66 insertions(+), 28 deletions(-)

diff --git a/include/cobalt/Makefile.am b/include/cobalt/Makefile.am
index e2d7f87..f2e5e17 100644
--- a/include/cobalt/Makefile.am
+++ b/include/cobalt/Makefile.am
@@ -1,6 +1,7 @@
 includesubdir = $(includedir)/cobalt
 
 includesub_HEADERS =   \
+       cobalt.h        \
        fcntl.h         \
        mqueue.h        \
        pthread.h       \
diff --git a/include/cobalt/Makefile.in b/include/cobalt/Makefile.in
index c4edf30..3507802 100644
--- a/include/cobalt/Makefile.in
+++ b/include/cobalt/Makefile.in
@@ -372,6 +372,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/cobalt
 includesub_HEADERS = \
+       cobalt.h        \
        fcntl.h         \
        mqueue.h        \
        pthread.h       \
diff --git a/include/cobalt/cobalt.h b/include/cobalt/cobalt.h
new file mode 100644
index 0000000..63a9771
--- /dev/null
+++ b/include/cobalt/cobalt.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014 Philippe Gerum <r...@xenomai.org>.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+#ifndef _COBALT_COBALT_H
+#define _COBALT_COBALT_H
+
+#include <sys/types.h>
+#include <cobalt/uapi/thread.h>
+
+#define cobalt_commit_memory(p) __cobalt_commit_memory(p, sizeof(*p))
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int cobalt_thread_stat(pid_t pid,
+                      struct cobalt_threadstat *stat);
+
+int cobalt_serial_debug(const char *fmt, ...);
+
+size_t cobalt_get_stacksize(size_t size);
+
+void __cobalt_commit_memory(void *p, size_t len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_COBALT_COBALT_H */
diff --git a/include/cobalt/signal.h b/include/cobalt/signal.h
index febc752..62694f9 100644
--- a/include/cobalt/signal.h
+++ b/include/cobalt/signal.h
@@ -34,7 +34,11 @@
 extern "C" {
 #endif
 
-int cobalt_sigshadow_handler(int sig, siginfo_t *si, void *ctxt);
+int cobalt_sigshadow_handler(int sig, siginfo_t *si,
+                            void *ctxt);
+
+void cobalt_sigdebug_handler(int sig, siginfo_t *si,
+                            void *context);
 
 COBALT_DECL(int, sigpending(sigset_t *set));
 
diff --git a/lib/cobalt/cond.c b/lib/cobalt/cond.c
index 489c862..1991981 100644
--- a/lib/cobalt/cond.c
+++ b/lib/cobalt/cond.c
@@ -140,7 +140,7 @@ COBALT_IMPL(int, pthread_cond_init, (pthread_cond_t *cond,
        } else
                pending_signalsp = cond_get_signalsp(_cnd);
 
-       __cobalt_prefault(pending_signalsp);
+       cobalt_commit_memory(pending_signalsp);
 
        return 0;
 }
diff --git a/lib/cobalt/current.c b/lib/cobalt/current.c
index a18da44..d28fb29 100644
--- a/lib/cobalt/current.c
+++ b/lib/cobalt/current.c
@@ -47,7 +47,7 @@ void cobalt_set_current_window(unsigned long offset)
 {
        cobalt_current_window = (struct xnthread_user_window *)
                (cobalt_sem_heap[0] + offset);
-       __cobalt_prefault(cobalt_current_window);
+       cobalt_commit_memory(cobalt_current_window);
 }
 
 #else /* !HAVE_TLS */
@@ -84,7 +84,7 @@ void cobalt_set_current_window(unsigned long offset)
 
        window = (void *)(cobalt_sem_heap[0] + offset);
        pthread_setspecific(cobalt_current_window_key, window);
-       __cobalt_prefault(window);
+       cobalt_commit_memory(window);
 }
 
 #endif /* !HAVE_TLS */
diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
index ad6e3e6..260013c 100644
--- a/lib/cobalt/internal.c
+++ b/lib/cobalt/internal.c
@@ -19,7 +19,6 @@
  * Internal Cobalt services. No sanity check will be done with
  * respect to object validity, callers have to take care of this.
  */
-
 #include <sys/types.h>
 #include <stddef.h>
 #include <stdlib.h>
@@ -92,7 +91,7 @@ int cobalt_thread_join(pthread_t thread)
        return ret;
 }
 
-void ___cobalt_prefault(void *p, size_t len)
+void __cobalt_commit_memory(void *p, size_t len)
 {
        volatile char *_p = (volatile char *)p, *end;
        long pagesz = sysconf(_SC_PAGESIZE);
@@ -165,7 +164,7 @@ int cobalt_monitor_init(cobalt_monitor_t *mon, clockid_t 
clk_id, int flags)
        } else
                datp = get_monitor_data(mon);
 
-       __cobalt_prefault(datp);
+       cobalt_commit_memory(datp);
 
        return 0;
 }
@@ -454,7 +453,7 @@ int cobalt_event_init(cobalt_event_t *event, unsigned long 
value,
        } else
                datp = get_event_data(event);
 
-       __cobalt_prefault(datp);
+       cobalt_commit_memory(datp);
 
        return 0;
 }
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index e633dd7..72ed6af 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -33,6 +33,7 @@
 #include <cobalt/uapi/thread.h>
 #include <cobalt/uapi/cond.h>
 #include <cobalt/uapi/sem.h>
+#include <cobalt/cobalt.h>
 #include <xeno_config.h>
 #include "current.h"
 
@@ -42,10 +43,10 @@
 #define report_error_cont(fmt, args...) \
        __STD(fprintf(stderr, "                " fmt "\n", ##args))
 
-void cobalt_sigshadow_install_once(void);
-
 extern unsigned long cobalt_sem_heap[2];
 
+void cobalt_sigshadow_install_once(void);
+
 static inline struct mutex_dat *mutex_get_datp(struct cobalt_mutex_shadow 
*shadow)
 {
        if (shadow->attr.pshared)
@@ -59,20 +60,10 @@ static inline atomic_long_t *mutex_get_ownerp(struct 
cobalt_mutex_shadow *shadow
        return &mutex_get_datp(shadow)->owner;
 }
 
-size_t cobalt_get_stacksize(size_t size);
-
-void ___cobalt_prefault(void *p, size_t len);
-#define __cobalt_prefault(p) ___cobalt_prefault(p, sizeof(*p))
-
 void cobalt_thread_harden(void);
 
-int cobalt_thread_stat(pid_t pid,
-                      struct cobalt_threadstat *stat);
-
 int cobalt_thread_join(pthread_t thread);
 
-int cobalt_serial_debug(const char *fmt, ...);
-
 int cobalt_monitor_init(cobalt_monitor_t *mon,
                        clockid_t clk_id, int flags);
 
@@ -143,8 +134,6 @@ void cobalt_default_mutexattr_init(void);
 
 void cobalt_default_condattr_init(void);
 
-void cobalt_sigdebug_handler(int sig, siginfo_t *si, void *context);
-
 struct xnfeatinfo;
 
 void cobalt_check_features(struct xnfeatinfo *finfo);
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index f66276a..07acb64 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -137,7 +137,7 @@ COBALT_IMPL(int, pthread_mutex_init, (pthread_mutex_t 
*mutex,
        } else
                datp = mutex_get_datp(_mutex);
 
-       __cobalt_prefault(datp);
+       cobalt_commit_memory(datp);
 
        return err;
 }
diff --git a/lib/cobalt/semaphore.c b/lib/cobalt/semaphore.c
index 0ac3624..9add146 100644
--- a/lib/cobalt/semaphore.c
+++ b/lib/cobalt/semaphore.c
@@ -94,7 +94,8 @@ COBALT_IMPL(int, sem_init, (sem_t *sem, int pshared, unsigned 
value))
                return -1;
        }
 
-       __cobalt_prefault(sem_get_datp(_sem));
+       cobalt_commit_memory(sem_get_datp(_sem));
+
        return 0;
 }
 
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 418a931..3a3f779 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -49,11 +49,11 @@ static int linuxthreads;
 
 static int std_maxpri;
 
-static void prefault_stack(void)
+static void commit_stack_memory(void)
 {
        if (pthread_self() == __cobalt_main_ptid) {
                char stk[cobalt_get_stacksize(1)];
-               __cobalt_prefault(stk);
+               cobalt_commit_memory(stk);
        }
 }
 
@@ -120,7 +120,7 @@ static void *cobalt_thread_trampoline(void *p)
        long ret;
 
        cobalt_sigshadow_install_once();
-       prefault_stack();
+       commit_stack_memory();
 
        personality = iargs->personality;
        param_ex = iargs->param_ex;
@@ -685,7 +685,7 @@ int pthread_setschedparam_ex(pthread_t thread,
                                 &u_winoff, &promoted);
 
        if (ret == 0 && promoted) {
-               prefault_stack();
+               commit_stack_memory();
                cobalt_sigshadow_install_once();
                cobalt_set_current();
                cobalt_set_current_window(u_winoff);


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

Reply via email to