From e8aa6f90d6e8c69f3af32942d0ae2bdf44e34783 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Sun, 14 Mar 2021 22:43:03 -0600 Subject: stage2 llvm bindings: use correct type for LLVMBool for ABI compat --- src/codegen/llvm/bindings.zig | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/codegen/llvm') diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig index ff385efd08..7217ca381e 100644 --- a/src/codegen/llvm/bindings.zig +++ b/src/codegen/llvm/bindings.zig @@ -1,7 +1,20 @@ //! We do this instead of @cImport because the self-hosted compiler is easier //! to bootstrap if it does not depend on translate-c. -const Bool = bool; +/// Do not compare directly to .True, use toBool() instead. +pub const Bool = enum(c_int) { + False, + True, + _, + + pub fn fromBool(b: bool) Bool { + return @intToEnum(Bool, @boolToInt(b)); + } + + pub fn toBool(b: Bool) bool { + return b != .False; + } +}; pub const AttributeIndex = c_uint; /// Make sure to use the *InContext functions instead of the global ones. -- cgit v1.2.3