Skip to content

Commit e703051

Browse files
author
Robert Zakrzewski
committed
Context with checking if target dependent types is supported
1 parent 82e65eb commit e703051

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

gccjit_sys/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,9 @@ extern {
658658
#[cfg(feature="master")]
659659
pub fn gcc_jit_target_info_supports_128bit_int(info: *mut gcc_jit_target_info) -> c_int;
660660

661+
#[cfg(feature="master")]
662+
pub fn gcc_jit_target_info_supports_target_dependent_type(info: *mut gcc_jit_target_info, ty: gcc_jit_types) -> c_int;
663+
661664
#[cfg(feature="master")]
662665
pub fn gcc_jit_context_new_sizeof(ctxt: *mut gcc_jit_context, typ: *mut gcc_jit_type) -> *mut gcc_jit_rvalue;
663666

src/context.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@ impl<'ctx> Context<'ctx> {
383383
}
384384
}
385385

386+
/// Checks if a given type is supported by the build target.
387+
#[cfg(feature="master")]
388+
pub fn supports_target_dependent_type<'a>(&'a self, c_type: CType) -> bool {
389+
self.get_target_info().supports_target_dependent_type(c_type.to_sys())
390+
}
391+
386392
pub fn new_int_type<'a>(&'a self, num_bytes: i32, signed: bool) -> types::Type<'a> {
387393
unsafe {
388394
let ctx_ptr = get_ptr(self);

src/target_info.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ impl TargetInfo {
4040
gccjit_sys::gcc_jit_target_info_supports_128bit_int(self.ptr) != 0
4141
}
4242
}
43+
44+
#[cfg(feature="master")]
45+
pub fn supports_target_dependent_type(&self, ty: gccjit_sys::gcc_jit_types) -> bool {
46+
unsafe {
47+
gccjit_sys::gcc_jit_target_info_supports_target_dependent_type(self.ptr, ty) != 0
48+
}
49+
}
4350
}
4451

4552
impl Drop for TargetInfo {

0 commit comments

Comments
 (0)