summaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-05-18 21:03:55 +0200
committerHarald Welte <laforge@gnumonks.org>2019-06-05 10:01:20 +0000
commit7b74551b93421d30d5f0346042993ff763ddbe25 (patch)
tree16d05cdaf21e172d5ca5f94424cb58be0c45a996 /include/osmocom/core
parent7a56952307a0d1ff673900e68a73a0a961b5197c (diff)
fsm: Allow millisecond granularity in osmo_fsm built-in timer
So far, the public API of osmo_fsm only allowed integral seconds as timeout. Let's change that to milli-seconds in order to cover more use cases. This introduces * osmo_fsm_inst_state_chg_ms() * osmo_fsm_inst_state_chg_keep_or_start_timer_ms() Which both work exactly like their previous counterparts without the _ms suffix - the only difference being that the timeout parameter is specified in milli-seconds, not in seconds. The value range for an unsigned long in milli-seconds even on a 32bit platform extends to about 48 days. This patch also removes the documentation notice about limiting the maximum value to 0x7fffffff due to time_t signed-ness. We don't use time_t but unsigned long. Change-Id: I35b330e460e80bb67376c77e997e464439ac5397
Diffstat (limited to 'include/osmocom/core')
-rw-r--r--include/osmocom/core/fsm.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index 41d01a58..1701c45e 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -243,6 +243,13 @@ int _osmo_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t new_state,
unsigned long timeout_secs, int T,
const char *file, int line);
+#define osmo_fsm_inst_state_chg_ms(fi, new_state, timeout_ms, T) \
+ _osmo_fsm_inst_state_chg_ms(fi, new_state, timeout_ms, T, \
+ __FILE__, __LINE__)
+int _osmo_fsm_inst_state_chg_ms(struct osmo_fsm_inst *fi, uint32_t new_state,
+ unsigned long timeout_ms, int T,
+ const char *file, int line);
+
/*! perform a state change while keeping the current timer running.
*
* This is useful to keep a timeout across several states (without having to round the
@@ -273,6 +280,14 @@ int _osmo_fsm_inst_state_chg_keep_or_start_timer(struct osmo_fsm_inst *fi, uint3
unsigned long timeout_secs, int T,
const char *file, int line);
+#define osmo_fsm_inst_state_chg_keep_or_start_timer_ms(fi, new_state, timeout_ms, T) \
+ _osmo_fsm_inst_state_chg_keep_or_start_timer_ms(fi, new_state, timeout_ms, T, \
+ __FILE__, __LINE__)
+int _osmo_fsm_inst_state_chg_keep_or_start_timer_ms(struct osmo_fsm_inst *fi, uint32_t new_state,
+ unsigned long timeout_ms, int T,
+ const char *file, int line);
+
+
/*! dispatch an event to an osmocom finite state machine instance
*
* This is a macro that calls _osmo_fsm_inst_dispatch() with the given