forked from google/highway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Abort definition from targets.cc
This allows compilation without the dynamic dispatch machinery and gives an example of the interface for the `Abort` function should you wish to write your own.
- Loading branch information
Showing
4 changed files
with
45 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# Copyright 2019 Google LLC | ||
# Copyright 2024 Arm Limited and/or its affiliates <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -132,6 +135,7 @@ list(APPEND HWY_CONTRIB_SOURCES | |
endif() # HWY_ENABLE_CONTRIB | ||
|
||
set(HWY_SOURCES | ||
hwy/abort.cc | ||
hwy/aligned_allocator.cc | ||
hwy/aligned_allocator.h | ||
hwy/base.h | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2019 Google LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdarg.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
#include "hwy/base.h" | ||
|
||
namespace hwy { | ||
|
||
HWY_DLLEXPORT HWY_NORETURN void HWY_FORMAT(3, 4) | ||
Abort(const char* file, int line, const char* format, ...) { | ||
char buf[800]; | ||
va_list args; | ||
va_start(args, format); | ||
vsnprintf(buf, sizeof(buf), format, args); | ||
va_end(args); | ||
|
||
fprintf(stderr, "Abort at %s:%d: %s\n", file, line, buf); | ||
|
||
// If compiled with any sanitizer, they can also print a stack trace. | ||
#if HWY_IS_ASAN || HWY_IS_MSAN || HWY_IS_TSAN | ||
__sanitizer_print_stack_trace(); | ||
#endif // HWY_IS_* | ||
fflush(stderr); | ||
|
||
// Now terminate the program: | ||
#if HWY_ARCH_RVV | ||
exit(1); // trap/abort just freeze Spike. | ||
#elif HWY_IS_DEBUG_BUILD && !HWY_COMPILER_MSVC | ||
// Facilitates breaking into a debugger, but don't use this in non-debug | ||
// builds because it looks like "illegal instruction", which is misleading. | ||
__builtin_trap(); | ||
#else | ||
abort(); // Compile error without this due to HWY_NORETURN. | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters