[libcxx-commits] [libcxx] f805c79 - [libc++] "Implements" new SI prefixis.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 19 08:04:40 PDT 2023


Author: Mark de Wever
Date: 2023-06-19T17:04:35+02:00
New Revision: f805c799bfceae68251ff19a21f60f7335bfaac5

URL: https://github.com/llvm/llvm-project/commit/f805c799bfceae68251ff19a21f60f7335bfaac5
DIFF: https://github.com/llvm/llvm-project/commit/f805c799bfceae68251ff19a21f60f7335bfaac5.diff

LOG: [libc++] "Implements" new SI prefixis.

Like yocto, zepto, zetta, and yotta. The new prefixes quecto, ronto,
ronna, and quetta can't be implemented in a intmax_t. So their
implementation does nothing.

Implements
- P2734R0 Adding the new SI prefixes

Depends on D153192

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D153200

Added: 
    

Modified: 
    libcxx/docs/FeatureTestMacroTable.rst
    libcxx/docs/Status/Cxx2cPapers.csv
    libcxx/include/ratio
    libcxx/include/version
    libcxx/test/std/language.support/support.limits/support.limits.general/ratio.version.compile.pass.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
    libcxx/utils/generate_feature_test_macro_components.py

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 4c8e1ffc828bb..9fa449557ec06 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -394,7 +394,7 @@ Status
     --------------------------------------------------- -----------------
     ``__cpp_lib_hazard_pointer``                        *unimplemented*
     --------------------------------------------------- -----------------
-    ``__cpp_lib_ratio``                                 *unimplemented*
+    ``__cpp_lib_ratio``                                 ``202306L``
     --------------------------------------------------- -----------------
     ``__cpp_lib_rcu``                                   *unimplemented*
     --------------------------------------------------- -----------------

diff  --git a/libcxx/docs/Status/Cxx2cPapers.csv b/libcxx/docs/Status/Cxx2cPapers.csv
index 494e70f22a356..cd2e93377b20e 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -22,7 +22,7 @@
 "`P1759R6 <https://wg21.link/P1759R6>`__","LWG","Native handles and file streams","Varna June 2023","","",""
 "`P2697R1 <https://wg21.link/P2697R1>`__","LWG","Interfacing ``bitset`` with ``string_view``","Varna June 2023","","",""
 "`P1383R2 <https://wg21.link/P1383R2>`__","LWG","More ``constexpr`` for ``<cmath>`` and ``<complex>``","Varna June 2023","","",""
-"`P2734R0 <https://wg21.link/P2734R0>`__","LWG","Adding the new SI prefixes","Varna June 2023","","",""
+"`P2734R0 <https://wg21.link/P2734R0>`__","LWG","Adding the new SI prefixes","Varna June 2023","|Complete|","Clang 17",""
 "`P2548R6 <https://wg21.link/P2548R6>`__","LWG","``copyable_function``","Varna June 2023","","",""
 "`P2714R1 <https://wg21.link/P2714R1>`__","LWG","Bind front and back to NTTP callables","Varna June 2023","","",""
 "`P2630R4 <https://wg21.link/P2630R4>`__","LWG","``submdspan``","Varna June 2023","","",""

diff  --git a/libcxx/include/ratio b/libcxx/include/ratio
index 327e08cf1b4f1..c9637ab818cda 100644
--- a/libcxx/include/ratio
+++ b/libcxx/include/ratio
@@ -40,6 +40,8 @@ template <class R1, class R2> struct ratio_greater;
 template <class R1, class R2> struct ratio_greater_equal;
 
 // convenience SI typedefs
+using quecto = ratio <1, 1'000'000'000'000'000'000'000'000'000'000>; // Since C++26; not supported
+using ronto = ratio <1, 1'000'000'000'000'000'000'000'000'000>;      // Since C++26; not supported
 typedef ratio<1, 1000000000000000000000000> yocto;  // not supported
 typedef ratio<1,    1000000000000000000000> zepto;  // not supported
 typedef ratio<1,       1000000000000000000> atto;
@@ -60,6 +62,8 @@ typedef ratio<         1000000000000000, 1> peta;
 typedef ratio<      1000000000000000000, 1> exa;
 typedef ratio<   1000000000000000000000, 1> zetta;  // not supported
 typedef ratio<1000000000000000000000000, 1> yotta;  // not supported
+using ronna = ratio <1'000'000'000'000'000'000'000'000'000, 1>;      // Since C++26; not supported
+using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C++26; not supported
 
   // 20.11.5, ratio comparison
   template <class R1, class R2> inline constexpr bool ratio_equal_v

diff  --git a/libcxx/include/version b/libcxx/include/version
index 10abf695dadac..0cdf06d6d370c 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -456,7 +456,7 @@ __cpp_lib_within_lifetime                               202306L <type_traits>
 // # define __cpp_lib_fstream_native_handle                202306L
 // # define __cpp_lib_function_ref                         202306L
 // # define __cpp_lib_hazard_pointer                       202306L
-// # define __cpp_lib_ratio                                202306L
+# define __cpp_lib_ratio                                202306L
 // # define __cpp_lib_rcu                                  202306L
 // # define __cpp_lib_smart_ptr_owner_equality             202306L
 // # define __cpp_lib_sstream_from_string_view             202306L

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/ratio.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/ratio.version.compile.pass.cpp
index f782c24898b43..38adba62079d7 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/ratio.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/ratio.version.compile.pass.cpp
@@ -54,17 +54,11 @@
 
 #elif TEST_STD_VER > 23
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_ratio
-#     error "__cpp_lib_ratio should be defined in c++26"
-#   endif
-#   if __cpp_lib_ratio != 202306L
-#     error "__cpp_lib_ratio should have the value 202306L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_ratio
-#     error "__cpp_lib_ratio should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_ratio
+#   error "__cpp_lib_ratio should be defined in c++26"
+# endif
+# if __cpp_lib_ratio != 202306L
+#   error "__cpp_lib_ratio should have the value 202306L in c++26"
 # endif
 
 #endif // TEST_STD_VER > 23

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
index fb7081f2ebbf7..040dc9c6cd9e7 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
@@ -6511,17 +6511,11 @@
 #   endif
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_ratio
-#     error "__cpp_lib_ratio should be defined in c++26"
-#   endif
-#   if __cpp_lib_ratio != 202306L
-#     error "__cpp_lib_ratio should have the value 202306L in c++26"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_ratio
-#     error "__cpp_lib_ratio should not be defined because it is unimplemented in libc++!"
-#   endif
+# ifndef __cpp_lib_ratio
+#   error "__cpp_lib_ratio should be defined in c++26"
+# endif
+# if __cpp_lib_ratio != 202306L
+#   error "__cpp_lib_ratio should have the value 202306L in c++26"
 # endif
 
 # ifndef __cpp_lib_raw_memory_algorithms

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 4d454f7e42986..4b835791aee53 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -847,7 +847,6 @@ def add_version_header(tc):
             "name": "__cpp_lib_ratio",
             "values": {"c++26": 202306}, # P2734R0 Adding the new SI prefixes
             "headers": ["ratio"],
-            "unimplemented": True,
         },
         {
             "name": "__cpp_lib_raw_memory_algorithms",


        


More information about the libcxx-commits mailing list