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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri May  1 19:30:10 2015 +0200

cobalt/synch: un-inline xnsynch_destroy()

---

 include/cobalt/kernel/synch.h |    2 +-
 kernel/cobalt/synch.c         |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index 4333521..f53cd5e 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -124,7 +124,7 @@ static inline void xnsynch_detect_claimed_relax(struct 
xnthread *owner)
 void xnsynch_init(struct xnsynch *synch, int flags,
                  atomic_t *fastlock);
 
-#define xnsynch_destroy(synch) xnsynch_flush(synch, XNRMID)
+int xnsynch_destroy(struct xnsynch *synch);
 
 static inline void xnsynch_set_owner(struct xnsynch *synch,
                                     struct xnthread *thread)
diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c
index 93176eb..da827d0 100644
--- a/kernel/cobalt/synch.c
+++ b/kernel/cobalt/synch.c
@@ -99,6 +99,33 @@ void xnsynch_init(struct xnsynch *synch, int flags, atomic_t 
*fastlock)
 EXPORT_SYMBOL_GPL(xnsynch_init);
 
 /**
+ * @fn void xnsynch_destroy(struct xnsynch *synch)
+ * @brief Destroy a synchronization object.
+ *
+ * Destroys the synchronization object @a synch, unblocking all
+ * waiters with the XNRMID status.
+ *
+ * @return XNSYNCH_RESCHED is returned if at least one thread is
+ * unblocked, which means the caller should invoke xnsched_run() for
+ * applying the new scheduling state. Otherwise, XNSYNCH_DONE is
+ * returned.
+
+ * @sideeffect Same as xnsynch_flush().
+ *
+ * @coretags{task-unrestricted}
+ */
+int xnsynch_destroy(struct xnsynch *synch)
+{
+       int ret;
+       
+       ret = xnsynch_flush(synch, XNRMID);
+       XENO_BUG_ON(COBALT, synch->status & XNSYNCH_CLAIMED);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(xnsynch_destroy);
+
+/**
  * @fn int xnsynch_sleep_on(struct xnsynch *synch, xnticks_t timeout, 
xntmode_t timeout_mode);
  * @brief Sleep on an ownerless synchronization object.
  *
@@ -650,6 +677,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch,
        }
 
        lockp = xnsynch_fastlock(synch);
+       XENO_BUG_ON(COBALT, lockp == NULL);
        threadh = thread->handle;
        if (likely(xnsynch_fast_release(lockp, threadh)))
                return NULL;
@@ -670,6 +698,8 @@ void xnsynch_requeue_sleeper(struct xnthread *thread)
        if ((synch->status & XNSYNCH_PRIO) == 0)
                return;
 
+       XENO_BUG_ON(COBALT, (synch->status & XNSYNCH_OWNER) == 0);
+
        list_del(&thread->plink);
        list_add_priff(thread, &synch->pendq, wprio, plink);
        owner = synch->owner;
@@ -778,7 +808,8 @@ EXPORT_SYMBOL_GPL(xnsynch_peek_pendq);
  * lowered to its base priority value as a consequence of the priority
  * inheritance boost being cleared.
  *
- * - The synchronization object is no more owned by any thread.
+ * - After this operation has completed, the synchronization object is
+ * not owned by any thread.
  *
  * @coretags{unrestricted}
  */


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

Reply via email to