xref: /llvm-project/libc/src/stdio/gpu/puts.cpp (revision a6ef0debb1d60966b5bcc69f7d58a2b75c9c621d)
1d04494ccSJoseph Huber //===-- GPU Implementation of puts ----------------------------------------===//
2d04494ccSJoseph Huber //
3d04494ccSJoseph Huber // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4d04494ccSJoseph Huber // See https://llvm.org/LICENSE.txt for license information.
5d04494ccSJoseph Huber // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d04494ccSJoseph Huber //
7d04494ccSJoseph Huber //===----------------------------------------------------------------------===//
8d04494ccSJoseph Huber 
9d04494ccSJoseph Huber #include "src/stdio/puts.h"
10d04494ccSJoseph Huber #include "src/__support/CPP/string_view.h"
115ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
12d04494ccSJoseph Huber #include "src/errno/libc_errno.h"
13d04494ccSJoseph Huber #include "src/stdio/gpu/file.h"
14d04494ccSJoseph Huber 
15c63112a9Slntue #include "hdr/stdio_macros.h" // for EOF and stdout.
16d04494ccSJoseph Huber 
175ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
18d04494ccSJoseph Huber 
19d04494ccSJoseph Huber LLVM_LIBC_FUNCTION(int, puts, (const char *__restrict str)) {
20d04494ccSJoseph Huber   cpp::string_view str_view(str);
21*a6ef0debSJoseph Huber   auto written = file::write_impl<LIBC_WRITE_TO_STDOUT_NEWLINE>(stdout, str,
22791b2799SJoseph Huber                                                                str_view.size());
23791b2799SJoseph Huber   if (written != str_view.size() + 1)
24d04494ccSJoseph Huber     return EOF;
25d04494ccSJoseph Huber   return 0;
26d04494ccSJoseph Huber }
27d04494ccSJoseph Huber 
285ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
29