summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-11-14 18:14:24 +0100
committerPatrick McHardy <kaber@trash.net>2010-11-14 19:09:33 +0100
commit582a7d50c70492776d9f1be4a9c9b1cdb0b6103e (patch)
tree8f41e14b60603a1a85ff5ab5984951602c8d80f6
parent3c8698333bb75e5d25b5df2a0f9bacd0e1a63f93 (diff)
libdect: support allocating per-handle private space
Similar to other objects, support a private data area for libdect handles for applications dealing with multiple handles simultenously. Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--include/dect/libdect.h4
-rw-r--r--include/libdect.h2
-rw-r--r--src/libdect.c8
3 files changed, 13 insertions, 1 deletions
diff --git a/include/dect/libdect.h b/include/dect/libdect.h
index 4cb7eb9..771d0f1 100644
--- a/include/dect/libdect.h
+++ b/include/dect/libdect.h
@@ -127,6 +127,8 @@ struct dect_event_ops {
* The DECT ops contain references to the individual ops of the libdect subsystems.
*/
struct dect_ops {
+ size_t priv_size;
+
void *(*malloc)(size_t size);
void (*free)(void *ptr);
@@ -144,6 +146,8 @@ extern struct dect_handle *dect_open_handle(struct dect_ops *ops,
const char *cluster);
extern void dect_close_handle(struct dect_handle *dh);
+extern void *dect_handle_priv(struct dect_handle *dh);
+
extern void dect_pp_set_ipui(struct dect_handle *dh,
const struct dect_ipui *ipui);
extern void dect_pp_set_tpui(struct dect_handle *dh,
diff --git a/include/libdect.h b/include/libdect.h
index f0bf943..7c3ff83 100644
--- a/include/libdect.h
+++ b/include/libdect.h
@@ -53,6 +53,8 @@ struct dect_handle {
struct list_head links;
struct list_head mme_list;
+
+ uint8_t priv[] __aligned(__alignof__(uint64_t));
};
#endif /* _LIBDECT_H */
diff --git a/src/libdect.c b/src/libdect.c
index cf89591..ea6f37c 100644
--- a/src/libdect.c
+++ b/src/libdect.c
@@ -31,7 +31,7 @@ static struct dect_handle *dect_alloc_handle(struct dect_ops *ops)
if (ops->free == NULL)
ops->free = free;
- dh = ops->malloc(sizeof(*dh));
+ dh = ops->malloc(sizeof(*dh) + ops->priv_size);
if (dh == NULL)
return NULL;
memset(dh, 0, sizeof(*dh));
@@ -92,4 +92,10 @@ void dect_close_handle(struct dect_handle *dh)
}
EXPORT_SYMBOL(dect_close_handle);
+void *dect_handle_priv(struct dect_handle *dh)
+{
+ return dh->priv;
+}
+EXPORT_SYMBOL(dect_handle_priv);
+
/** @} */