Skip to content

Add new_alignof method #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gccjit_sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,4 +670,7 @@ extern {
#[cfg(feature="master")]
pub fn gcc_jit_rvalue_set_location(rvalue: *mut gcc_jit_rvalue,
loc: *mut gcc_jit_location);

#[cfg(feature="master")]
pub fn gcc_jit_context_new_alignof(ctxt: *mut gcc_jit_context, typ: *mut gcc_jit_type) -> *mut gcc_jit_rvalue;
}
14 changes: 13 additions & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,6 @@ impl<'ctx> Context<'ctx> {
#[cfg(feature="master")]
/// Creates a new RValue from a sizeof(type).
pub fn new_sizeof<'a>(&'a self, ty: types::Type<'a>) -> RValue<'a> {

unsafe {
let ptr = gccjit_sys::gcc_jit_context_new_sizeof(self.ptr, types::get_ptr(&ty));
#[cfg(debug_assertions)]
Expand All @@ -1059,6 +1058,19 @@ impl<'ctx> Context<'ctx> {
}
}

#[cfg(feature="master")]
/// Creates a new RValue from a _Alignof(type).
pub fn new_alignof<'a>(&'a self, ty: types::Type<'a>) -> RValue<'a> {
unsafe {
let ptr = gccjit_sys::gcc_jit_context_new_alignof(self.ptr, types::get_ptr(&ty));
#[cfg(debug_assertions)]
if let Ok(Some(error)) = self.get_last_error() {
panic!("{}", error);
}
rvalue::from_ptr(ptr)
}
}

/// Dumps a small C file to the path that can be used to reproduce a series
/// of API calls. You should only ever need to call this if you are debugging
/// an issue in gccjit itself or this library.
Expand Down
Loading