Skip to content

Commit

Permalink
[libc] Support LIBC_COPT_USE_C_ASSERT build flag
Browse files Browse the repository at this point in the history
In this mode, LIBC_ASSERT is just standard C assert.

Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D151498
  • Loading branch information
frobtech committed May 25, 2023
1 parent 1d4e8f0 commit 65c7893
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libc/src/__support/libc_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
#ifndef LLVM_LIBC_SRC_SUPPORT_LIBC_ASSERT_H
#define LLVM_LIBC_SRC_SUPPORT_LIBC_ASSERT_H

#ifdef LIBC_COPT_USE_C_ASSERT

// The build is configured to just use the public <assert.h> API
// for libc's internal assertions.

#include <assert.h>

#define LIBC_ASSERT(COND) assert(COND)

#else // Not LIBC_COPT_USE_C_ASSERT

#include "src/__support/OSUtil/io.h"
#include "src/__support/OSUtil/quick_exit.h"
#include "src/__support/integer_to_string.h"
Expand Down Expand Up @@ -58,4 +69,6 @@ LIBC_INLINE void report_assertion_failure(const char *assertion,
} while (false)
#endif // NDEBUG

#endif // LIBC_COPT_USE_C_ASSERT

#endif // LLVM_LIBC_SRC_SUPPORT_LIBC_ASSERT_H

0 comments on commit 65c7893

Please sign in to comment.