aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-02-16 18:35:24 +0100
committerPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-03-30 13:52:30 +0200
commiteedfefb49d1aa8750c52a4893149207cc6ba5dbc (patch)
tree688c8b3625080f1aaec5a41a15012a242a79668d
parentdc4f537942ee67079526e06528a9f0823ee81bf1 (diff)
downloadgcc-eedfefb49d1aa8750c52a4893149207cc6ba5dbc.zip
gcc-eedfefb49d1aa8750c52a4893149207cc6ba5dbc.tar.gz
gcc-eedfefb49d1aa8750c52a4893149207cc6ba5dbc.tar.bz2
libproc_macro: Add is_available ffi
Add ffi call for is_available function. ChangeLog: * librust/proc_macro/rust/bridge.rs: Add internal implementation. * librust/proc_macro/rust/lib.rs: Add call to internal implementation. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--librust/proc_macro/rust/bridge.rs8
-rw-r--r--librust/proc_macro/rust/lib.rs2
2 files changed, 9 insertions, 1 deletions
diff --git a/librust/proc_macro/rust/bridge.rs b/librust/proc_macro/rust/bridge.rs
index eb49071..ff2c496 100644
--- a/librust/proc_macro/rust/bridge.rs
+++ b/librust/proc_macro/rust/bridge.rs
@@ -2,3 +2,11 @@ pub mod ident;
pub mod literal;
pub mod punct;
pub mod span;
+
+extern "C" {
+ fn bridge__is_available() -> bool;
+}
+
+pub fn is_available() -> bool {
+ unsafe { bridge__is_available() }
+}
diff --git a/librust/proc_macro/rust/lib.rs b/librust/proc_macro/rust/lib.rs
index 48e1bcd..4e6802a 100644
--- a/librust/proc_macro/rust/lib.rs
+++ b/librust/proc_macro/rust/lib.rs
@@ -22,7 +22,7 @@ pub mod token_stream;
/// This function provide a non panicking way to detect whether the API is
/// invoked from inside of a procedural macro.
pub fn is_available() -> bool {
- todo!("Implement this function")
+ bridge::is_available()
}
/// A single token or a delimited sequence of token trees.