atomic_ops: add char versions of uint8_t atomic primitives.
authorBastien Montagne <montagne29@wanadoo.fr>
Thu, 23 Nov 2017 15:23:45 +0000 (16:23 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Thu, 23 Nov 2017 15:24:34 +0000 (16:24 +0100)
intern/atomic/atomic_ops.h
intern/atomic/intern/atomic_ops_ext.h
source/blender/blenkernel/intern/pbvh.c

index 7fab8f2ac57ed3efd943383eaea3aaf7c3851e51..578cfb76eb67961320dedc33daf79146ab6f00e4 100644 (file)
@@ -112,6 +112,9 @@ ATOMIC_INLINE uint8_t atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b);
 ATOMIC_INLINE int8_t atomic_fetch_and_or_int8(int8_t *p, int8_t b);
 ATOMIC_INLINE int8_t atomic_fetch_and_and_int8(int8_t *p, int8_t b);
 
+ATOMIC_INLINE char atomic_fetch_and_or_char(char *p, char b);
+ATOMIC_INLINE char atomic_fetch_and_and_char(char *p, char b);
+
 ATOMIC_INLINE size_t atomic_add_and_fetch_z(size_t *p, size_t x);
 ATOMIC_INLINE size_t atomic_sub_and_fetch_z(size_t *p, size_t x);
 ATOMIC_INLINE size_t atomic_fetch_and_add_z(size_t *p, size_t x);
index 34158a0b45edd44d488f6ac04b40f9bb4309e48b..51275e2b36bc93735b99cf4ba24924f3c5dfdca0 100644 (file)
@@ -179,6 +179,18 @@ ATOMIC_INLINE unsigned int atomic_cas_u(unsigned int *v, unsigned int old, unsig
 #endif
 }
 
+/******************************************************************************/
+/* Char operations. */
+ATOMIC_INLINE char atomic_fetch_and_or_char(char *p, char b)
+{
+       return (char)atomic_fetch_and_or_uint8((uint8_t *)p, (uint8_t)b);
+}
+
+ATOMIC_INLINE char atomic_fetch_and_and_char(char *p, char b)
+{
+       return (char)atomic_fetch_and_and_uint8((uint8_t *)p, (uint8_t)b);
+}
+
 /******************************************************************************/
 /* Pointer operations. */
 
index aa8ab07518f559dbe320840fb685d24a221125a8..39d1d8e8510a34854d5731d8b7687a93350a8d41 100644 (file)
@@ -1007,9 +1007,7 @@ static void pbvh_update_normals_store_task_cb(void *userdata, const int n)
                        MVert *mvert = &bvh->verts[v];
 
                        /* mvert is shared between nodes, hence between threads. */
-                       if (atomic_fetch_and_and_uint8(
-                               (uint8_t *)&mvert->flag, (uint8_t)~ME_VERT_PBVH_UPDATE) & ME_VERT_PBVH_UPDATE)
-                       {
+                       if (atomic_fetch_and_and_char(&mvert->flag, (char)~ME_VERT_PBVH_UPDATE) & ME_VERT_PBVH_UPDATE) {
                                normalize_v3(vnors[v]);
                                normal_float_to_short_v3(mvert->no, vnors[v]);
                        }