| 1 |
// SPDX-License-Identifier: MPL-2.0 |
| 2 |
// (c) Hare authors <https://harelang.org> |
| 3 |
|
| 4 |
fn strvec(s: str) iovec = { |
| 5 |
return iovec { |
| 6 |
iov_base = *(&s: **opaque), |
| 7 |
iov_len = len(s), |
| 8 |
}; |
| 9 |
}; |
| 10 |
|
| 11 |
fn platform_abort(path: *str, line: u64, col: u64, msg: str) never = { |
| 12 |
let linebuf: [U64_BUFSZ]u8 = [0...]; |
| 13 |
let colbuf: [U64_BUFSZ]u8 = [0...]; |
| 14 |
|
| 15 |
const iov = [ |
| 16 |
strvec("Abort: "), |
| 17 |
strvec(*path), |
| 18 |
strvec(":"), |
| 19 |
strvec(u64tos(linebuf, line)), |
| 20 |
strvec(":"), |
| 21 |
strvec(u64tos(colbuf, col)), |
| 22 |
strvec(": "), |
| 23 |
strvec(msg), |
| 24 |
strvec("\n"), |
| 25 |
]; |
| 26 |
_ = writev(STDERR_FILENO, &iov, len(iov): int); |
| 27 |
|
| 28 |
for (true) { |
| 29 |
_ = kill(getpid(), SIGABRT); |
| 30 |
}; |
| 31 |
}; |