Skip to content

Commit 6e290f2

Browse files
authored
Merge pull request #26 from antoyo/feature/lib-version
Add function to get the version of libgccjit
2 parents 1e37e2c + 8b5d8a7 commit 6e290f2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

gccjit_sys/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,4 +658,8 @@ extern {
658658

659659
#[cfg(feature="master")]
660660
pub fn gcc_jit_context_set_output_ident(ctxt: *mut gcc_jit_context, output_ident: *const c_char);
661+
662+
pub fn gcc_jit_version_major() -> c_int;
663+
pub fn gcc_jit_version_minor() -> c_int;
664+
pub fn gcc_jit_version_patchlevel() -> c_int;
661665
}

src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,22 @@ pub fn set_global_personality_function_name(name: &'static [u8]) {
6666
gccjit_sys::gcc_jit_set_global_personality_function_name(name.as_ptr() as *const _);
6767
}
6868
}
69+
70+
#[derive(Debug)]
71+
pub struct Version {
72+
pub major: i32,
73+
pub minor: i32,
74+
pub patch: i32,
75+
}
76+
77+
impl Version {
78+
pub fn get() -> Self {
79+
unsafe {
80+
Self {
81+
major: gccjit_sys::gcc_jit_version_major(),
82+
minor: gccjit_sys::gcc_jit_version_minor(),
83+
patch: gccjit_sys::gcc_jit_version_patchlevel(),
84+
}
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)