[riot-notifications] [RIOT-OS/RIOT] core: Fix undefined behaviour in C11 atomics (#11528)

Semjon Kerner notifications at github.com
Wed May 15 14:57:42 CEST 2019


SemjonKerner approved this pull request.

Fix as disscussed. You could fix the indentions, but feel free to squash right away.

> @@ -137,12 +137,12 @@ typedef uint64_t I8;
 #define TEMPLATE_ATOMIC_FETCH_OP_N(opname, op, n, prefixop) \
     I##n __atomic_fetch_##opname##_##n(volatile void *ptr, I##n val, int memmodel) \
     { \
-        unsigned int mask = irq_disable();    \
-        (void)memmodel;                       \
-        I##n tmp = *(I##n *)ptr;              \
-        *(I##n *)ptr = prefixop(tmp op val);  \
-        irq_restore(mask);                    \
-        return tmp;                           \
+        unsigned int mask = irq_disable();              \
+        (void)memmodel;                                 \
+        I##n tmp = *(volatile I##n *)ptr;               \
+        *(volatile I##n *)ptr = prefixop(tmp op val);   \

indention of slash

> @@ -156,12 +156,12 @@ typedef uint64_t I8;
 #define TEMPLATE_ATOMIC_OP_FETCH_N(opname, op, n, prefixop) \
     I##n __atomic_##opname##_fetch_##n(volatile void *ptr, I##n val, int memmodel) \
     { \
-        (void)memmodel;                                 \
-        unsigned int mask = irq_disable();              \
-        I##n tmp = prefixop((*(I##n *)ptr) op val);     \
-        *(I##n *)ptr = tmp;                             \
-        irq_restore(mask);                              \
-        return tmp;                                     \
+        (void)memmodel;                                         \
+        unsigned int mask = irq_disable();                      \
+        I##n tmp = prefixop((*(volatile I##n *)ptr) op val);    \

indention

-- 
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/11528#pullrequestreview-237801332
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190515/47adb2b9/attachment.html>


More information about the notifications mailing list