Skip to content

Extend context and target info with function to check if target dependent types is supported #35

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
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 @@ -658,6 +658,9 @@ extern {
#[cfg(feature="master")]
pub fn gcc_jit_target_info_supports_128bit_int(info: *mut gcc_jit_target_info) -> c_int;

#[cfg(feature="master")]
pub fn gcc_jit_target_info_supports_target_dependent_type(info: *mut gcc_jit_target_info, ty: gcc_jit_types) -> c_int;

#[cfg(feature="master")]
pub fn gcc_jit_context_new_sizeof(ctxt: *mut gcc_jit_context, typ: *mut gcc_jit_type) -> *mut gcc_jit_rvalue;

Expand Down
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ pub enum CType {
}

impl CType {
fn to_sys(self) -> gccjit_sys::gcc_jit_types {
pub(crate) fn to_sys(self) -> gccjit_sys::gcc_jit_types {
use gccjit_sys::gcc_jit_types::*;
use self::CType::*;

Expand Down
8 changes: 8 additions & 0 deletions src/target_info.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use context::CType;
use std::{ffi::{CStr, CString}, fmt};

pub struct TargetInfo {
Expand Down Expand Up @@ -40,6 +41,13 @@ impl TargetInfo {
gccjit_sys::gcc_jit_target_info_supports_128bit_int(self.ptr) != 0
}
}

#[cfg(feature="master")]
pub fn supports_target_dependent_type(&self, c_type: CType) -> bool {
unsafe {
gccjit_sys::gcc_jit_target_info_supports_target_dependent_type(self.ptr, c_type.to_sys()) != 0
}
}
}

impl Drop for TargetInfo {
Expand Down
Loading