public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] libproc_macro: Add is_available ffi
@ 2023-04-06 21:31 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-04-06 21:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:eedfefb49d1aa8750c52a4893149207cc6ba5dbc

commit eedfefb49d1aa8750c52a4893149207cc6ba5dbc
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Thu Feb 16 18:35:24 2023 +0100

    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>

Diff:
---
 librust/proc_macro/rust/bridge.rs | 8 ++++++++
 librust/proc_macro/rust/lib.rs    | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/librust/proc_macro/rust/bridge.rs b/librust/proc_macro/rust/bridge.rs
index eb49071fb1f..ff2c49688b6 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 48e1bcd7679..4e6802abeda 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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-06 21:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 21:31 [gcc/devel/rust/master] libproc_macro: Add is_available ffi Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).