[rtems commit] score: Create spinlock implementation header

Sebastian Huber sebh at rtems.org
Mon Jul 22 14:51:44 UTC 2013


Module:    rtems
Branch:    master
Commit:    c71b596c4eb708716fb45950876a00f8ce6f4156
Changeset: http://git.rtems.org/rtems/commit/?id=c71b596c4eb708716fb45950876a00f8ce6f4156

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jul 19 15:24:04 2013 +0200

score: Create spinlock implementation header

Move implementation specific parts of corespinlock.h and
corespinlock.inl into new header file corespinlockimpl.h.  The
corespinlock.h contains now only the application visible API.

---

 cpukit/posix/include/rtems/posix/spinlockimpl.h    |    1 +
 cpukit/score/Makefile.am                           |    5 +-
 cpukit/score/include/rtems/score/corespinlock.h    |  106 +-------------
 .../score/include/rtems/score/corespinlockimpl.h   |  155 ++++++++++++++++++++
 cpukit/score/inline/rtems/score/corespinlock.inl   |   61 --------
 cpukit/score/preinstall.am                         |    9 +-
 cpukit/score/src/corespinlock.c                    |    2 +-
 cpukit/score/src/corespinlockrelease.c             |    2 +-
 cpukit/score/src/corespinlockwait.c                |    2 +-
 9 files changed, 171 insertions(+), 172 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/spinlockimpl.h b/cpukit/posix/include/rtems/posix/spinlockimpl.h
index 5853d45..2711316 100644
--- a/cpukit/posix/include/rtems/posix/spinlockimpl.h
+++ b/cpukit/posix/include/rtems/posix/spinlockimpl.h
@@ -20,6 +20,7 @@
 #define _RTEMS_POSIX_SPINLOCKIMPL_H
 
 #include <rtems/posix/spinlock.h>
+#include <rtems/score/corespinlockimpl.h>
 
 #include <pthread.h>
 
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 65abaa4..6217412 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -71,6 +71,7 @@ endif
 
 if HAS_PTHREADS
 include_rtems_score_HEADERS += include/rtems/score/corespinlock.h
+include_rtems_score_HEADERS += include/rtems/score/corespinlockimpl.h
 include_rtems_score_HEADERS += include/rtems/score/corerwlock.h
 include_rtems_score_HEADERS += include/rtems/score/corerwlockimpl.h
 endif
@@ -108,10 +109,6 @@ include_rtems_score_HEADERS += inline/rtems/score/tqdata.inl
 include_rtems_score_HEADERS += inline/rtems/score/watchdog.inl
 include_rtems_score_HEADERS += inline/rtems/score/wkspace.inl
 
-if HAS_PTHREADS
-include_rtems_score_HEADERS += inline/rtems/score/corespinlock.inl
-endif
-
 if HAS_MP
 ## We only build multiprocessing related files if HAS_MP was defined
 include_rtems_score_HEADERS += inline/rtems/score/mppkt.inl
diff --git a/cpukit/score/include/rtems/score/corespinlock.h b/cpukit/score/include/rtems/score/corespinlock.h
index 5a5b681..2c91e83 100644
--- a/cpukit/score/include/rtems/score/corespinlock.h
+++ b/cpukit/score/include/rtems/score/corespinlock.h
@@ -19,6 +19,12 @@
 #ifndef _RTEMS_SCORE_CORESPINLOCK_H
 #define _RTEMS_SCORE_CORESPINLOCK_H
 
+#include <rtems/score/object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**
  *  @defgroup ScoreSpinlock Spinlock Handler
  *
