Skip to content

Commit b190535

Browse files
committed
Final polish and fixes.
1 parent 4fcce8d commit b190535

File tree

9 files changed

+36
-44
lines changed

9 files changed

+36
-44
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Status
358358
---------------------------------------------------------- -----------------
359359
``__cpp_lib_out_ptr`` ``202106L``
360360
---------------------------------------------------------- -----------------
361-
``__cpp_lib_print`` ``202207L``
361+
``__cpp_lib_print`` ``202403L``
362362
---------------------------------------------------------- -----------------
363363
``__cpp_lib_ranges`` ``202406L``
364364
---------------------------------------------------------- -----------------

libcxx/docs/Status/Cxx2cPapers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"`P2867R2 <https://wg21.link/P2867R2>`__","Remove Deprecated ``strstreams`` From C++26","2024-03 (Tokyo)","|Complete|","19",""
5151
"`P2869R4 <https://wg21.link/P2869R4>`__","Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26","2024-03 (Tokyo)","","",""
5252
"`P2872R3 <https://wg21.link/P2872R3>`__","Remove ``wstring_convert`` From C++26","2024-03 (Tokyo)","|Complete|","19",""
53-
"`P3107R5 <https://wg21.link/P3107R5>`__","Permit an efficient implementation of ``std::print``","2024-03 (Tokyo)","","",""
53+
"`P3107R5 <https://wg21.link/P3107R5>`__","Permit an efficient implementation of ``std::print``","2024-03 (Tokyo)","|Complete|","21",""
5454
"`P3142R0 <https://wg21.link/P3142R0>`__","Printing Blank Lines with ``println``","2024-03 (Tokyo)","|Complete|","19","Implemented as a DR against C++23. (MSVC STL and libstdc++ will do the same.)"
5555
"`P2845R8 <https://wg21.link/P2845R8>`__","Formatting of ``std::filesystem::path``","2024-03 (Tokyo)","","",""
5656
"`P0493R5 <https://wg21.link/P0493R5>`__","Atomic minimum/maximum","2024-03 (Tokyo)","","",""

