+#if !defined(__AVR__)
+
+ /* No tricks needed on 16/32bit CPUs */
+# define fifo_isempty_locked(fb) fifo_isempty((fb))
+# define fifo_push_locked(fb, c) fifo_push((fb), (c))
+
+#else /* !__AVR__ */
+
+ /*!
+ * Similar to fifo_isempty(), but with stronger guarantees for
+ * concurrent access between user and interrupt code.
+ * This is actually only needed for 8-bit processors.
+ *
+ * \sa fifo_isempty()
+ */
+ INLINE bool fifo_isempty_locked(const FIFOBuffer *fb);
+ INLINE bool fifo_isempty_locked(const FIFOBuffer *fb)
+ {
+ bool result;
+ cpuflags_t flags;
+
+ DISABLE_IRQSAVE(flags);
+ result = fifo_isempty(fb);
+ ENABLE_IRQRESTORE(flags);
+
+ return result;
+ }
+
+ /*!
+ * Similar to fifo_push(), but with stronger guarantees for
+ * concurrent access between user and interrupt code.
+ * This is actually only needed for 8-bit processors.
+ *
+ * \sa fifo_push()
+ */
+ INLINE void fifo_push_locked(FIFOBuffer *fb, unsigned char c);
+ INLINE void fifo_push_locked(FIFOBuffer *fb, unsigned char c)
+ {
+ cpuflags_t flags;
+ DISABLE_IRQSAVE(flags);
+ fifo_push(fb, c);
+ ENABLE_IRQRESTORE(flags);
+ }
+
+#endif /* !__AVR__ */
+
+
+/*!
+ * Thread safe version of fifo_isfull()
+ */
+INLINE bool fifo_isfull_locked(const FIFOBuffer *_fb)
+{
+ bool _result;
+ cpuflags_t _flags;
+
+ DISABLE_IRQSAVE(_flags);
+ _result = fifo_isfull(_fb);
+ ENABLE_IRQRESTORE(_flags);
+
+ return _result;
+}
+
+
+