<commit_before>#ifndef foowincompatfoo
#define foowincompatfoo

// This file and its companion wincompat.c provide some Posix interfaces to
// Windows APIs so the rest of the code can keep using them.


// require at least Windows Vista
#undef WINVER
#undef _WIN32_WINNT
#define WINVER 0x0600
#define _WIN32_WINNT WINVER

#include <winsock2.h>
#include <ws2tcpip.h>
#include <mswsock.h>


// wrappers around WSAStartup/WSACleanup to avoid clutter
void winsock_init(void);
void winsock_exit(void);


// the equivalent of strerror(errno) for Windows sockets
char *errnostrsocket(void);


// Winsock doesn't have recvmsg/sendmsg but offers the same functionality
// with WSARecvMsg/WSASendMsg, so we implement the former in terms of the
// latter.

struct iovec {                   /* Scatter/gather array items */
   void  *iov_base;              /* Starting address */
   size_t iov_len;               /* Number of bytes to transfer */
};

struct msghdr {
   void         *msg_name;       /* optional address */
   socklen_t     msg_namelen;    /* size of address */
   struct iovec *msg_iov;        /* scatter/gather array */
   size_t        msg_iovlen;     /* # elements in msg_iov */
   void         *msg_control;    /* ancillary data, see below */
   size_t        msg_controllen; /* ancillary data buffer len */
   int           msg_flags;      /* flags on received message */
};

// MSDN says this struct is called wsacmsghdr but MingW uses _WSACMSGHDR.
// TODO: Verify what it is on actual Windows.
// cf. http://msdn.microsoft.com/en-us/library/ms741645(v=vs.85).aspx
#ifdef __MINGW32__
#define cmsghdr _WSACMSGHDR     // as in 'struct cmsghdr'
#else
#define cmsghdr wsacmsghdr      // as in 'struct cmsghdr'
#endif

static inline struct cmsghdr *CMSG_FIRSTHDR(struct msghdr *m) {
    WSAMSG wm;
    wm.Control.len = m->msg_controllen;
    wm.Control.buf = m->msg_control;
    return WSA_CMSG_FIRSTHDR(&wm);
}

static inline struct cmsghdr *CMSG_NXTHDR(struct msghdr *m, struct cmsghdr *c) {
    WSAMSG wm;
    wm.Control.len = m->msg_controllen;
    wm.Control.buf = m->msg_control;
    return WSA_CMSG_NXTHDR(&wm, c);
}

#define CMSG_SPACE(len) WSA_CMSG_SPACE(len)
#define CMSG_LEN(len) WSA_CMSG_LEN(len)<commit_msg>avoid implicit conversion from void* to char*<commit_after>#ifndef foowincompatfoo
#define foowincompatfoo

// This file and its companion wincompat.c provide some Posix interfaces to
// Windows APIs so the rest of the code can keep using them.


// require at least Windows Vista
#undef WINVER
#undef _WIN32_WINNT
#define WINVER 0x0600
#define _WIN32_WINNT WINVER

#include <winsock2.h>
#include <ws2tcpip.h>
#include <mswsock.h>


// wrappers around WSAStartup/WSACleanup to avoid clutter
void winsock_init(void);
void winsock_exit(void);


// the equivalent of strerror(errno) for Windows sockets
char *errnostrsocket(void);


// Winsock doesn't have recvmsg/sendmsg but offers the same functionality
// with WSARecvMsg/WSASendMsg, so we implement the former in terms of the
// latter.

struct iovec {                   /* Scatter/gather array items */
   void  *iov_base;              /* Starting address */
   size_t iov_len;               /* Number of bytes to transfer */
};

struct msghdr {
   void         *msg_name;       /* optional address */
   socklen_t     msg_namelen;    /* size of address */
   struct iovec *msg_iov;        /* scatter/gather array */
   size_t        msg_iovlen;     /* # elements in msg_iov */
   void         *msg_control;    /* ancillary data, see below */
   size_t        msg_controllen; /* ancillary data buffer len */
   int           msg_flags;      /* flags on received message */
};

// MSDN says this struct is called wsacmsghdr but MingW uses _WSACMSGHDR.
// TODO: Verify what it is on actual Windows.
// cf. http://msdn.microsoft.com/en-us/library/ms741645(v=vs.85).aspx
#ifdef __MINGW32__
#define cmsghdr _WSACMSGHDR     // as in 'struct cmsghdr'
#else
#define cmsghdr wsacmsghdr      // as in 'struct cmsghdr'
#endif

static inline struct cmsghdr *CMSG_FIRSTHDR(struct msghdr *m) {
    WSAMSG wm;
    wm.Control.len = m->msg_controllen;
    wm.Control.buf = reinterpret_cast<char*>(m->msg_control);
    return WSA_CMSG_FIRSTHDR(&wm);
}

static inline struct cmsghdr *CMSG_NXTHDR(struct msghdr *m, struct cmsghdr *c) {
    WSAMSG wm;
    wm.Control.len = m->msg_controllen;
    wm.Control.buf = reinterpret_cast<char*>(m->msg_control);
    return WSA_CMSG_NXTHDR(&wm, c);
}

#define CMSG_SPACE(len) WSA_CMSG_SPACE(len)
#define CMSG_LEN(len) WSA_CMSG_LEN(len)
{'fraction_non_alphanumeric': 0.09792677547419497, 'fraction_numerical': 0.009263343625937363, 'mean_word_length': 3.0892696122633003, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '5977498', 'n_tokens_mistral': 1612, 'n_tokens_neox': 1537, 'n_words': 449}