[llvm-branch-commits] [polly] r255408 - Creating tags/google/testing/2015-12-11 from r255243
Author: samsonov Date: Fri Dec 11 18:39:53 2015 New Revision: 255408 URL: http://llvm.org/viewvc/llvm-project?rev=255408&view=rev Log: Creating tags/google/testing/2015-12-11 from r255243 Added: polly/tags/google/testing/2015-12-11/ - copied from r255243, polly/trunk/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lldb] r255410 - Creating tags/google/testing/2015-12-11 from r255243
Author: samsonov Date: Fri Dec 11 18:39:56 2015 New Revision: 255410 URL: http://llvm.org/viewvc/llvm-project?rev=255410&view=rev Log: Creating tags/google/testing/2015-12-11 from r255243 Added: lldb/tags/google/testing/2015-12-11/ (props changed) - copied from r255243, lldb/trunk/ Propchange: lldb/tags/google/testing/2015-12-11/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Dec 11 18:39:56 2015 @@ -0,0 +1,2 @@ +/lldb/branches/apple/python-GIL:156467-162159 +/lldb/branches/iohandler:198360-200250 ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra-tag] r255406 - Creating tags/google/testing/2015-12-11 from r255243
Author: samsonov Date: Fri Dec 11 18:39:49 2015 New Revision: 255406 URL: http://llvm.org/viewvc/llvm-project?rev=255406&view=rev Log: Creating tags/google/testing/2015-12-11 from r255243 Added: clang-tools-extra/tags/google/testing/2015-12-11/ - copied from r255243, clang-tools-extra/trunk/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [polly] r255409 - Updating branches/google/testing to r255243
Author: samsonov Date: Fri Dec 11 18:39:54 2015 New Revision: 255409 URL: http://llvm.org/viewvc/llvm-project?rev=255409&view=rev Log: Updating branches/google/testing to r255243 Added: polly/branches/google/testing/ - copied from r255243, polly/trunk/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm-branch] r255413 - Updating branches/google/testing to r255243
Author: samsonov Date: Fri Dec 11 18:40:02 2015 New Revision: 255413 URL: http://llvm.org/viewvc/llvm-project?rev=255413&view=rev Log: Updating branches/google/testing to r255243 Added: llvm/branches/google/testing/ (props changed) - copied from r255243, llvm/trunk/ Propchange: llvm/branches/google/testing/ -- --- svn:ignore (added) +++ svn:ignore Fri Dec 11 18:40:02 2015 @@ -0,0 +1,25 @@ +Debug +Release +Release-Asserts +mklib +Makefile.config +config.log +config.status +cvs.out +autom4te.cache +configure.out +LLVM-* +_distcheckdir +llvm.spec +svn-commit.* +*.patch +*.patch.raw +cscope.* +Debug+Coverage-Asserts +Release+Coverage-Asserts +Debug+Coverage +Release+Coverage +Debug+Checks +Debug+Asserts +Release+Asserts +build Propchange: llvm/branches/google/testing/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Dec 11 18:40:02 2015 @@ -0,0 +1,3 @@ +/llvm/branches/Apple/Pertwee:110850,110961 +/llvm/branches/type-system-rewrite:133420-134817 +/llvm/trunk:155241 ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm-branch] r255401 - Cleaning up testing branch
Author: samsonov Date: Fri Dec 11 18:39:40 2015 New Revision: 255401 URL: http://llvm.org/viewvc/llvm-project?rev=255401&view=rev Log: Cleaning up testing branch Removed: llvm/branches/google/testing/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [cfe-branch] r255403 - Updating branches/google/testing to r255243
Author: samsonov Date: Fri Dec 11 18:39:44 2015 New Revision: 255403 URL: http://llvm.org/viewvc/llvm-project?rev=255403&view=rev Log: Updating branches/google/testing to r255243 Added: cfe/branches/google/testing/ (props changed) - copied from r255243, cfe/trunk/ Propchange: cfe/branches/google/testing/ -- --- svn:ignore (added) +++ svn:ignore Fri Dec 11 18:39:44 2015 @@ -0,0 +1,3 @@ +configure.out +cscope.files +cscope.out Propchange: cfe/branches/google/testing/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Dec 11 18:39:44 2015 @@ -0,0 +1,3 @@ +/cfe/branches/type-system-rewrite:134693-134817 +/cfe/trunk/test:170344 +/cfe/trunk/test/SemaTemplate:126920 ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [cfe-branch] r255401 - Cleaning up testing branch
Author: samsonov Date: Fri Dec 11 18:39:40 2015 New Revision: 255401 URL: http://llvm.org/viewvc/llvm-project?rev=255401&view=rev Log: Cleaning up testing branch Removed: cfe/branches/google/testing/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt-branch] r255405 - Updating branches/google/testing to r255243
Author: samsonov Date: Fri Dec 11 18:39:47 2015 New Revision: 255405 URL: http://llvm.org/viewvc/llvm-project?rev=255405&view=rev Log: Updating branches/google/testing to r255243 Added: compiler-rt/branches/google/testing/ - copied from r255243, compiler-rt/trunk/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt-tag] r255404 - Creating tags/google/testing/2015-12-11 from r255243
Author: samsonov Date: Fri Dec 11 18:39:45 2015 New Revision: 255404 URL: http://llvm.org/viewvc/llvm-project?rev=255404&view=rev Log: Creating tags/google/testing/2015-12-11 from r255243 Added: compiler-rt/tags/google/testing/2015-12-11/ - copied from r255243, compiler-rt/trunk/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [cfe-tag] r255402 - Creating tags/google/testing/2015-12-11 from r255243
Author: samsonov Date: Fri Dec 11 18:39:42 2015 New Revision: 255402 URL: http://llvm.org/viewvc/llvm-project?rev=255402&view=rev Log: Creating tags/google/testing/2015-12-11 from r255243 Added: cfe/tags/google/testing/2015-12-11/ (props changed) - copied from r255243, cfe/trunk/ Propchange: cfe/tags/google/testing/2015-12-11/ -- --- svn:ignore (added) +++ svn:ignore Fri Dec 11 18:39:42 2015 @@ -0,0 +1,3 @@ +configure.out +cscope.files +cscope.out Propchange: cfe/tags/google/testing/2015-12-11/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Dec 11 18:39:42 2015 @@ -0,0 +1,3 @@ +/cfe/branches/type-system-rewrite:134693-134817 +/cfe/trunk/test:170344 +/cfe/trunk/test/SemaTemplate:126920 ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra-branch] r255407 - Updating branches/google/testing to r255243
Author: samsonov Date: Fri Dec 11 18:39:51 2015 New Revision: 255407 URL: http://llvm.org/viewvc/llvm-project?rev=255407&view=rev Log: Updating branches/google/testing to r255243 Added: clang-tools-extra/branches/google/testing/ - copied from r255243, clang-tools-extra/trunk/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [compiler-rt-branch] r255401 - Cleaning up testing branch
Author: samsonov Date: Fri Dec 11 18:39:40 2015 New Revision: 255401 URL: http://llvm.org/viewvc/llvm-project?rev=255401&view=rev Log: Cleaning up testing branch Removed: compiler-rt/branches/google/testing/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lldb] r255411 - Updating branches/google/testing to r255243
Author: samsonov Date: Fri Dec 11 18:39:58 2015 New Revision: 255411 URL: http://llvm.org/viewvc/llvm-project?rev=255411&view=rev Log: Updating branches/google/testing to r255243 Added: lldb/branches/google/testing/ (props changed) - copied from r255243, lldb/trunk/ Propchange: lldb/branches/google/testing/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Dec 11 18:39:58 2015 @@ -0,0 +1,2 @@ +/lldb/branches/apple/python-GIL:156467-162159 +/lldb/branches/iohandler:198360-200250 ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang-tools-extra-branch] r255401 - Cleaning up testing branch
Author: samsonov Date: Fri Dec 11 18:39:40 2015 New Revision: 255401 URL: http://llvm.org/viewvc/llvm-project?rev=255401&view=rev Log: Cleaning up testing branch Removed: clang-tools-extra/branches/google/testing/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [polly] r255401 - Cleaning up testing branch
Author: samsonov Date: Fri Dec 11 18:39:40 2015 New Revision: 255401 URL: http://llvm.org/viewvc/llvm-project?rev=255401&view=rev Log: Cleaning up testing branch Removed: polly/branches/google/testing/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm-tag] r255412 - Creating tags/google/testing/2015-12-11 from r255243
Author: samsonov Date: Fri Dec 11 18:40:00 2015 New Revision: 255412 URL: http://llvm.org/viewvc/llvm-project?rev=255412&view=rev Log: Creating tags/google/testing/2015-12-11 from r255243 Added: llvm/tags/google/testing/2015-12-11/ (props changed) - copied from r255243, llvm/trunk/ Propchange: llvm/tags/google/testing/2015-12-11/ -- --- svn:ignore (added) +++ svn:ignore Fri Dec 11 18:40:00 2015 @@ -0,0 +1,25 @@ +Debug +Release +Release-Asserts +mklib +Makefile.config +config.log +config.status +cvs.out +autom4te.cache +configure.out +LLVM-* +_distcheckdir +llvm.spec +svn-commit.* +*.patch +*.patch.raw +cscope.* +Debug+Coverage-Asserts +Release+Coverage-Asserts +Debug+Coverage +Release+Coverage +Debug+Checks +Debug+Asserts +Release+Asserts +build Propchange: llvm/tags/google/testing/2015-12-11/ -- --- svn:mergeinfo (added) +++ svn:mergeinfo Fri Dec 11 18:40:00 2015 @@ -0,0 +1,3 @@ +/llvm/branches/Apple/Pertwee:110850,110961 +/llvm/branches/type-system-rewrite:133420-134817 +/llvm/trunk:155241 ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lldb] r255401 - Cleaning up testing branch
Author: samsonov Date: Fri Dec 11 18:39:40 2015 New Revision: 255401 URL: http://llvm.org/viewvc/llvm-project?rev=255401&view=rev Log: Cleaning up testing branch Removed: lldb/branches/google/testing/ ___ llvm-branch-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc] Modular printf option (float only) (PR #147426)
@@ -0,0 +1,55 @@
+//===-- Implementation of printf_modular for baremetal --*- C++
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "src/__support/OSUtil/io.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/macros/config.h"
+#include "src/stdio/printf.h"
+#include "src/stdio/printf_core/core_structs.h"
+#include "src/stdio/printf_core/printf_main.h"
+#include "src/stdio/printf_core/writer.h"
+
+#include
+#include
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace {
+
+LIBC_INLINE int stdout_write_hook(cpp::string_view new_str, void *) {
+ write_to_stdout(new_str);
+ return printf_core::WRITE_OK;
+}
+
+} // namespace
+
+LLVM_LIBC_FUNCTION(int, __printf_modular,
+ (const char *__restrict format, ...)) {
+ va_list vlist;
+ va_start(vlist, format);
+ internal::ArgList args(vlist); // This holder class allows for easier copying
+ // and pointer semantics, as well as handling
+ // destruction automatically.
+ va_end(vlist);
+ static constexpr size_t BUFF_SIZE = 1024;
+ char buffer[BUFF_SIZE];
+
+ printf_core::WriteBuffer wb(
vonosmas wrote:
I will just add as a drive-by comment, that it's a tricky bug lurking here -
this should be
`printf_core::Mode::value`. Needless
to say, it's
easy to miss and is confusing. PR #169089 should fix it, if it can go in first.
https://github.com/llvm/llvm-project/pull/147426
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc][printf] De-string-viewify writer internals. (PR #170959)
https://github.com/vonosmas ready_for_review https://github.com/llvm/llvm-project/pull/170959 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc][printf] De-string-viewify writer internals. (PR #170959)
https://github.com/vonosmas updated
https://github.com/llvm/llvm-project/pull/170959
>From 008397fc8a6aa17b27aecd965c3fc2be433708c0 Mon Sep 17 00:00:00 2001
From: Alexey Samsonov
Date: Fri, 21 Nov 2025 19:45:34 +
Subject: [PATCH 1/2] [libc] Refactor static polymorphism in WriteBuffer (NFC).
There are three flavors of WriteBuffer currently, all of which
could be passed into printf_core::Writer class. It's a tricky
class, since it chooses a flavor-specific logic either based
on runtime dispatch (to save code size and prevent
generating three versions of the entirety of printf_core),
or based on template arguments (to avoid dealing with
function pointers in codegen for FILL_BUFF_AND_DROP_OVERFLOW path.
Refactor this somewhat convoluted logic to have three
concrete subclasses inheriting from the templated base
class, and use static polymorphism with reinterpret_cast
to implement dispatching above. Now we can actually
have flavor-specific fields, constructors, and methods
(e.g. "flush_to_stream" is now a method of FlushingBuffer),
and the code on the user side is cleaner: the complexity
of enabling/disabling runtime-dispatch and using proper
template arguments is now localized in writer.h.
This code will need to be further templatized to support
buffers of type wchar_t to implement swprintf() and
friends. This change would make it (ever so slightly) easier.
---
libc/src/__support/RPC/rpc_server.h | 12 +-
libc/src/stdio/baremetal/printf.cpp | 8 +-
libc/src/stdio/baremetal/vprintf.cpp | 8 +-
.../stdio/printf_core/vasprintf_internal.h| 10 +-
.../src/stdio/printf_core/vfprintf_internal.h | 6 +-
libc/src/stdio/printf_core/writer.h | 154 +++---
libc/src/stdio/snprintf.cpp | 4 +-
libc/src/stdio/sprintf.cpp| 5 +-
libc/src/stdio/vsnprintf.cpp | 4 +-
libc/src/stdio/vsprintf.cpp | 5 +-
libc/src/stdlib/strfromd.cpp | 4 +-
libc/src/stdlib/strfromf.cpp | 4 +-
libc/src/stdlib/strfroml.cpp | 4 +-
libc/src/time/strftime.cpp| 4 +-
libc/src/time/strftime_l.cpp | 4 +-
.../src/stdio/printf_core/converter_test.cpp | 16 +-
.../src/stdio/printf_core/writer_test.cpp | 64
17 files changed, 162 insertions(+), 154 deletions(-)
diff --git a/libc/src/__support/RPC/rpc_server.h
b/libc/src/__support/RPC/rpc_server.h
index abd604ae48146..98dc40ecd0a89 100644
--- a/libc/src/__support/RPC/rpc_server.h
+++ b/libc/src/__support/RPC/rpc_server.h
@@ -169,9 +169,7 @@ LIBC_INLINE static void handle_printf(rpc::Server::Port
&port,
if (!format[lane])
continue;
-printf_core::WriteBuffer<
-printf_core::WriteMode::FILL_BUFF_AND_DROP_OVERFLOW>
-wb(nullptr, 0);
+printf_core::DropOverflowBuffer wb(nullptr, 0);
printf_core::Writer writer(wb);
internal::DummyArgList printf_args;
@@ -198,9 +196,7 @@ LIBC_INLINE static void handle_printf(rpc::Server::Port
&port,
if (!format[lane])
continue;
-printf_core::WriteBuffer<
-printf_core::WriteMode::FILL_BUFF_AND_DROP_OVERFLOW>
-wb(nullptr, 0);
+printf_core::DropOverflowBuffer wb(nullptr, 0);
printf_core::Writer writer(wb);
internal::StructArgList printf_args(args[lane], args_sizes[lane]);
@@ -262,9 +258,7 @@ LIBC_INLINE static void handle_printf(rpc::Server::Port
&port,
continue;
char *buffer = temp_storage.alloc(buffer_size[lane]);
-printf_core::WriteBuffer<
-printf_core::WriteMode::FILL_BUFF_AND_DROP_OVERFLOW>
-wb(buffer, buffer_size[lane]);
+printf_core::DropOverflowBuffer wb(buffer, buffer_size[lane]);
printf_core::Writer writer(wb);
internal::StructArgList printf_args(args[lane], args_sizes[lane]);
diff --git a/libc/src/stdio/baremetal/printf.cpp
b/libc/src/stdio/baremetal/printf.cpp
index 5a9b19ff20471..2fa9cf7c9f3cd 100644
--- a/libc/src/stdio/baremetal/printf.cpp
+++ b/libc/src/stdio/baremetal/printf.cpp
@@ -41,9 +41,9 @@ LLVM_LIBC_FUNCTION(int, printf, (const char *__restrict
format, ...)) {
static constexpr size_t BUFF_SIZE = 1024;
char buffer[BUFF_SIZE];
- printf_core::WriteBuffer wb(
- buffer, BUFF_SIZE, &stdout_write_hook, nullptr);
- printf_core::Writer writer(wb);
+ printf_core::FlushingBuffer wb(buffer, BUFF_SIZE, &stdout_write_hook,
+ nullptr);
+ printf_core::Writer writer(wb);
auto retval = printf_core::printf_main(&writer, format, args);
if (!retval.has_value()) {
@@ -51,7 +51,7 @@ LLVM_LIBC_FUNCTION(int, printf, (const char *__restrict
format, ...)) {
return -1;
}
- int flushval = wb.overflow_write("");
+ int flushval = wb.flush_to_stream();
if (flushval != printf_core::WRITE_OK) {
libc_errno = printf_core::internal_error_to_errno(-flushval);
return -1;
diff --git a/libc/src/stdio/ba
[llvm-branch-commits] [libc] [libc][printf] De-string-viewify writer internals. (PR #170959)
https://github.com/vonosmas created
https://github.com/llvm/llvm-project/pull/170959
This change doesn't yet modify
Writer::write(string_view) public API, which
has a lot of uses through printf_core.
For wide-char write functions (like swprintf) we'd
need to templatize WriteBuffer and Writer to
support wide characrters. We'd need to either
support helper cpp::string_view class to support
wide-character strings, or replace them with pure
pointer/size pairs.
The latter option seems to be a more
straightforward one, given that majority of printf_core operates on buffers
anyway
(and only constructs string_views right
before invoking the buffer), and we don't
have a use case internal wide-character
string-views.
>From 008397fc8a6aa17b27aecd965c3fc2be433708c0 Mon Sep 17 00:00:00 2001
From: Alexey Samsonov
Date: Fri, 21 Nov 2025 19:45:34 +
Subject: [PATCH 1/2] [libc] Refactor static polymorphism in WriteBuffer (NFC).
There are three flavors of WriteBuffer currently, all of which
could be passed into printf_core::Writer class. It's a tricky
class, since it chooses a flavor-specific logic either based
on runtime dispatch (to save code size and prevent
generating three versions of the entirety of printf_core),
or based on template arguments (to avoid dealing with
function pointers in codegen for FILL_BUFF_AND_DROP_OVERFLOW path.
Refactor this somewhat convoluted logic to have three
concrete subclasses inheriting from the templated base
class, and use static polymorphism with reinterpret_cast
to implement dispatching above. Now we can actually
have flavor-specific fields, constructors, and methods
(e.g. "flush_to_stream" is now a method of FlushingBuffer),
and the code on the user side is cleaner: the complexity
of enabling/disabling runtime-dispatch and using proper
template arguments is now localized in writer.h.
This code will need to be further templatized to support
buffers of type wchar_t to implement swprintf() and
friends. This change would make it (ever so slightly) easier.
---
libc/src/__support/RPC/rpc_server.h | 12 +-
libc/src/stdio/baremetal/printf.cpp | 8 +-
libc/src/stdio/baremetal/vprintf.cpp | 8 +-
.../stdio/printf_core/vasprintf_internal.h| 10 +-
.../src/stdio/printf_core/vfprintf_internal.h | 6 +-
libc/src/stdio/printf_core/writer.h | 154 +++---
libc/src/stdio/snprintf.cpp | 4 +-
libc/src/stdio/sprintf.cpp| 5 +-
libc/src/stdio/vsnprintf.cpp | 4 +-
libc/src/stdio/vsprintf.cpp | 5 +-
libc/src/stdlib/strfromd.cpp | 4 +-
libc/src/stdlib/strfromf.cpp | 4 +-
libc/src/stdlib/strfroml.cpp | 4 +-
libc/src/time/strftime.cpp| 4 +-
libc/src/time/strftime_l.cpp | 4 +-
.../src/stdio/printf_core/converter_test.cpp | 16 +-
.../src/stdio/printf_core/writer_test.cpp | 64
17 files changed, 162 insertions(+), 154 deletions(-)
diff --git a/libc/src/__support/RPC/rpc_server.h
b/libc/src/__support/RPC/rpc_server.h
index abd604ae48146..98dc40ecd0a89 100644
--- a/libc/src/__support/RPC/rpc_server.h
+++ b/libc/src/__support/RPC/rpc_server.h
@@ -169,9 +169,7 @@ LIBC_INLINE static void handle_printf(rpc::Server::Port
&port,
if (!format[lane])
continue;
-printf_core::WriteBuffer<
-printf_core::WriteMode::FILL_BUFF_AND_DROP_OVERFLOW>
-wb(nullptr, 0);
+printf_core::DropOverflowBuffer wb(nullptr, 0);
printf_core::Writer writer(wb);
internal::DummyArgList printf_args;
@@ -198,9 +196,7 @@ LIBC_INLINE static void handle_printf(rpc::Server::Port
&port,
if (!format[lane])
continue;
-printf_core::WriteBuffer<
-printf_core::WriteMode::FILL_BUFF_AND_DROP_OVERFLOW>
-wb(nullptr, 0);
+printf_core::DropOverflowBuffer wb(nullptr, 0);
printf_core::Writer writer(wb);
internal::StructArgList printf_args(args[lane], args_sizes[lane]);
@@ -262,9 +258,7 @@ LIBC_INLINE static void handle_printf(rpc::Server::Port
&port,
continue;
char *buffer = temp_storage.alloc(buffer_size[lane]);
-printf_core::WriteBuffer<
-printf_core::WriteMode::FILL_BUFF_AND_DROP_OVERFLOW>
-wb(buffer, buffer_size[lane]);
+printf_core::DropOverflowBuffer wb(buffer, buffer_size[lane]);
printf_core::Writer writer(wb);
internal::StructArgList printf_args(args[lane], args_sizes[lane]);
diff --git a/libc/src/stdio/baremetal/printf.cpp
b/libc/src/stdio/baremetal/printf.cpp
index 5a9b19ff20471..2fa9cf7c9f3cd 100644
--- a/libc/src/stdio/baremetal/printf.cpp
+++ b/libc/src/stdio/baremetal/printf.cpp
@@ -41,9 +41,9 @@ LLVM_LIBC_FUNCTION(int, printf, (const char *__restrict
format, ...)) {
static constexpr size_t BUFF_SIZE = 1024;
char buffer[BUFF_SIZE];
- printf_core::WriteBuffer wb(
- buffer, BUFF_SIZE, &stdout_write_hook, nullptr);
-
[llvm-branch-commits] [libc] [libc][printf] De-string-viewify writer internals. (PR #170959)
vonosmas wrote: This is stacked on top of PR #169089 , to reduce the usage of cpp::string_view in Writer / WriteBuffer to simplify further templatization. https://github.com/llvm/llvm-project/pull/170959 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc][printf] De-string-viewify writer internals. (PR #170959)
vonosmas wrote: > I very much think this is the wrong direction. Using span / string_view style > types rather than raw pointer / size pairs is something I really think we > should aspire to stick to and move more outlier code towards. > `cpp::string_view` is a polyfill for `std::string_view`, which is already > actually just `std::basic_string_view`; it's easy enough to templatize > the polyfill as well and I don't see why we wouldn't just do that. > > In the long run, more Hand-in-Hand work with libc++ will probably give us > fuller string_view / span implementations to use directly in our hermetic > namespace without reimplementing them all ourselves as we have now in > `__support`. So I think putting a bit more work into our `cpp::*` types > now--in the direction of being more faithful and complete polyfills of > `std::*` counterparts--is not a slippery slope of complicating maintenance, > but a sensible interim approach that just further motivates our established > long-term intent to collaborate more extensively with libc++ on > implementation sharing. > > On the contrary, I think reverting from span/view-style types to an earlier > era's C conventions is itself a slippery slope of backsliding to lose the > benefits of our rigorous and modern C++ approach to libc implementation > internals. Thank you for the feedback! I wasn't aware that we consider using any of the libc++ container implementations inside llvm-libc, and I think it would be a quite a massive undertaking to do so? In any case, I agree that templatizing our `cpp::string_view` is certainly doable, and if that's the direction we want to go (and use the `string_view` for handling the wide-characters buffers as we create the implementation of more wide-char functions from C standard), let's choose this path instead. I'm closing this PR and will look into templatizing `cpp::string_view` instead. https://github.com/llvm/llvm-project/pull/170959 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libc] [libc][printf] De-string-viewify writer internals. (PR #170959)
https://github.com/vonosmas closed https://github.com/llvm/llvm-project/pull/170959 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
