cb_mux.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Acutam Automation, LLC
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
29 #ifndef CB_MUX_H
30 #define CB_MUX_H
31 
32 #include <stdint.h>
33 
34 /* For alternate cb_mux_cbid_t */
35 #include "periph_cpu.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #ifndef HAVE_CB_MUX_CBID_T
42 
45 typedef unsigned int cb_mux_cbid_t;
46 #endif
47 
51 typedef void (*cb_mux_cb_t)(void *);
52 
56 typedef struct cb_mux {
57  struct cb_mux *next;
59  void *info;
61  void *arg;
62 } cb_mux_t;
63 
67 typedef void (*cb_mux_iter_t)(cb_mux_t *, void *);
68 
75 void cb_mux_add(cb_mux_t **head, cb_mux_t *entry);
76 
83 void cb_mux_del(cb_mux_t **head, cb_mux_t *entry);
84 
94 
105 
116 
127 
135 void cb_mux_iter(cb_mux_t *head, cb_mux_iter_t func, void *arg);
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
143 #endif /* CB_MUX_H */
cb_mux::arg
void * arg
argument for callback function
Definition: cb_mux.h:61
cb_mux_cb_t
void(* cb_mux_cb_t)(void *)
cb_mux callback type
Definition: cb_mux.h:51
cb_mux::info
void * info
optional extra information
Definition: cb_mux.h:59
cb_mux_add
void cb_mux_add(cb_mux_t **head, cb_mux_t *entry)
Add a new entry to the end of a cb_mux list.
cb_mux_find_high
cb_mux_t * cb_mux_find_high(cb_mux_t *head)
Find the entry with the highest ID.
cb_mux
cb_mux list entry structure
Definition: cb_mux.h:56
cb_mux_t
struct cb_mux cb_mux_t
cb_mux list entry structure
cb_mux_iter
void cb_mux_iter(cb_mux_t *head, cb_mux_iter_t func, void *arg)
Run a function on every item in the cb_mux list.
cb_mux::cb
cb_mux_cb_t cb
callback function
Definition: cb_mux.h:60
cb_mux::cbid
cb_mux_cbid_t cbid
identifier for this callback
Definition: cb_mux.h:58
cb_mux::next
struct cb_mux * next
next entry in the cb_mux list
Definition: cb_mux.h:57
cb_mux_del
void cb_mux_del(cb_mux_t **head, cb_mux_t *entry)
Remove a entry from a cb_mux list.
cb_mux_find_free_id
cb_mux_cbid_t cb_mux_find_free_id(cb_mux_t *head)
Find the lowest unused ID.
cb_mux_find_low
cb_mux_t * cb_mux_find_low(cb_mux_t *head)
Find the entry with the lowest ID.
cb_mux_find_cbid
cb_mux_t * cb_mux_find_cbid(cb_mux_t *head, cb_mux_cbid_t cbid_val)
Find an entry in the list by ID.
cb_mux_iter_t
void(* cb_mux_iter_t)(cb_mux_t *, void *)
cb_mux iterate function callback type for cb_mux_iter
Definition: cb_mux.h:67
cb_mux_cbid_t
unsigned int cb_mux_cbid_t
cb_mux identifier type
Definition: cb_mux.h:45