[riot-notifications] [RIOT-OS/RIOT] tsrb: change input type to `uint8_t` (#11634)

Martine Lenders notifications at github.com
Wed Jun 5 15:25:51 CEST 2019


> (I believe they are the problem with volatile)

I was able to deny by claim with the following patch:

```diff
diff --git a/sys/include/tsrb.h b/sys/include/tsrb.h
index 6dea0eca3..392c746b5 100644
--- a/sys/include/tsrb.h
+++ b/sys/include/tsrb.h
@@ -30,6 +30,8 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "irq.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -76,7 +78,11 @@ static inline void tsrb_init(tsrb_t *rb, void *buffer, unsigned bufsize)
  */
 static inline int tsrb_empty(const tsrb_t *rb)
 {
-    return (rb->reads == rb->writes);
+    int res;
+    unsigned state = irq_disable();
+    res = (rb->reads == rb->writes);
+    irq_restore(state);
+    return res;
 }
 
 
@@ -87,7 +93,11 @@ static inline int tsrb_empty(const tsrb_t *rb)
  */
 static inline unsigned int tsrb_avail(const tsrb_t *rb)
 {
-    return (rb->writes - rb->reads);
+    unsigned int res;
+    unsigned state = irq_disable();
+    res = (rb->writes - rb->reads);
+    irq_restore(state);
+    return res;
 }
 
 /**
@@ -98,7 +108,11 @@ static inline unsigned int tsrb_avail(const tsrb_t *rb)
  */
 static inline int tsrb_full(const tsrb_t *rb)
 {
-    return (rb->writes - rb->reads) == rb->size;
+    int res;
+    unsigned state = irq_disable();
+    res = (rb->writes - rb->reads) == rb->size;
+    irq_restore(state);
+    return res;
 }
 
 /**
@@ -108,7 +122,11 @@ static inline int tsrb_full(const tsrb_t *rb)
  */
+    int res;
+    unsigned state = irq_disable();
+    res = (rb->reads == rb->writes);
+    irq_restore(state);
+    return res;
 }
 
 
@@ -87,7 +93,11 @@ static inline int tsrb_empty(const tsrb_t *rb)
  */
 static inline unsigned int tsrb_avail(const tsrb_t *rb)
 {
-    return (rb->writes - rb->reads);
+    unsigned int res;
+    unsigned state = irq_disable();
+    res = (rb->writes - rb->reads);
+    irq_restore(state);
+    return res;
 }
 
 /**
@@ -98,7 +108,11 @@ static inline unsigned int tsrb_avail(const tsrb_t *rb)
  */
 static inline int tsrb_full(const tsrb_t *rb)
 {
-    return (rb->writes - rb->reads) == rb->size;
+    int res;
+    unsigned state = irq_disable();
+    res = (rb->writes - rb->reads) == rb->size;
+    irq_restore(state);
+    return res;
 }
 
 /**
@@ -108,7 +122,11 @@ static inline int tsrb_full(const tsrb_t *rb)
  */
 static inline unsigned int tsrb_free(const tsrb_t *rb)
 {
-    return (rb->size - rb->writes + rb->reads);
+    unsigned int res;
+    unsigned state = irq_disable();
+    res = (rb->size - rb->writes + rb->reads);
+    irq_restore(state);
+    return res;
 }
 
 /**
```

Still not working. Will try your proposal.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11634#issuecomment-499081829
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190605/d5caab3b/attachment.html>


More information about the notifications mailing list