libcxx/include/print

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ _LIBCPP_HIDE_FROM_ABI inline void __funlockfile(FILE* __stream) {
241241
_LIBCPP_HIDE_FROM_ABI inline int __fflush_unlocked(FILE* __stream) {
242242
# if defined(_LIBCPP_WIN32API)
243243
return ::_fflush_nolock(__stream);
244-
# elif defined(__PICOLIBC__) || defined(_AIX) || defined(__ANDROID__)
244+
# elif defined(__PICOLIBC__) || defined(_AIX) || defined(__ANDROID__) || defined(__APPLE__)
245245
// There is no fflush_unlocked on these systems.
246246
// This funcion is not part of POSIX.
247247
return ::fflush(__stream);
@@ -257,7 +257,7 @@ _LIBCPP_HIDE_FROM_ABI inline size_t
257257
__fwrite_unlocked(const void* __buffer, [[maybe_unused]] size_t __size, size_t __n, FILE* __stream) {
258258
# if defined(_LIBCPP_WIN32API)
259259
return ::_fwrite_nolock(__buffer, __size, __n, __stream);
260-
# elif defined(__PICOLIBC__) || defined(_AIX) || defined(__ANDROID__)
260+
# elif defined(__PICOLIBC__) || defined(_AIX) || defined(__ANDROID__) || defined(__APPLE__)
261261
// The function fwrite_unlocked is not part of POSIX and not available on
262262
// these systems.
263263
auto __b = static_cast<const char*>(__buffer);
@@ -291,7 +291,7 @@ _LIBCPP_HIDE_FROM_ABI int __fflush(FILE* __stream) {
291291
return std::fflush(__stream);
292292
else
293293
# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600
294-
sizeof(__lock_policy) == 0
294+
static_assert(sizeof(__lock_policy) == 0, "Unsupported policy");
295295
# else
296296
static_assert(false, "Unsupported policy");
297297
# endif
@@ -316,7 +316,7 @@ public:
316316
__print::__flockfile(__stream_);
317317
else if constexpr (__policy != __lock_policy::__stdio)
318318
# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600
319-
sizeof(__lock_policy) == 0
319+
static_assert(sizeof(__lock_policy) == 0, "Unsupported policy");
320320
# else
321321
static_assert(false, "Unsupported policy");
322322
# endif
@@ -327,7 +327,7 @@ public:
327327
__print::__funlockfile(__stream_);
328328
else if constexpr (__policy != __lock_policy::__stdio)
329329
# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600
330-
sizeof(__lock_policy) == 0
330+
static_assert(sizeof(__lock_policy) == 0, "Unsupported policy");
331331
# else
332332
static_assert(false, "Unsupported policy");
333333
# endif
@@ -359,7 +359,7 @@ private:
359359
return std::fwrite(__small_buffer_, 1, __n, __stream_);
360360
else
361361
# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600
362-
sizeof(__lock_policy) == 0
362+
static_assert(sizeof(__lock_policy) == 0, "Unsupported policy");
363363
# else
364364
static_assert(false, "Unsupported policy");
365365
# endif
@@ -505,20 +505,19 @@ __vprint_unicode([[maybe_unused]] FILE* __stream,
505505

506506
template <class... _Args>
507507
_LIBCPP_HIDE_FROM_ABI void print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) {
508-
# if _LIBCPP_HAS_UNICODE
509-
constexpr bool __use_unicode = __print::__use_unicode_execution_charset;
510-
# else // _LIBCPP_HAS_UNICODE
511-
constexpr bool __use_unicode = false;
512-
# endif // _LIBCPP_HAS_UNICODE
513508
constexpr bool __locksafe = (enable_nonlocking_formatter_optimization<remove_cvref_t<_Args>> && ...);
514509

515510
using enum __print::__lock_policy;
516-
if constexpr (__use_unicode)
511+
# if _LIBCPP_HAS_UNICODE
512+
if constexpr (__print::__use_unicode_execution_charset)
517513
__print::__vprint_unicode<__locksafe ? __manual : __stdio>(
518514
__stream, __fmt.get(), std::make_format_args(__args...), false);
519515
else
516+
# endif // _LIBCPP_HAS_UNICODE
517+
{
520518
__print::__vprint_nonunicode<__locksafe ? __manual : __stdio>(
521519
__stream, __fmt.get(), std::make_format_args(__args...), false);
520+
}
522521
}
523522

524523
template <class... _Args>
@@ -528,23 +527,22 @@ _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __arg
528527

529528
template <class... _Args>
530529
_LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) {
531-
# if _LIBCPP_HAS_UNICODE
532-
constexpr bool __use_unicode = __print::__use_unicode_execution_charset;
533-
# else // _LIBCPP_HAS_UNICODE
534-
constexpr bool __use_unicode = false;
535-
# endif // _LIBCPP_HAS_UNICODE
536530
constexpr bool __locksafe = (enable_nonlocking_formatter_optimization<remove_cvref_t<_Args>> && ...);
537531

538532
// Note the wording in the Standard is inefficient. The output of
539533
// std::format is a std::string which is then copied. This solution
540534
// just appends a newline at the end of the output.
541535
using enum __print::__lock_policy;
542-
if constexpr (__use_unicode)
536+
# if _LIBCPP_HAS_UNICODE
537+
if constexpr (__print::__use_unicode_execution_charset)
543538
__print::__vprint_unicode<__locksafe ? __manual : __stdio>(
544539
__stream, __fmt.get(), std::make_format_args(__args...), true);
545540
else
541+
# endif // _LIBCPP_HAS_UNICODE
542+
{
546543
__print::__vprint_nonunicode<__locksafe ? __manual : __stdio>(
547544
__stream, __fmt.get(), std::make_format_args(__args...), true);
545+
}
548546
}
549547

550548
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).

libcxx/include/version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ __cpp_lib_out_ptr 202311L <memory>
185185
__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>
186186
__cpp_lib_philox_engine 202406L <random>
187187
__cpp_lib_polymorphic_allocator 201902L <memory_resource>
188-
__cpp_lib_print 202207L <ostream> <print>
188+
__cpp_lib_print 202403L <ostream> <print>
189189
__cpp_lib_quoted_string_io 201304L <iomanip>
190190
__cpp_lib_ranges 202406L <algorithm> <functional> <iterator>
191191
<memory> <ranges>
@@ -502,7 +502,7 @@ __cpp_lib_void_t 201411L <type_traits>
502502
# define __cpp_lib_optional 202110L
503503
# define __cpp_lib_out_ptr 202106L
504504
# if _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT
505-
# define __cpp_lib_print 202207L
505+
# define __cpp_lib_print 202403L
506506
# endif
507507
# undef __cpp_lib_ranges
508508
# define __cpp_lib_ranges 202406L

libcxx/test/libcxx/system_reserved_names.gen.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@
119119
#define __acquire SYSTEM_RESERVED_NAME
120120
#define __release SYSTEM_RESERVED_NAME
121121
122-
// Android and FreeBSD use this for __attribute__((__unused__))
123-
#if !defined(__FreeBSD__) && !defined(__ANDROID__)
124-
#define __unused SYSTEM_RESERVED_NAME
125-
#endif
126-
127122
// These names are not reserved, so the user can macro-define them.
128123
// These are intended to find improperly _Uglified template parameters.
129124
#define A SYSTEM_RESERVED_NAME

libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.compile.pass.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/* Constant Value
2121
__cpp_lib_char8_t 201907L [C++20]
22-
__cpp_lib_print 202207L [C++23]
22+
__cpp_lib_print 202403L [C++23]
2323
*/
2424

2525
#include <ostream>
@@ -93,8 +93,8 @@
9393
# ifndef __cpp_lib_print
9494
# error "__cpp_lib_print should be defined in c++23"
9595
# endif
96-
# if __cpp_lib_print != 202207L
97-
# error "__cpp_lib_print should have the value 202207L in c++23"
96+
# if __cpp_lib_print != 202403L
97+
# error "__cpp_lib_print should have the value 202403L in c++23"
9898
# endif
9999
# else
100100
# ifdef __cpp_lib_print
@@ -121,8 +121,8 @@
121121
# ifndef __cpp_lib_print
122122
# error "__cpp_lib_print should be defined in c++26"
123123
# endif
124-
# if __cpp_lib_print != 202207L
125-
# error "__cpp_lib_print should have the value 202207L in c++26"
124+
# if __cpp_lib_print != 202403L
125+
# error "__cpp_lib_print should have the value 202403L in c++26"
126126
# endif
127127
# else
128128
# ifdef __cpp_lib_print

libcxx/test/std/language.support/support.limits/support.limits.general/print.version.compile.pass.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// Test the feature test macros defined by <print>
1919

2020
/* Constant Value
21-
__cpp_lib_print 202207L [C++23]
21+
__cpp_lib_print 202403L [C++23]
2222
*/
2323

2424
#include <print>
@@ -54,8 +54,8 @@
5454
# ifndef __cpp_lib_print
5555
# error "__cpp_lib_print should be defined in c++23"
5656
# endif
57-
# if __cpp_lib_print != 202207L
58-
# error "__cpp_lib_print should have the value 202207L in c++23"
57+
# if __cpp_lib_print != 202403L
58+
# error "__cpp_lib_print should have the value 202403L in c++23"
5959
# endif
6060
# else
6161
# ifdef __cpp_lib_print
@@ -69,8 +69,8 @@
6969
# ifndef __cpp_lib_print
7070
# error "__cpp_lib_print should be defined in c++26"
7171
# endif
72-
# if __cpp_lib_print != 202207L
73-
# error "__cpp_lib_print should have the value 202207L in c++26"
72+
# if __cpp_lib_print != 202403L
73+
# error "__cpp_lib_print should have the value 202403L in c++26"
7474
# endif
7575
# else
7676
# ifdef __cpp_lib_print

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
__cpp_lib_parallel_algorithm 201603L [C++17]
170170
__cpp_lib_philox_engine 202406L [C++26]
171171
__cpp_lib_polymorphic_allocator 201902L [C++20]
172-
__cpp_lib_print 202207L [C++23]
172+
__cpp_lib_print 202403L [C++23]
173173
__cpp_lib_quoted_string_io 201304L [C++14]
174174
__cpp_lib_ranges 202110L [C++20]
175175
202406L [C++23]
@@ -5683,8 +5683,8 @@
56835683
# ifndef __cpp_lib_print
56845684
# error "__cpp_lib_print should be defined in c++23"
56855685
# endif
5686-
# if __cpp_lib_print != 202207L
5687-
# error "__cpp_lib_print should have the value 202207L in c++23"
5686+
# if __cpp_lib_print != 202403L
5687+
# error "__cpp_lib_print should have the value 202403L in c++23"
56885688
# endif
56895689
# else
56905690
# ifdef __cpp_lib_print
@@ -7567,8 +7567,8 @@
75677567
# ifndef __cpp_lib_print
75687568
# error "__cpp_lib_print should be defined in c++26"
75697569
# endif
7570-
# if __cpp_lib_print != 202207L
7571-
# error "__cpp_lib_print should have the value 202207L in c++26"
7570+
# if __cpp_lib_print != 202403L
7571+
# error "__cpp_lib_print should have the value 202403L in c++26"
75727572
# endif
75737573
# else
75747574
# ifdef __cpp_lib_print

libcxx/utils/generate_feature_test_macro_components.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,7 @@ def add_version_header(tc):
10101010
{
10111011
"name": "__cpp_lib_print",
10121012
"values": {
1013-
"c++23": 202207,
1014-
# "c++26": 202403, # P3107R5: Permit an efficient implementation of std::print
1013+
"c++23": 202403,
10151014
# "c++26": 202406, # P3235R3 std::print more types faster with less memory
10161015
},
10171016
"headers": ["ostream", "print"],

0 commit comments

Comments
 (0)