166d00febSPaula Toth //===-- Implementation of __assert_fail -----------------------------------===//
2b47c9f53SAlex Brachet //
3b47c9f53SAlex Brachet // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4b47c9f53SAlex Brachet // See https://llvm.org/LICENSE.txt for license information.
5b47c9f53SAlex Brachet // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6b47c9f53SAlex Brachet //
7b47c9f53SAlex Brachet //===----------------------------------------------------------------------===//
8b47c9f53SAlex Brachet 
9*70ae480cSAlex Brachet #include "src/__support/OSUtil/io.h"
105080840dSMichael Jones #include "src/assert/__assert_fail.h"
11b47c9f53SAlex Brachet #include "src/stdlib/abort.h"
12b47c9f53SAlex Brachet 
13b47c9f53SAlex Brachet namespace __llvm_libc {
14b47c9f53SAlex Brachet 
15a0b65a7bSMichael Jones LLVM_LIBC_FUNCTION(void, __assert_fail,
16a0b65a7bSMichael Jones                    (const char *assertion, const char *file, unsigned line,
17a0b65a7bSMichael Jones                     const char *function)) {
181c92911eSMichael Jones   write_to_stderr(file);
191c92911eSMichael Jones   write_to_stderr(": Assertion failed: '");
201c92911eSMichael Jones   write_to_stderr(assertion);
211c92911eSMichael Jones   write_to_stderr("' in function: '");
221c92911eSMichael Jones   write_to_stderr(function);
231c92911eSMichael Jones   write_to_stderr("'\n");
24b47c9f53SAlex Brachet   __llvm_libc::abort();
25b47c9f53SAlex Brachet }
26b47c9f53SAlex Brachet 
27b47c9f53SAlex Brachet } // namespace __llvm_libc
28