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