@@ -29,54 +35,6 @@
  */
 /**@{*/
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <rtems/score/thread.h>
-#include <rtems/score/priority.h>
-
-/**
- *  Core Spinlock handler return statuses.
- */
-typedef enum {
-  /** This status indicates that the operation completed successfully. */
-  CORE_SPINLOCK_SUCCESSFUL,
-  /** This status indicates that the current thread already holds the spinlock.
-   *  An attempt to relock it will result in deadlock.
-   */
-  CORE_SPINLOCK_HOLDER_RELOCKING,
-  /** This status indicates that the current thread is attempting to unlock a
-   *  spinlock that is held by another thread.
-   */
-  CORE_SPINLOCK_NOT_HOLDER,
-  /** This status indicates that a thread reached the limit of time it
-   *  was willing to wait on the spin lock.
-   */
-  CORE_SPINLOCK_TIMEOUT,
-  /** This status indicates that a thread is currently waiting for this
-   *  spin lock.
-   */
-  CORE_SPINLOCK_IS_BUSY,
-  /** This status indicates that the spinlock is currently locked and thus
-   *  unavailable.
-   */
-  CORE_SPINLOCK_UNAVAILABLE,
-  /** This status indicates that the spinlock is not currently locked and thus
-   *  should not be released.
-   */
-  CORE_SPINLOCK_NOT_LOCKED
-}   CORE_spinlock_Status;
-
-/** This is a shorthand for the last status code. */
-#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_NOT_LOCKED
-
-/** This indicates the lock is available. */
-#define CORE_SPINLOCK_UNLOCKED 0
-
-/** This indicates the lock is unavailable. */
-#define CORE_SPINLOCK_LOCKED   1
-
 /**
  *  The following defines the control block used to manage the
  *  attributes of each spinlock.
@@ -111,61 +69,11 @@ typedef struct {
   volatile Objects_Id   holder;
 }   CORE_spinlock_Control;
 
-/**
- *  @brief Initialize the spinlock.
- *
- *  This routine initializes the spinlock based on the parameters passed.
- *
- *  @param[in] the_spinlock is the spinlock control block to initialize
- *  @param[in] the_spinlock_attributes define the behavior of this instance
- */
-void _CORE_spinlock_Initialize(
-  CORE_spinlock_Control       *the_spinlock,
-  CORE_spinlock_Attributes    *the_spinlock_attributes
-);
-
-/**
- *  @brief Wait for spinlock.
- *
- *  This routine wait for the spinlock to be released.  If the spinlock
- *  is set to automatic and this is the appropriate thread, then it returns
- *  immediately.  Otherwise, the calling thread is blocked until the spinlock
- *  is released.
- *
- *  @param[in] the_spinlock is the spinlock to wait for
- *  @param[in] wait is true if willing to wait
- *  @param[in] timeout is the maximum number of ticks to spin (0 is forever)
- *
- * @retval A status is returned which indicates the success or failure of
- *         this operation.
- */
-CORE_spinlock_Status _CORE_spinlock_Wait(
-  CORE_spinlock_Control  *the_spinlock,
-  bool                    wait,
-  Watchdog_Interval       timeout
-);
-
-/**
- * @brief Manually release the spinlock.
- *
- *  This routine manually releases the spinlock.  All of the threads waiting
- *  for the spinlock will be readied.
- *
- *  @param[in] the_spinlock is the spinlock to surrender
- */
-CORE_spinlock_Status _CORE_spinlock_Release(
-  CORE_spinlock_Control *the_spinlock
-);
-
-#ifndef __RTEMS_APPLICATION__
-#include <rtems/score/corespinlock.inl>
-#endif
+/**@}*/
 
 #ifdef __cplusplus
 }
 #endif
 
-/**@}*/
-
 #endif
 /*  end of include file */
