Skip to content

Commit 6971df6

Browse files
authored
Merge pull request #32 from rust-lang/feature/alignof
Add new_alignof method
2 parents 55b63b4 + 1970d21 commit 6971df6

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
@@ -1049,7 +1049,6 @@ impl<'ctx> Context<'ctx> {
10491049
#[cfg(feature="master")]
10501050
/// Creates a new RValue from a sizeof(type).
10511051
pub fn new_sizeof<'a>(&'a self, ty: types::Type<'a>) -> RValue<'a> {
1052-
10531052
unsafe {
10541053
let ptr = gccjit_sys::gcc_jit_context_new_sizeof(self.ptr, types::get_ptr(&ty));
10551054
#[cfg(debug_assertions)]
@@ -1060,6 +1059,19 @@ impl<'ctx> Context<'ctx> {
10601059
}
10611060
}
10621061

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

0 commit comments

Comments
 (0)