<commit_before>#ifndef _LIBSOC_GPIO_H_
#define _LIBSOC_GPIO_H_

#include <poll.h>
#include <pthread.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \struct gpio_callback
 * \brief representation of an interrupt callback
 * \param int (*callback_fn)(void*) - the function to callback on interrupt
 * \param void *callback_arg - the argument to pass to the callback function
 * \param pthread_t *thread - the pthread struct on which the poll and
 *  callback function runs
 * \param int ready - signal when the pthread is ready to accept interrupts
 */

struct gpio_callback {
	int (*callback_fn) (void *);
	void *callback_arg;
	pthread_t *thread;
	pthread_mutex_t ready;
};

/**
 * \struct gpio
 * \brief representation of a single requested gpio
 * \param unsigned int gpio gpio id
 * \param int value_fd file descriptor to gpio value file
 * \param struct gpio_callback *callback - struct used to store interrupt
 *  callback data
 * \param int shared - set if the request flag was shared and the GPIO was
 *  exported on request
 */

typedef struct {
	unsigned int gpio;
	int value_fd;
	struct gpio_callback *callback;
	struct pollfd pfd;
	int shared;
} gpio;

/**
 * \enum gpio_int_ret
 * \brief defined values for return type of blocked gpio interrupts
 */

typedef enum {
	LS_INT_ERROR = EXIT_FAILURE,
	LS_INT_TRIGGERED = EXIT_SUCCESS,
	LS_INT_TIMEOUT,
} gpio_int_ret;

/**
 * \enum gpio_direction
 * \brief defined values for input/output direction
 */

typedef enum {
	DIRECTION_ERROR = -1,
	INPUT = 0,
	OUTPUT = 1,
} gpio_direction;

/**
 * \enum gpio_level
 * \brief defined values for high/low gpio level
 */

typedef enum {
	LEVEL_ERROR = -1,
	LOW = 0,
	HIGH = 1,
} gpio_level;

/**
 * \enum gpio_edge<commit_msg>gpio: fix 'gpio_int_ret' enum, 'LS_INT_ERROR' and 'LS_INT_TIMEOUT' same value<commit_after>#ifndef _LIBSOC_GPIO_H_
#define _LIBSOC_GPIO_H_

#include <poll.h>
#include <pthread.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \struct gpio_callback
 * \brief representation of an interrupt callback
 * \param int (*callback_fn)(void*) - the function to callback on interrupt
 * \param void *callback_arg - the argument to pass to the callback function
 * \param pthread_t *thread - the pthread struct on which the poll and
 *  callback function runs
 * \param int ready - signal when the pthread is ready to accept interrupts
 */

struct gpio_callback {
	int (*callback_fn) (void *);
	void *callback_arg;
	pthread_t *thread;
	pthread_mutex_t ready;
};

/**
 * \struct gpio
 * \brief representation of a single requested gpio
 * \param unsigned int gpio gpio id
 * \param int value_fd file descriptor to gpio value file
 * \param struct gpio_callback *callback - struct used to store interrupt
 *  callback data
 * \param int shared - set if the request flag was shared and the GPIO was
 *  exported on request
 */

typedef struct {
	unsigned int gpio;
	int value_fd;
	struct gpio_callback *callback;
	struct pollfd pfd;
	int shared;
} gpio;

/**
 * \enum gpio_int_ret
 * \brief defined values for return type of blocked gpio interrupts
 */

typedef enum {
	LS_INT_TRIGGERED = EXIT_SUCCESS,
	LS_INT_ERROR = EXIT_FAILURE,
	LS_INT_TIMEOUT,
} gpio_int_ret;

/**
 * \enum gpio_direction
 * \brief defined values for input/output direction
 */

typedef enum {
	DIRECTION_ERROR = -1,
	INPUT = 0,
	OUTPUT = 1,
} gpio_direction;

/**
 * \enum gpio_level
 * \brief defined values for high/low gpio level
 */

typedef enum {
	LEVEL_ERROR = -1,
	LOW = 0,
	HIGH = 1,
} gpio_level;

/**
 * \enum gpio_edge
{'fraction_non_alphanumeric': 0.09218662169758292, 'fraction_numerical': 0.003372681281618887, 'mean_word_length': 3.7900403768506057, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5184685', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1189, 'n_words': 417}