diff --git a/cpukit/score/include/rtems/score/corespinlockimpl.h b/cpukit/score/include/rtems/score/corespinlockimpl.h
new file mode 100644
index 0000000..021f2cc
--- /dev/null
+++ b/cpukit/score/include/rtems/score/corespinlockimpl.h
@@ -0,0 +1,155 @@
+/**
+ * @file
+ *
+ * @brief Inlined Routines Associated with the SuperCore Spinlock
+ *
+ * This include file contains all of the inlined routines associated
+ * with the SuperCore spinlock.
+ */
+
+/*
+ *  COPYRIGHT (c) 1989-2008.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SCORE_CORESPINLOCKIMPL_H
+#define _RTEMS_SCORE_CORESPINLOCKIMPL_H
+
+#include <rtems/score/corespinlock.h>
+#include <rtems/score/watchdog.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup ScoreSpinlock
+ */
+/**@{**/
+
+/**
+ *  Core Spinlock handler return statuses.
+ */
+typedef enum {
+  /** This status indicates that the operation completed successfully. */
+  CORE_SPINLOCK_SUCCESSFUL,
+  /** This status indicates that the current thread already holds the spinlock.
+   *  An attempt to relock it will result in deadlock.
+   */
+  CORE_SPINLOCK_HOLDER_RELOCKING,
+  /** This status indicates that the current thread is attempting to unlock a
+   *  spinlock that is held by another thread.
+   */
+  CORE_SPINLOCK_NOT_HOLDER,
+  /** This status indicates that a thread reached the limit of time it
+   *  was willing to wait on the spin lock.
+   */
+  CORE_SPINLOCK_TIMEOUT,
+  /** This status indicates that a thread is currently waiting for this
+   *  spin lock.
+   */
+  CORE_SPINLOCK_IS_BUSY,
+  /** This status indicates that the spinlock is currently locked and thus
+   *  unavailable.
+   */
+  CORE_SPINLOCK_UNAVAILABLE,
+  /** This status indicates that the spinlock is not currently locked and thus
+   *  should not be released.
+   */
+  CORE_SPINLOCK_NOT_LOCKED
+}   CORE_spinlock_Status;
+
+/** This is a shorthand for the last status code. */
+#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_NOT_LOCKED
+
+/** This indicates the lock is available. */
+#define CORE_SPINLOCK_UNLOCKED 0
+
+/** This indicates the lock is unavailable. */
+#define CORE_SPINLOCK_LOCKED   1
+
+/**
+ *  @brief Initialize the spinlock.
+ *
+ *  This routine initializes the spinlock based on the parameters passed.
+ *
+ *  @param[in] the_spinlock is the spinlock control block to initialize
+ *  @param[in] the_spinlock_attributes define the behavior of this instance
+ */
+void _CORE_spinlock_Initialize(
+  CORE_spinlock_Control       *the_spinlock,
+  CORE_spinlock_Attributes    *the_spinlock_attributes
+);
+
+/**
+ *  @brief Wait for spinlock.
+ *
+ *  This routine wait for the spinlock to be released.  If the spinlock
+ *  is set to automatic and this is the appropriate thread, then it returns
+ *  immediately.  Otherwise, the calling thread is blocked until the spinlock
+ *  is released.
+ *
+ *  @param[in] the_spinlock is the spinlock to wait for
+ *  @param[in] wait is true if willing to wait
+ *  @param[in] timeout is the maximum number of ticks to spin (0 is forever)
+ *
+ * @retval A status is returned which indicates the success or failure of
+ *         this operation.
+ */
+CORE_spinlock_Status _CORE_spinlock_Wait(
+  CORE_spinlock_Control  *the_spinlock,
+  bool                    wait,
+  Watchdog_Interval       timeout
+);
+
+/**
+ * @brief Manually release the spinlock.
+ *
+ *  This routine manually releases the spinlock.  All of the threads waiting
+ *  for the spinlock will be readied.
+ *
+ *  @param[in] the_spinlock is the spinlock to surrender
+ */
+CORE_spinlock_Status _CORE_spinlock_Release(
+  CORE_spinlock_Control *the_spinlock
+);
+
+/**
+ * This method is used to initialize core spinlock attributes.
+ *
+ * @param[in] the_attributes pointer to the attributes to initialize.
+ */
+RTEMS_INLINE_ROUTINE void _CORE_spinlock_Initialize_attributes(
+  CORE_spinlock_Attributes *the_attributes
+)
+{
+  the_attributes->XXX = 0;
+}
+
+/**
+ * This method is used to determine if the spinlock is available or not.
+ *
+ * @param[in] the_spinlock will be checked
+ *
+ * @return This method will return true if the spinlock is busy
+ *         and false otherwise.
+ */
+RTEMS_INLINE_ROUTINE bool _CORE_spinlock_Is_busy(
+  CORE_spinlock_Control  *the_spinlock
+)
+{
+  return (the_spinlock->users != 0);
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/score/inline/rtems/score/corespinlock.inl b/cpukit/score/inline/rtems/score/corespinlock.inl
deleted file mode 100644
index 76f5c44..0000000
--- a/cpukit/score/inline/rtems/score/corespinlock.inl
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * @file
- *
- * @brief Inlined Routines Associated with the SuperCore Spinlock
- *
- * This include file contains all of the inlined routines associated
- * with the SuperCore spinlock.
- */
-
-/*
- *  COPYRIGHT (c) 1989-2008.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
- */
-
-#ifndef _RTEMS_SCORE_CORESPINLOCK_H
-# error "Never use <rtems/score/corespinlock.inl> directly; include <rtems/score/corespinlock.h> instead."
-#endif
-
-#ifndef _RTEMS_SCORE_CORESPINLOCK_INL
-#define _RTEMS_SCORE_CORESPINLOCK_INL
-
-/**
- * @addtogroup ScoreSpinlock
- */
-/**@{**/
-
-/**
- * This method is used to initialize core spinlock attributes.
- *
- * @param[in] the_attributes pointer to the attributes to initialize.
- */
-RTEMS_INLINE_ROUTINE void _CORE_spinlock_Initialize_attributes(
-  CORE_spinlock_Attributes *the_attributes
-)
-{
-  the_attributes->XXX = 0;
-}
-
-/**
- * This method is used to determine if the spinlock is available or not.
- *
- * @param[in] the_spinlock will be checked
- *
- * @return This method will return true if the spinlock is busy
- *         and false otherwise.
- */
-RTEMS_INLINE_ROUTINE bool _CORE_spinlock_Is_busy(
-  CORE_spinlock_Control  *the_spinlock
-)
-{
-  return (the_spinlock->users != 0);
-}
-
-/** @} */
-
-#endif
-/* end of include file */
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index 294a05f..7fb9109 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -253,6 +253,10 @@ $(PROJECT_INCLUDE)/rtems/score/corespinlock.h: include/rtems/score/corespinlock.
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corespinlock.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corespinlock.h
 
+$(PROJECT_INCLUDE)/rtems/score/corespinlockimpl.h: include/rtems/score/corespinlockimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corespinlockimpl.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corespinlockimpl.h
+
 $(PROJECT_INCLUDE)/rtems/score/corerwlock.h: include/rtems/score/corerwlock.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corerwlock.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corerwlock.h
@@ -359,11 +363,6 @@ $(PROJECT_INCLUDE)/rtems/score/wkspace.inl: inline/rtems/score/wkspace.inl $(PRO
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/wkspace.inl
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/wkspace.inl
 
-if HAS_PTHREADS
-$(PROJECT_INCLUDE)/rtems/score/corespinlock.inl: inline/rtems/score/corespinlock.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
-	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corespinlock.inl
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corespinlock.inl
-endif
 if HAS_MP
 $(PROJECT_INCLUDE)/rtems/score/mppkt.inl: inline/rtems/score/mppkt.inl $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mppkt.inl
diff --git a/cpukit/score/src/corespinlock.c b/cpukit/score/src/corespinlock.c
index bc7084e..013178b 100644
--- a/cpukit/score/src/corespinlock.c
+++ b/cpukit/score/src/corespinlock.c
@@ -20,7 +20,7 @@
 #endif
 
 #include <rtems/system.h>
-#include <rtems/score/corespinlock.h>
+#include <rtems/score/corespinlockimpl.h>
 #include <rtems/score/states.h>
 #include <rtems/score/thread.h>
 #include <rtems/score/threadq.h>
diff --git a/cpukit/score/src/corespinlockrelease.c b/cpukit/score/src/corespinlockrelease.c
index bc085f2..b2c9b53 100644
--- a/cpukit/score/src/corespinlockrelease.c
+++ b/cpukit/score/src/corespinlockrelease.c
@@ -19,7 +19,7 @@
 #endif
 
 #include <rtems/system.h>
-#include <rtems/score/corespinlock.h>
+#include <rtems/score/corespinlockimpl.h>
 #include <rtems/score/states.h>
 #include <rtems/score/thread.h>
 #include <rtems/score/watchdog.h>
diff --git a/cpukit/score/src/corespinlockwait.c b/cpukit/score/src/corespinlockwait.c
index 6e71a1f..56baad1 100644
--- a/cpukit/score/src/corespinlockwait.c
+++ b/cpukit/score/src/corespinlockwait.c
@@ -19,7 +19,7 @@
 #endif
 
 #include <rtems/system.h>
-#include <rtems/score/corespinlock.h>
+#include <rtems/score/corespinlockimpl.h>
 #include <rtems/score/states.h>
 #include <rtems/score/thread.h>
 #include <rtems/score/threaddispatch.h>




More information about the vc mailing list