aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/src/chregistry.c
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-02-24 10:28:43 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-02-24 10:28:43 +0000
commit5181b1e391f3480d375a484fb55e70fd5586a5d1 (patch)
treef5a52fd64f69f31c40cc55a404c599d61dd70cd7 /os/rt/src/chregistry.c
parent54e8a6c9e2a71902af35b4ec25f087719192c130 (diff)
downloadChibiOS-5181b1e391f3480d375a484fb55e70fd5586a5d1.tar.gz
ChibiOS-5181b1e391f3480d375a484fb55e70fd5586a5d1.tar.bz2
ChibiOS-5181b1e391f3480d375a484fb55e70fd5586a5d1.zip
Enhanced registry.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8939 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/src/chregistry.c')
-rw-r--r--os/rt/src/chregistry.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/os/rt/src/chregistry.c b/os/rt/src/chregistry.c
index 07185d331..944383bf1 100644
--- a/os/rt/src/chregistry.c
+++ b/os/rt/src/chregistry.c
@@ -44,6 +44,9 @@
* option must be enabled in @p chconf.h.
* @{
*/
+
+#include <string.h>
+
#include "ch.h"
#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__)
@@ -160,6 +163,53 @@ thread_t *chRegNextThread(thread_t *tp) {
return ntp;
}
+/**
+ * @brief Retrieves a thread pointer by name.
+ *
+ * @param[in] name the thread name
+ * @return A pointer to the found thread.
+ * @retval NULL if a matching thread has not been found.
+ *
+ * @api
+ */
+thread_t *chRegFindThreadByName(const char *name) {
+ thread_t *ctp;
+
+ /* Scanning registry.*/
+ ctp = chRegFirstThread();
+ do {
+ if (strcmp(chRegGetThreadNameX(ctp), name) == 0) {
+ return ctp;
+ }
+ ctp = chRegNextThread(ctp);
+ } while (ctp != NULL);
+
+ return NULL;
+}
#endif /* CH_CFG_USE_REGISTRY == TRUE */
+/**
+ * @brief Confirms that a pointer is a valid thread pointer.
+ *
+ * @param[in] tp pointer to the thread
+ * @return A pointer to the found thread.
+ * @retval NULL if a matching thread has not been found.
+ *
+ * @api
+ */
+thread_t *chRegFindThreadByPointer(thread_t *tp) {
+ thread_t *ctp;
+
+ /* Scanning registry.*/
+ ctp = chRegFirstThread();
+ do {
+ if (ctp == tp) {
+ return ctp;
+ }
+ ctp = chRegNextThread(ctp);
+ } while (ctp != NULL);
+
+ return NULL;
+}
+
/** @} */