capi: check api is aligned

This commit is contained in:
chyyran 2023-01-14 00:27:35 -05:00
parent 403ed5ed13
commit 1fa85d1e4d
2 changed files with 5 additions and 3 deletions

View file

@ -107,7 +107,7 @@ pub extern "C" fn libra_error_free(error: *mut libra_error_t) -> i32 {
/// Function pointer definition for libra_error_write
pub type PFN_libra_error_write =
extern "C" fn(error: libra_error_t, out: *mut MaybeUninit<*mut c_char>) -> i32;
extern "C" fn(error: libra_error_t, out: *mut MaybeUninit<*mut c_char>) -> i32;
#[no_mangle]
/// Writes the error message into `out`
///
@ -194,12 +194,12 @@ impl LibrashaderError {
macro_rules! assert_non_null {
($value:ident) => {
if $value.is_null() {
if $value.is_null() || !$value.is_aligned() {
return $crate::error::LibrashaderError::InvalidParameter(stringify!($value)).export();
}
};
(noexport $value:ident) => {
if $value.is_null() {
if $value.is_null() || !$value.is_aligned() {
return Err($crate::error::LibrashaderError::InvalidParameter(
stringify!($value),
));
@ -234,5 +234,6 @@ macro_rules! assert_some_ptr {
use crate::ctypes::libra_error_t;
pub(crate) use assert_non_null;
// pub(crate) use assert_some;
pub(crate) use assert_some_ptr;

View file

@ -35,6 +35,7 @@
//! `libra_error_free`.
#![allow(non_camel_case_types)]
#![feature(try_blocks)]
#![feature(pointer_is_aligned)]
#![feature(vec_into_raw_parts)]
#![deny(unsafe_op_in_unsafe_fn)]