Skip to content

Commit 814eea1

Browse files
committed
Add support for alias and weak function attributes
1 parent 61d8d55 commit 814eea1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

gccjit_sys/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ pub enum gcc_jit_comparison
258258
#[repr(C)]
259259
pub enum gcc_jit_fn_attribute
260260
{
261+
GCC_JIT_FN_ATTRIBUTE_ALIAS,
261262
GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE,
262263
GCC_JIT_FN_ATTRIBUTE_INLINE,
263264
GCC_JIT_FN_ATTRIBUTE_NOINLINE,
@@ -268,6 +269,7 @@ pub enum gcc_jit_fn_attribute
268269
GCC_JIT_FN_ATTRIBUTE_RETURNS_TWICE,
269270
GCC_JIT_FN_ATTRIBUTE_PURE,
270271
GCC_JIT_FN_ATTRIBUTE_CONST,
272+
GCC_JIT_FN_ATTRIBUTE_WEAK,
271273
}
272274

273275
#[cfg(feature="master")]

src/function.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub enum FunctionType {
4949
#[cfg(feature="master")]
5050
#[derive(Clone, Debug)]
5151
pub enum FnAttribute<'a> {
52+
Alias(&'a str),
5253
AlwaysInline,
5354
Inline,
5455
NoInline,
@@ -59,13 +60,14 @@ pub enum FnAttribute<'a> {
5960
ReturnsTwice,
6061
Pure,
6162
Const,
63+
Weak,
6264
}
6365

6466
#[cfg(feature="master")]
6567
impl<'a> FnAttribute<'a> {
6668
fn get_value(&self) -> AttributeValue {
6769
match *self {
68-
FnAttribute::Target(target) => AttributeValue::String(target),
70+
FnAttribute::Alias(value) | FnAttribute::Target(value) => AttributeValue::String(value),
6971
FnAttribute::Visibility(visibility) => AttributeValue::String(visibility.as_str()),
7072
FnAttribute::AlwaysInline
7173
| FnAttribute::Inline
@@ -74,12 +76,14 @@ impl<'a> FnAttribute<'a> {
7476
| FnAttribute::Cold
7577
| FnAttribute::ReturnsTwice
7678
| FnAttribute::Pure
77-
| FnAttribute::Const => AttributeValue::None,
79+
| FnAttribute::Const
80+
| FnAttribute::Weak => AttributeValue::None,
7881
}
7982
}
8083

8184
fn as_sys(&self) -> gccjit_sys::gcc_jit_fn_attribute {
8285
match *self {
86+
FnAttribute::Alias(_) => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_ALIAS,
8387
FnAttribute::AlwaysInline => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_ALWAYS_INLINE,
8488
FnAttribute::Inline => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_INLINE,
8589
FnAttribute::NoInline => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_NOINLINE,
@@ -90,6 +94,7 @@ impl<'a> FnAttribute<'a> {
9094
FnAttribute::ReturnsTwice => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_RETURNS_TWICE,
9195
FnAttribute::Pure => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_PURE,
9296
FnAttribute::Const => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_CONST,
97+
FnAttribute::Weak => gccjit_sys::gcc_jit_fn_attribute::GCC_JIT_FN_ATTRIBUTE_WEAK,
9398
}
9499
}
95100
}

0 commit comments

Comments
 (0)