<commit_before>/*
 * c-periphery
 * https://github.com/vsergeev/c-periphery
 * License: MIT
 */

#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

#include <sys/ioctl.h>
#include <linux/spi/spidev.h>

#include "spi.h"

static int _spi_error(struct spi_handle *spi, int code, int c_errno, const char *fmt, ...) {
    va_list ap;

    spi->error.c_errno = c_errno;

    va_start(ap, fmt);
    vsnprintf(spi->error.errmsg, sizeof(spi->error.errmsg), fmt, ap);
    va_end(ap);

    /* Tack on strerror() and errno */
    if (c_errno) {
        char buf[64];
        strerror_r(c_errno, buf, sizeof(buf));
        snprintf(spi->error.errmsg+strlen(spi->error.errmsg), sizeof(spi->error.errmsg)-strlen(spi->error.errmsg), ": %s [errno %d]", buf, c_errno);
    }

    return code;
}

int spi_open(spi_t *spi, const char *path, unsigned int mode, uint32_t max_speed) {
    return spi_open_advanced(spi, path, mode, max_speed, MSB_FIRST, 8, 0);
}<commit_msg>Add missing header for musl compatibility<commit_after>/*
 * c-periphery
 * https://github.com/vsergeev/c-periphery
 * License: MIT
 */

#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

#include <sys/ioctl.h>
#include <linux/ioctl.h>
#include <linux/spi/spidev.h>

#include "spi.h"

static int _spi_error(struct spi_handle *spi, int code, int c_errno, const char *fmt, ...) {
    va_list ap;

    spi->error.c_errno = c_errno;

    va_start(ap, fmt);
    vsnprintf(spi->error.errmsg, sizeof(spi->error.errmsg), fmt, ap);
    va_end(ap);

    /* Tack on strerror() and errno */
    if (c_errno) {
        char buf[64];
        strerror_r(c_errno, buf, sizeof(buf));
        snprintf(spi->error.errmsg+strlen(spi->error.errmsg), sizeof(spi->error.errmsg)-strlen(spi->error.errmsg), ": %s [errno %d]", buf, c_errno);
    }

    return code;
}

int spi_open(spi_t *spi, const char *path, unsigned int mode, uint32_t max_speed) {
    return spi_open_advanced(spi, path, mode, max_speed, MSB_FIRST, 8, 0);
}
{'fraction_non_alphanumeric': 0.16794929832503394, 'fraction_numerical': 0.005432322317790856, 'mean_word_length': 3.742489270386266, 'pattern_counts': {'":': 2, '<': 26, '<?xml version=': 0, '>': 40, 'https://': 2, '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': '6285205', 'n_tokens_mistral': 895, 'n_tokens_neox': 870, 'n_words': 191}