[llvm-branch-commits] [libc] [libc][annex_k] Add libc_constraint_handler macros. (PR #164092)
Victor Campos via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jul 13 05:27:42 PDT 2026
================
@@ -0,0 +1,44 @@
+//===-- Helper macros header for constraint violations ----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_ANNEX_K_MACROS_H
+#define LLVM_LIBC_SRC___SUPPORT_ANNEX_K_MACROS_H
+
+#include "libc_constraint_handler.h"
+#include "src/__support/libc_errno.h"
+
+#define _CONSTRAINT_VIOLATION(msg, error_code, ret_code) \
+ { \
+ libc_errno = error_code; \
+ libc_constraint_handler(msg, nullptr, error_code); \
+ return ret_code; \
+ }
----------------
vhscampos wrote:
How do you plan to use these macros? I think we should first implement a few Annex K functions before trying to have these helper macros. They could turn out to be unnecessary or poorly fit.
Because, for example, all the Annex K functions I have seen so far do not specify error codes or return codes. It's up to the libc implementation to decide the values.
So I think a PR such as this can wait a little.
https://github.com/llvm/llvm-project/pull/164092
More information about the llvm-branch-commits
mailing list