stack_sentinel: change cooperative check

One of the stack sentinel policies was to check the sentinel
any time a cooperative context switch is done (i.e, _Swap is
called).

This was done by adding a hook to _check_stack_sentinel in
every arch's __swap function.

This way is cleaner as we just have the hook in one inline
function rather than implemented in several different assembly
dialects.

The check upon interrupt is now made unconditionally rather
than checking if we are calling __swap, since the check now
is only called on cooperative _Swap(). The interrupt is always
serviced first.

Issue: ZEP-2244
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
diff --git a/kernel/include/nano_internal.h b/kernel/include/nano_internal.h
index 9052648..e76ae85 100644
--- a/kernel/include/nano_internal.h
+++ b/kernel/include/nano_internal.h
@@ -52,19 +52,27 @@
 
 extern unsigned int __swap(unsigned int key);
 
-#if defined(CONFIG_TIMESLICING)
+#ifdef CONFIG_TIMESLICING
 extern void _update_time_slice_before_swap(void);
+#endif
 
-static inline unsigned int _time_slice_swap(unsigned int key)
+#ifdef CONFIG_STACK_SENTINEL
+extern void _check_stack_sentinel(void);
+#endif
+
+static inline unsigned int _Swap(unsigned int key)
 {
+
+#ifdef CONFIG_STACK_SENTINEL
+	_check_stack_sentinel();
+#endif
+#ifdef CONFIG_TIMESLICING
 	_update_time_slice_before_swap();
+#endif
+
 	return __swap(key);
 }
 
-#define _Swap(x)  _time_slice_swap(x)
-#else
-#define _Swap(x)  __swap(x)
-#endif
 /* set and clear essential fiber/task flag */
 
 extern void _thread_essential_set(void);