Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/kfifo.h
| Show All 27 Lines | |||||
| #ifndef _LINUXKPI_LINUX_KFIFO_H_ | #ifndef _LINUXKPI_LINUX_KFIFO_H_ | ||||
| #define _LINUXKPI_LINUX_KFIFO_H_ | #define _LINUXKPI_LINUX_KFIFO_H_ | ||||
| #include <sys/types.h> | #include <sys/types.h> | ||||
| #include <linux/slab.h> | #include <linux/slab.h> | ||||
| #include <linux/gfp.h> | #include <linux/gfp.h> | ||||
| #define INIT_KFIFO(x) 0 | /* | ||||
| #define DECLARE_KFIFO(x, y, z) | * INIT_KFIFO() is used to initialize the structure declared with | ||||
| * DECLARE_KFIFO(). It doesn't work with DECLARE_KFIFO_PTR(). | |||||
| */ | |||||
| #define INIT_KFIFO(_kf) \ | |||||
| ({ \ | |||||
| (_kf).total = sizeof((_kf).head) / sizeof(*(_kf).head); \ | |||||
bz: That's nitems(), could use it if you wanted. | |||||
| (_kf).count = 0; \ | |||||
| (_kf).first = 0; \ | |||||
| (_kf).last = 0; \ | |||||
| }) | |||||
| #define DECLARE_KFIFO(_name, _type, _size) \ | |||||
| struct kfifo_ ## _name { \ | |||||
| size_t total; \ | |||||
| size_t count; \ | |||||
| size_t first; \ | |||||
| size_t last; \ | |||||
| _type head[_size]; \ | |||||
| } _name | |||||
| #define DECLARE_KFIFO_PTR(_name, _type) \ | #define DECLARE_KFIFO_PTR(_name, _type) \ | ||||
| struct kfifo_ ## _name { \ | struct kfifo_ ## _name { \ | ||||
| size_t total; \ | size_t total; \ | ||||
| size_t count; \ | size_t count; \ | ||||
| size_t first; \ | size_t first; \ | ||||
| size_t last; \ | size_t last; \ | ||||
| _type *head; \ | _type *head; \ | ||||
| ▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines | |||||
That's nitems(), could use it if you wanted.