https://github.com/halide/Halide
Raw File
Tip revision: fa88d14ff1358d7308a64f2ffa19098d32161146 authored by Andrew Adams on 01 February 2024, 01:19:21 UTC
Fix type error in VectorizeLoops
Tip revision: fa88d14
posix_error_handler.cpp
#include "HalideRuntime.h"
#include "printer.h"
#include "runtime_internal.h"

extern "C" {

extern void abort();

WEAK void halide_default_error(void *user_context, const char *msg) {
    // Can't use StackBasicPrinter here because it limits size to 256
    constexpr int buf_size = 4096;
    char buf[buf_size];
    PrinterBase dst(user_context, buf, buf_size);
    dst << "Error: " << msg;
    const char *d = dst.str();
    if (d && *d && d[strlen(d) - 1] != '\n') {
        dst << "\n";
    }
    halide_print(user_context, dst.str());
    abort();
}
}

namespace Halide {
namespace Runtime {
namespace Internal {

WEAK halide_error_handler_t error_handler = halide_default_error;

}
}  // namespace Runtime
}  // namespace Halide

extern "C" {

WEAK void halide_error(void *user_context, const char *msg) {
    (*error_handler)(user_context, msg);
}

WEAK halide_error_handler_t halide_set_error_handler(halide_error_handler_t handler) {
    halide_error_handler_t result = error_handler;
    error_handler = handler;
    return result;
}
}
back to top