<commit_before>#include "HalideRuntime.h"

#include <stdarg.h>

#define WEAK __attribute__((weak))

extern "C" {

extern void __android_log_vprint(int, const char *, const char *, va_list);

extern uint32_t fwrite(void *, uint32_t, uint32_t, void *);
extern void *fopen(const char *, const char *);
extern void fclose(void *);

WEAK int halide_printf(const char * fmt, ...) {
    va_list args;
    va_start(args,fmt);
    __android_log_vprint(7, "halide", fmt, args);
    va_end(args);
    return 0;
}

static bool write_stub(const void *bytes, size_t size, void *f) {
    return fwrite(const_cast<void *>(bytes), size, 1, f) == 1;
}

WEAK int32_t halide_debug_to_file(const char *filename, uint8_t *data,
                                  int32_t s0, int32_t s1, int32_t s2, int32_t s3,
                                  int32_t type_code, int32_t bytes_per_element) {
    void *f = fopen(filename, "wb");
    if (!f) return -1;

    int result = halide_write_debug_image(filename, data, s0, s1, s2, s3,<commit_msg>halide_printf needs to return a nonzero value<commit_after>#include "HalideRuntime.h"

#include <stdarg.h>

#define WEAK __attribute__((weak))

extern "C" {

extern void __android_log_vprint(int, const char *, const char *, va_list);

extern uint32_t fwrite(void *, uint32_t, uint32_t, void *);
extern void *fopen(const char *, const char *);
extern void fclose(void *);

WEAK int halide_printf(const char * fmt, ...) {
    va_list args;
    va_start(args,fmt);
    __android_log_vprint(7, "halide", fmt, args);
    va_end(args);
    // Profiler assumes that return value <=0 is failure,
    // so return something else here.
    return 1;
}

static bool write_stub(const void *bytes, size_t size, void *f) {
    return fwrite(const_cast<void *>(bytes), size, 1, f) == 1;
}

WEAK int32_t halide_debug_to_file(const char *filename, uint8_t *data,
                                  int32_t s0, int32_t s1, int32_t s2, int32_t s3,
                                  int32_t type_code, int32_t bytes_per_element) {
    void *f = fopen(filename, "wb");
    if (!f) return -1;

    int result = halide_write_debug_image(filename, data, s0, s1, s2, s3,
{'fraction_non_alphanumeric': 0.12037037037037036, 'fraction_numerical': 0.03194444444444444, 'mean_word_length': 3.2962226640159047, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2458178', 'n_tokens_mistral': 822, 'n_tokens_neox': 773, 'n_words': 214}