about summary refs log tree commit diff
path: root/library/compiler-builtins/libm-test/src/op.rs
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2025-04-23 06:46:31 +0000
committerTrevor Gross <t.gross35@gmail.com>2025-04-23 03:48:02 -0400
commit1dd39e27f06d0028bc62452283cf00a2d932d981 (patch)
treea656e6939c060266c6377ee82a30913c4782cb5e /library/compiler-builtins/libm-test/src/op.rs
parentb6db36061e83d5e0566331e78d8f80423cf3757e (diff)
downloadrust-1dd39e27f06d0028bc62452283cf00a2d932d981.tar.gz
rust-1dd39e27f06d0028bc62452283cf00a2d932d981.zip
libm-macros: Start tracking which functions are public
It would be nice to reuse some of the macro structure for internal
functions, like `rem_pio2`. To facilitate this, add a `public` field and
make it available in the macro's API.
Diffstat (limited to 'library/compiler-builtins/libm-test/src/op.rs')
-rw-r--r--library/compiler-builtins/libm-test/src/op.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/library/compiler-builtins/libm-test/src/op.rs b/library/compiler-builtins/libm-test/src/op.rs
index bd17aad7d03..afd445ff9c5 100644
--- a/library/compiler-builtins/libm-test/src/op.rs
+++ b/library/compiler-builtins/libm-test/src/op.rs
@@ -90,6 +90,9 @@ pub trait MathOp {
 
     /// The function in `libm` which can be called.
     const ROUTINE: Self::RustFn;
+
+    /// Whether or not the function is part of libm public API.
+    const PUBLIC: bool;
 }
 
 /// Access the associated `FTy` type from an op (helper to avoid ambiguous associated types).
@@ -107,7 +110,7 @@ pub type OpRustArgs<Op> = <Op as MathOp>::RustArgs;
 /// Access the associated `RustRet` type from an op (helper to avoid ambiguous associated types).
 pub type OpRustRet<Op> = <Op as MathOp>::RustRet;
 
-macro_rules! do_thing {
+macro_rules! create_op_modules {
     // Matcher for unary functions
     (
         fn_name: $fn_name:ident,
@@ -118,8 +121,8 @@ macro_rules! do_thing {
         RustFn: $RustFn:ty,
         RustArgs: $RustArgs:ty,
         RustRet: $RustRet:ty,
+        public: $public:expr,
         attrs: [$($attr:meta),*],
-
     ) => {
         paste::paste! {
             $(#[$attr])*
@@ -138,6 +141,7 @@ macro_rules! do_thing {
 
                     const IDENTIFIER: Identifier = Identifier::[< $fn_name:camel >];
                     const ROUTINE: Self::RustFn = libm::$fn_name;
+                    const PUBLIC: bool = $public;
                 }
             }
 
@@ -146,6 +150,6 @@ macro_rules! do_thing {
 }
 
 libm_macros::for_each_function! {
-    callback: do_thing,
+    callback: create_op_modules,
     emit_types: all,
 }