<commit_before>/* automaton
 * (c) 2013 <NAME>
 * The source code of this project is distributed under the terms of the
 * simplified BSD license. See the LICENSE file for details.
 */


#ifndef AUTOMATON_ALGO_FIFO_H
#define AUTOMATON_ALGO_FIFO_H


#include "std.h"


/* cannot exceed 256; power of two is preferred (AND instead of MOD) */
#define FIFO_SIZE 16


struct fifo {
	uint8_t data[FIFO_SIZE];
	
	uint8_t len;
	
	uint8_t i_push;
	uint8_t i_pop;
};


/* nonatomic: get number of values in fifo */
static inline uint8_t fifo_count(volatile struct fifo *fifo) {
	return fifo->len;
}

/* nonatomic: get number of free spaces in fifo */
static inline uint8_t fifo_free(volatile struct fifo *fifo) {
	return (FIFO_SIZE - fifo->len);
}


void fifo_init(volatile struct fifo *fifo);

bool fifo_push(volatile struct fifo *fifo, uint8_t val);
bool fifo_push_wait(volatile struct fifo *fifo, uint8_t val,
	uint16_t timeout_ms);
void fifo_push_force(volatile struct fifo *fifo, uint8_t val);

bool fifo_pop(volatile struct fifo *fifo, uint8_t *out);
bool fifo_pop_wait(volatile struct fifo *fifo, uint8_t *out,
	uint16_t timeout_ms);


#endif
<commit_msg>algo/fifo: use const fifo ptr in fifo_{count,free}<commit_after>/* automaton
 * (c) 2013 <NAME>
 * The source code of this project is distributed under the terms of the
 * simplified BSD license. See the LICENSE file for details.
 */


#ifndef AUTOMATON_ALGO_FIFO_H
#define AUTOMATON_ALGO_FIFO_H


#include "std.h"


/* cannot exceed 256; power of two is preferred (AND instead of MOD) */
#define FIFO_SIZE 16


struct fifo {
	uint8_t data[FIFO_SIZE];
	
	uint8_t len;
	
	uint8_t i_push;
	uint8_t i_pop;
};


/* nonatomic: get number of values in fifo */
static inline uint8_t fifo_count(const volatile struct fifo *fifo) {
	return fifo->len;
}

/* nonatomic: get number of free spaces in fifo */
static inline uint8_t fifo_free(const volatile struct fifo *fifo) {
	return (FIFO_SIZE - fifo->len);
}


void fifo_init(volatile struct fifo *fifo);

bool fifo_push(volatile struct fifo *fifo, uint8_t val);
bool fifo_push_wait(volatile struct fifo *fifo, uint8_t val,
	uint16_t timeout_ms);
void fifo_push_force(volatile struct fifo *fifo, uint8_t val);

bool fifo_pop(volatile struct fifo *fifo, uint8_t *out);
bool fifo_pop_wait(volatile struct fifo *fifo, uint8_t *out,
	uint16_t timeout_ms);


#endif

{'fraction_non_alphanumeric': 0.08882277943051424, 'fraction_numerical': 0.020399490012749683, 'mean_word_length': 4.713592233009709, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '570339', 'n_tokens_mistral': 921, 'n_tokens_neox': 857, 'n_words': 284}