Browse Source

Add bitfield_set function from libubox.

The bitfield functions and macros where removed from libubox. Add the
bitfield_set function which is used by uci, and prefix it with uci_.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Stijn Tintel 6 years ago
parent
commit
5ad59ad412
2 changed files with 10 additions and 1 deletions
  1. 1 1
      blob.c
  2. 9 0
      uci.h

+ 1 - 1
blob.c

@@ -188,7 +188,7 @@ uci_blob_diff(struct blob_attr **tb1, struct blob_attr **tb2,
 mark:
 		ret = true;
 		if (diff)
-			bitfield_set(diff, i);
+			uci_bitfield_set(diff, i);
 		else
 			return ret;
 	}

+ 9 - 0
uci.h

@@ -689,6 +689,15 @@ uci_lookup_option_string(struct uci_context *ctx, struct uci_section *s, const c
 	return o->v.string;
 }
 
+#ifndef BITS_PER_LONG
+#define BITS_PER_LONG (8 * sizeof(unsigned long))
+#endif
+
+static inline void uci_bitfield_set(unsigned long *bits, int bit)
+{
+	bits[bit / BITS_PER_LONG] |= (1UL << (bit % BITS_PER_LONG));
+}
+
 #ifdef __cplusplus
 }
 #endif