<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/21815">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">fsm: Add osmo_fsm_inst_broadcast_children()<br><br>This is a helper function to broadcast an event to all of the<br>siblings of a specified FSM instance.<br><br>Change-Id: I2ce398741a8672d7b7c4058d056f46e2fe7353c1<br>---<br>M include/osmocom/core/fsm.h<br>M src/fsm.c<br>2 files changed, 31 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h</span><br><span>index 7b262c7..77ebe7c 100644</span><br><span>--- a/include/osmocom/core/fsm.h</span><br><span>+++ b/include/osmocom/core/fsm.h</span><br><span>@@ -326,4 +326,15 @@</span><br><span>                            void *data,</span><br><span>                                  const char *file, int line);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! dispatch an event to all children of an osmocom finite state machine instance</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ *  This is a macro that calls _osmo_fsm_inst_broadcast_children() with the given</span><br><span style="color: hsl(120, 100%, 40%);">+ *  parameters as well as the caller's source file and line number for logging</span><br><span style="color: hsl(120, 100%, 40%);">+ *  purposes. See there for documentation.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define osmo_fsm_inst_broadcast_children(fi, cause, data) \</span><br><span style="color: hsl(120, 100%, 40%);">+        _osmo_fsm_inst_broadcast_children(fi, cause, data, __FILE__, __LINE__)</span><br><span style="color: hsl(120, 100%, 40%);">+void _osmo_fsm_inst_broadcast_children(struct osmo_fsm_inst *fi, uint32_t event,</span><br><span style="color: hsl(120, 100%, 40%);">+                                      void *data, const char *file, int line);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! @} */</span><br><span>diff --git a/src/fsm.c b/src/fsm.c</span><br><span>index 1e8909e..f1dbb41 100644</span><br><span>--- a/src/fsm.c</span><br><span>+++ b/src/fsm.c</span><br><span>@@ -1016,6 +1016,26 @@</span><br><span>    }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Broadcast an event to all the FSMs children.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ *  Iterate over all children and send them the specified event.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] fi FSM instance of the parent</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] event Event to send to children of FSM instance</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] data Data to pass along with the event</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] file Calling source file (from osmo_fsm_inst_dispatch macro)</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] line Calling source line (from osmo_fsm_inst_dispatch macro)</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void _osmo_fsm_inst_broadcast_children(struct osmo_fsm_inst *fi,</span><br><span style="color: hsl(120, 100%, 40%);">+                                  uint32_t event, void *data,</span><br><span style="color: hsl(120, 100%, 40%);">+                                   const char *file, int line)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        struct osmo_fsm_inst *child, *tmp;</span><br><span style="color: hsl(120, 100%, 40%);">+    llist_for_each_entry_safe(child, tmp, &fi->proc.children, proc.child) {</span><br><span style="color: hsl(120, 100%, 40%);">+                _osmo_fsm_inst_dispatch(child, event, data, file, line);</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> const struct value_string osmo_fsm_term_cause_names[] = {</span><br><span>  OSMO_VALUE_STRING(OSMO_FSM_TERM_PARENT),</span><br><span>     OSMO_VALUE_STRING(OSMO_FSM_TERM_REQUEST),</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/21815">change 21815</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/21815"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I2ce398741a8672d7b7c4058d056f46e2fe7353c1 </div>
<div style="display:none"> Gerrit-Change-Number: 21815 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>