<commit_before>#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "block.h"
#include "gl_helpers.h"
#include "glouija/glouija.h"
#include "remote.h"
#include "wrap/gles.h"
#include "wrap/types.h"

#define GLOUIJA_CALL_INIT(ret_size)                            \
    {                                                          \
        .args = 1,                                             \
        .type = GLO_CALL_TYPE_CALL,                            \
        .arg = {                                               \
            {.type = GLO_ARG_TYPE_UINT, .data.ui = ret_size},  \
        0},                                                    \
    }


int remote_spawn(const char *path) {
    if (path == NULL) {
        path = "libgl_remote";
    }
    int fd = glouija_init_client();
    int pid = fork();
    if (pid == 0) {
        char *argv[] = {(char *)path, NULL, NULL};
        asprintf(&argv[1], "%d", fd);
        execve(path, argv, NULL);
        if (errno) {
            fprintf(stderr, "libGL: launching '%s' failed with %d (%s)\n", path, errno, strerror(errno));
        }
    }
    return pid;
}

static void write_memcpy(uintptr_t *dst, void *src, size_t size) {
    memcpy(*(void **)dst, src, size);
    *dst += size;
}

static void write_uint32(uintptr_t *dst, uint32_t i) {
    **(uint32_t **)dst = i;
    *dst += 4;
}

static void *read_ptr(uintptr_t *src, size_t size) {
    void *pos = (void *)*src;
    *src += size;
    return pos;
}

static uint32_t read_uint32(uintptr_t *src) {
    uint32_t i = *(uint32_t *)src;
    *src += 4;
    return i;
}

void *remote_serialize_block(block_t *block, size_t *ret_size) {<commit_msg>fix exec environment<commit_after>#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "block.h"
#include "gl_helpers.h"
#include "glouija/glouija.h"
#include "remote.h"
#include "wrap/gles.h"
#include "wrap/types.h"

#define GLOUIJA_CALL_INIT(ret_size)                            \
    {                                                          \
        .args = 1,                                             \
        .type = GLO_CALL_TYPE_CALL,                            \
        .arg = {                                               \
            {.type = GLO_ARG_TYPE_UINT, .data.ui = ret_size},  \
        0},                                                    \
    }


int remote_spawn(const char *path) {
    if (path == NULL) {
        path = "libgl_remote";
    }
    int fd = glouija_init_client();
    int pid = fork();
    if (pid == 0) {
        char *argv[] = {(char *)path, NULL, NULL};
        asprintf(&argv[1], "%d", fd);
        execvp(path, argv);
        if (errno) {
            fprintf(stderr, "libGL: launching '%s' failed with %d (%s)\n", path, errno, strerror(errno));
        }
    }
    return pid;
}

static void write_memcpy(uintptr_t *dst, void *src, size_t size) {
    memcpy(*(void **)dst, src, size);
    *dst += size;
}

static void write_uint32(uintptr_t *dst, uint32_t i) {
    **(uint32_t **)dst = i;
    *dst += 4;
}

static void *read_ptr(uintptr_t *src, size_t size) {
    void *pos = (void *)*src;
    *src += size;
    return pos;
}

static uint32_t read_uint32(uintptr_t *src) {
    uint32_t i = *(uint32_t *)src;
    *src += 4;
    return i;
}

void *remote_serialize_block(block_t *block, size_t *ret_size) {
{'fraction_non_alphanumeric': 0.14251991737975805, 'fraction_numerical': 0.011802891708468575, 'mean_word_length': 1.6197836166924267, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4463150', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1136, 'n_words': 267}