From 5ad59ad412a784c5c478e31d1701ce39568ffd58 Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Thu, 17 Aug 2017 16:27:20 +0200 Subject: [PATCH 1/1] 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 --- blob.c | 2 +- uci.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/blob.c b/blob.c index c8e5dc9..bc38a7f 100644 --- a/blob.c +++ b/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; } diff --git a/uci.h b/uci.h index c5583ed..43f2052 100644 --- a/uci.h +++ b/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 -- 2.11.0