remove internal usage of redundant uci_ptr.last
[project/uci.git] / uci.h
diff --git a/uci.h b/uci.h
index c5583ed0f798a081e964ba120760c59d179b36e2..d0374f20a00bd4dfb5a900eb39b30beba1e50c55 100644 (file)
--- a/uci.h
+++ b/uci.h
@@ -34,6 +34,7 @@ extern "C" {
 #include <setjmp.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <stddef.h>
 
 #define UCI_CONFDIR "/etc/config"
 #define UCI_SAVEDIR "/tmp/.uci"
@@ -509,11 +510,6 @@ struct uci_parse_option {
 };
 
 
-/* linked list handling */
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
 /**
  * container_of - cast a member of a structure out to the containing structure
  * @ptr:    the pointer to the member.
@@ -617,16 +613,6 @@ BUILD_CAST(option)
 #define uci_to_option(ptr)  container_of(ptr, struct uci_option, e)
 #endif
 
-/**
- * uci_alloc_element: allocate a generic uci_element, reserve a buffer and typecast
- * @ctx: uci context
- * @type: {package,section,option}
- * @name: string containing the name of the element
- * @datasize: additional buffer size to reserve at the end of the struct
- */
-#define uci_alloc_element(ctx, type, name, datasize) \
-       uci_to_ ## type (uci_alloc_generic(ctx, uci_type_ ## type, name, sizeof(struct uci_ ## type) + datasize))
-
 #define uci_dataptr(ptr) \
        (((char *) ptr) + sizeof(*ptr))
 
@@ -689,6 +675,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