diff options
Diffstat (limited to 'prism/util/pm_state_stack.c')
-rw-r--r-- | prism/util/pm_state_stack.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/prism/util/pm_state_stack.c b/prism/util/pm_state_stack.c new file mode 100644 index 0000000000..7ff95bd611 --- /dev/null +++ b/prism/util/pm_state_stack.c @@ -0,0 +1,19 @@ +#include "yarp/util/yp_state_stack.h" + +// Pushes a value onto the stack. +void +yp_state_stack_push(yp_state_stack_t *stack, bool value) { + *stack = (*stack << 1) | (value & 1); +} + +// Pops a value off the stack. +void +yp_state_stack_pop(yp_state_stack_t *stack) { + *stack >>= 1; +} + +// Returns the value at the top of the stack. +bool +yp_state_stack_p(yp_state_stack_t *stack) { + return *stack & 1; +} |