]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/util.h
Update bcachefs sources to 0d63ed13ea3d closures: Fix race in closure_sync()
[bcachefs-tools-debian] / libbcachefs / util.h
index 9eb86c58e5509d5d69efb52ef0f62562bea75026..67f1a1d2a02d31a22edb411c5f7057b6cc8326a5 100644 (file)
@@ -466,8 +466,10 @@ struct bch_pd_controller {
        s64                     last_change;
        s64                     last_target;
 
-       /* If true, the rate will not increase if bch2_ratelimit_delay()
-        * is not being called often enough. */
+       /*
+        * If true, the rate will not increase if bch2_ratelimit_delay()
+        * is not being called often enough.
+        */
        bool                    backpressure;
 };
 
@@ -603,6 +605,7 @@ static inline void __memcpy_u64s(void *dst, const void *src,
 {
 #ifdef CONFIG_X86_64
        long d0, d1, d2;
+
        asm volatile("rep ; movsq"
                     : "=&c" (d0), "=&D" (d1), "=&S" (d2)
                     : "0" (u64s), "1" (dst), "2" (src)
@@ -679,6 +682,7 @@ static inline void __memmove_u64s_up(void *_dst, const void *_src,
 
 #ifdef CONFIG_X86_64
        long d0, d1, d2;
+
        asm volatile("std ;\n"
                     "rep ; movsq\n"
                     "cld ;\n"
@@ -771,12 +775,12 @@ static inline void __move_gap(void *array, size_t element_size,
 
 #define bubble_sort(_base, _nr, _cmp)                                  \
 do {                                                                   \
-       ssize_t _i, _end;                                               \
+       ssize_t _i, _last;                                              \
        bool _swapped = true;                                           \
                                                                        \
-       for (_end = (ssize_t) (_nr) - 1; _end > 0 && _swapped; --_end) {\
+       for (_last= (ssize_t) (_nr) - 1; _last > 0 && _swapped; --_last) {\
                _swapped = false;                                       \
-               for (_i = 0; _i < _end; _i++)                           \
+               for (_i = 0; _i < _last; _i++)                          \
                        if (_cmp((_base)[_i], (_base)[_i + 1]) > 0) {   \
                                swap((_base)[_i], (_base)[_i + 1]);     \
                                _swapped = true;                        \
@@ -837,11 +841,11 @@ static inline int u8_cmp(u8 l, u8 r)
        return cmp_int(l, r);
 }
 
-#include <linux/uuid.h>
-
-static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2)
+static inline int cmp_le32(__le32 l, __le32 r)
 {
-       return memcmp(&u1, &u2, sizeof(uuid_le));
+       return cmp_int(le32_to_cpu(l), le32_to_cpu(r));
 }
 
+#include <linux/uuid.h>
+
 #endif /* _BCACHEFS_UTIL_H */