Created
January 9, 2019 08:27
-
-
Save buttercutter/615913259f6767b6bed169f48177e699 to your computer and use it in GitHub Desktop.
Modified https://github.com/KastnerRG/riffa/blob/master/driver/linux/circ_queue.h using kernel built-in ptr_ring struct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Filename: circ_ring.h | |
* Version: 1.0 | |
* Description: A circular buffer using API from | |
* https://github.com/torvalds/linux/blob/master/include/linux/ptr_ring.h | |
*/ | |
// enables https://github.com/torvalds/linux/blob/master/include/linux/ptr_ring.h#L24-L32 | |
#define __KERNEL__ 1 | |
#include <linux/ptr_ring.h> | |
#include <linux/mm.h> | |
// power-of-2 sized buffers | |
#define CIRC_BUFF_SIZE 8 | |
/** | |
* Initializes a circ_queue with depth/length len. Returns non-NULL on success, | |
* NULL if there was a problem creating the queue. | |
*/ | |
struct ptr_ring * init_circ_queue(int len); | |
/** | |
* Pushes a pair of unsigned int values into the specified queue at the head. | |
* Returns 0 on success, non-zero if there is no more space in the queue. | |
*/ | |
int push_circ_queue(struct ptr_ring * q, unsigned int val1, unsigned int val2); | |
/** | |
* Pops a pair of unsigned int values out of the specified queue from the tail. | |
* Returns 0 on success, non-zero if the queue is empty. | |
*/ | |
int pop_circ_queue(struct ptr_ring * q, unsigned int * val1, unsigned int * val2); | |
/** | |
* Frees the resources associated with the specified circ_queue. | |
*/ | |
void free_circ_queue(struct ptr_ring * q); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment