Skip to content

Commit 1970d21

Browse files
committed
Add new_alignof method
1 parent 0d9271a commit 1970d21

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

gccjit_sys/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,4 +670,7 @@ extern {
670670
#[cfg(feature="master")]
671671
pub fn gcc_jit_rvalue_set_location(rvalue: *mut gcc_jit_rvalue,
672672
loc: *mut gcc_jit_location);
673+
674+
#[cfg(feature="master")]
675+
pub fn gcc_jit_context_new_alignof(ctxt: *mut gcc_jit_context, typ: *mut gcc_jit_type) -> *mut gcc_jit_rvalue;
673676
}

src/context.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,6 @@ impl<'ctx> Context<'ctx> {
10481048
#[cfg(feature="master")]
10491049
/// Creates a new RValue from a sizeof(type).
10501050
pub fn new_sizeof<'a>(&'a self, ty: types::Type<'a>) -> RValue<'a> {
1051-
10521051
unsafe {
10531052
let ptr = gccjit_sys::gcc_jit_context_new_sizeof(self.ptr, types::get_ptr(&ty));
10541053
#[cfg(debug_assertions)]
@@ -1059,6 +1058,19 @@ impl<'ctx> Context<'ctx> {
10591058
}
10601059
}
10611060

1061+
#[cfg(feature="master")]
1062+
/// Creates a new RValue from a _Alignof(type).
1063+
pub fn new_alignof<'a>(&'a self, ty: types::Type<'a>) -> RValue<'a> {
1064+
unsafe {
1065+
let ptr = gccjit_sys::gcc_jit_context_new_alignof(self.ptr, types::get_ptr(&ty));
1066+
#[cfg(debug_assertions)]
1067+
if let Ok(Some(error)) = self.get_last_error() {
1068+
panic!("{}", error);
1069+
}
1070+
rvalue::from_ptr(ptr)
1071+
}
1072+
}
1073+
10621074
/// Dumps a small C file to the path that can be used to reproduce a series
10631075
/// of API calls. You should only ever need to call this if you are debugging
10641076
/// an issue in gccjit itself or this library.

0 commit comments

Comments
 (0)