xref: /aosp_15_r20/external/llvm-libc/src/stdio/gpu/fputs.cpp (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- GPU Implementation of fputs ---------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "src/stdio/fputs.h"
10 #include "src/__support/CPP/string_view.h"
11 #include "src/__support/macros/config.h"
12 #include "src/errno/libc_errno.h"
13 #include "src/stdio/gpu/file.h"
14 
15 #include "hdr/stdio_macros.h" // for EOF.
16 #include "hdr/types/FILE.h"
17 
18 namespace LIBC_NAMESPACE_DECL {
19 
20 LLVM_LIBC_FUNCTION(int, fputs,
21                    (const char *__restrict str, ::FILE *__restrict stream)) {
22   cpp::string_view str_view(str);
23   auto written = file::write(stream, str, str_view.size());
24   if (written != str_view.size())
25     return EOF;
26   return 0;
27 }
28 
29 } // namespace LIBC_NAMESPACE_DECL
30