Skip to content

Commit

Permalink
fix: build errors on linux arm64
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Jan 15, 2024
1 parent 1742047 commit f016975
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion kclvm/runtime/src/api/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2021 The KCL Authors. All rights reserved.
#![allow(clippy::missing_safety_doc)]

use std::os::raw::c_char;

use crate::{Context, ValueRef};

/// New a mutable raw pointer.
Expand Down Expand Up @@ -35,7 +37,7 @@ pub(crate) fn mut_ptr_as_ref<'a, T>(p: *mut T) -> &'a mut T {
}

/// Convert a C str pointer to a Rust &str.
pub(crate) fn c2str<'a>(s: *const i8) -> &'a str {
pub(crate) fn c2str<'a>(s: *const c_char) -> &'a str {
let s = unsafe { std::ffi::CStr::from_ptr(s) }.to_str().unwrap();
s
}
Expand Down
2 changes: 1 addition & 1 deletion kclvm/runtime/src/context/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type kclvm_type_t = Type;
type kclvm_value_t = Value;

#[allow(dead_code, non_camel_case_types)]
type kclvm_char_t = i8;
type kclvm_char_t = c_char;

#[allow(dead_code, non_camel_case_types)]
type kclvm_size_t = i32;
Expand Down
8 changes: 4 additions & 4 deletions kclvm/runtime/src/stdlib/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub extern "C" fn kclvm_plugin_init(
}

// import kcl_plugin.hello
// hello.SayHello()
// hello.say_hello()
//
// => return kclvm_plugin_invoke("kcl_plugin.hello.SayHello", args, kwarge)
// => return kclvm_plugin_invoke("kcl_plugin.hello.say_hello", args, kwargs)

#[no_mangle]
#[runtime_fn]
Expand Down Expand Up @@ -64,7 +64,7 @@ pub unsafe extern "C" fn kclvm_plugin_invoke(
#[no_mangle]
#[runtime_fn]
pub extern "C" fn kclvm_plugin_invoke_json(
method: *const i8,
method: *const c_char,
args: *const c_char,
kwargs: *const c_char,
) -> *const c_char {
Expand All @@ -75,7 +75,7 @@ pub extern "C" fn kclvm_plugin_invoke_json(

let ptr = (&_plugin_handler_fn_ptr as *const u64) as *const ()
as *const extern "C" fn(
method: *const i8,
method: *const c_char,
args: *const c_char,
kwargs: *const c_char,
) -> *const c_char;
Expand Down
4 changes: 2 additions & 2 deletions kclvm/runtime/src/value/api.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 The KCL Authors. All rights reserved.
#![allow(clippy::missing_safety_doc)]

use std::mem::transmute_copy;
use std::{mem::transmute_copy, os::raw::c_char};

use crate::*;

Expand All @@ -24,7 +24,7 @@ pub type kclvm_value_ref_t = ValueRef;
pub type kclvm_iterator_t = ValueIterator;

#[allow(non_camel_case_types)]
pub type kclvm_char_t = i8;
pub type kclvm_char_t = c_char;

#[allow(non_camel_case_types)]
pub type kclvm_size_t = i32;
Expand Down

0 comments on commit f016975

Please sign in to comment.