<commit_before>#ifndef CIRCULAR_BUFFER_H
#define CIRCULAR_BUFFER_H

#include <semaphore.h>

struct circular_buffer {
	char *buffer;
	int length;
	int tail;
	int head;
	sem_t mutex;
};

struct circular_buffer *circular_buffer_create(int length);
void circular_buffer_destroy(struct circular_buffer *buffer);
int circular_buffer_read(struct circular_buffer *buffer, char *target, int amount);
int circular_buffer_write(struct circular_buffer *buffer, char *data, int length);
int circular_buffer_empty(struct circular_buffer *buffer);
int circular_buffer_full(struct circular_buffer *buffer);
int circular_buffer_available_data(struct circular_buffer *buffer);
int circular_buffer_available_space(struct circular_buffer *buffer);
void circular_buffer_debug(struct circular_buffer *buf);
void circular_buffer_clear(struct circular_buffer *buf);

#define circular_buffer_full(B) (circular_buffer_available_space((B)) == 0)
#define circular_buffer_empty(B) (circular_buffer_available_data((B)) == 0)
#define circular_buffer_starts_at(B) ((B)->buffer + (B)->tail)
#define circular_buffer_ends_at(B) ((B)->buffer + (B)->head)
#define circular_buffer_commit_read(B, A) ((B)->tail = ((B)->tail + (A)) % (B)->length)
#define circular_buffer_commit_write(B, A) ((B)->head = ((B)->head + (A)) % (B)->length)

#endif /* CIRCULAR_BUFFER_H */
<commit_msg>Fixed linking error; when compiling C++ couldn't find C functions.<commit_after>#ifndef CIRCULAR_BUFFER_H
#define CIRCULAR_BUFFER_H

#include <semaphore.h>

#ifdef __cplusplus
extern "C" {
#endif

struct circular_buffer {
	char *buffer;
	int length;
	int tail;
	int head;
	sem_t mutex;
};

struct circular_buffer *circular_buffer_create(int length);
void circular_buffer_destroy(struct circular_buffer *buffer);
int circular_buffer_read(struct circular_buffer *buffer, char *target, int amount);
int circular_buffer_write(struct circular_buffer *buffer, char *data, int length);
int circular_buffer_empty(struct circular_buffer *buffer);
int circular_buffer_full(struct circular_buffer *buffer);
int circular_buffer_available_data(struct circular_buffer *buffer);
int circular_buffer_available_space(struct circular_buffer *buffer);
void circular_buffer_debug(struct circular_buffer *buf);
void circular_buffer_clear(struct circular_buffer *buf);

#define circular_buffer_full(B) (circular_buffer_available_space((B)) == 0)
#define circular_buffer_empty(B) (circular_buffer_available_data((B)) == 0)
#define circular_buffer_starts_at(B) ((B)->buffer + (B)->tail)
#define circular_buffer_ends_at(B) ((B)->buffer + (B)->head)
#define circular_buffer_commit_read(B, A) ((B)->tail = ((B)->tail + (A)) % (B)->length)
#define circular_buffer_commit_write(B, A) ((B)->head = ((B)->head + (A)) % (B)->length)

#ifdef __cplusplus
}
#endif

#endif /* CIRCULAR_BUFFER_H */

{'fraction_non_alphanumeric': 0.1252676659528908, 'fraction_numerical': 0.0014275517487508922, 'mean_word_length': 8.566552901023892, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '7422572', 'n_tokens_mistral': 915, 'n_tokens_neox': 900, 'n_words': 213}