diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt index 11f560ed2b90f..ad41267626664 100644 --- a/libc/config/baremetal/arm/entrypoints.txt +++ b/libc/config/baremetal/arm/entrypoints.txt @@ -85,6 +85,7 @@ set(TARGET_LIBC_ENTRYPOINTS # stdio.h entrypoints libc.src.stdio.printf libc.src.stdio.putchar + libc.src.stdio.puts libc.src.stdio.remove libc.src.stdio.snprintf libc.src.stdio.sprintf diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt index f203317e2839d..6ed6732918b42 100644 --- a/libc/config/baremetal/riscv/entrypoints.txt +++ b/libc/config/baremetal/riscv/entrypoints.txt @@ -81,6 +81,7 @@ set(TARGET_LIBC_ENTRYPOINTS # stdio.h entrypoints libc.src.stdio.printf libc.src.stdio.putchar + libc.src.stdio.puts libc.src.stdio.remove libc.src.stdio.snprintf libc.src.stdio.sprintf diff --git a/libc/src/stdio/baremetal/CMakeLists.txt b/libc/src/stdio/baremetal/CMakeLists.txt index 45196ffc9de24..4acd8873ab753 100644 --- a/libc/src/stdio/baremetal/CMakeLists.txt +++ b/libc/src/stdio/baremetal/CMakeLists.txt @@ -32,6 +32,17 @@ add_entrypoint_object( libc.src.__support.CPP.string_view ) +add_entrypoint_object( + puts + SRCS + puts.cpp + HDRS + ../puts.h + DEPENDS + libc.src.__support.OSUtil.osutil + libc.src.__support.CPP.string_view +) + add_entrypoint_object( vprintf SRCS diff --git a/libc/src/stdio/baremetal/puts.cpp b/libc/src/stdio/baremetal/puts.cpp new file mode 100644 index 0000000000000..136cdb8acf800 --- /dev/null +++ b/libc/src/stdio/baremetal/puts.cpp @@ -0,0 +1,25 @@ +//===-- Implementation of puts for baremetal-------------------------------===// +// +// 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/stdio/puts.h" +#include "src/__support/CPP/string_view.h" +#include "src/__support/OSUtil/io.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(int, puts, (const char *__restrict str)) { + cpp::string_view str_view(str); + + // TODO: Can we combine these to avoid needing two writes? + write_to_stderr(str_view); + write_to_stderr("\n"); + + return 0; +} + +} // namespace LIBC_NAMESPACE