xref: /aosp_15_r20/external/llvm-libc/src/stdio/gpu/fprintf.cpp (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- GPU Implementation of fprintf -------------------------------------===//
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/fprintf.h"
10 
11 #include "hdr/types/FILE.h"
12 #include "src/__support/CPP/string_view.h"
13 #include "src/__support/arg_list.h"
14 #include "src/errno/libc_errno.h"
15 #include "src/stdio/gpu/vfprintf_utils.h"
16 
17 #include <stdarg.h>
18 
19 namespace LIBC_NAMESPACE_DECL {
20 
21 LLVM_LIBC_FUNCTION(int, fprintf,
22                    (::FILE *__restrict stream, const char *__restrict format,
23                     ...)) {
24   va_list vlist;
25   va_start(vlist, format);
26   cpp::string_view str_view(format);
27   int ret_val = vfprintf_internal(stream, format, str_view.size() + 1, vlist);
28   va_end(vlist);
29   return ret_val;
30 }
31 
32 } // namespace LIBC_NAMESPACE_DECL
33