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/__support/common.h"
14#include "src/__support/libc_errno.h"
15#include "src/stdio/gpu/vfprintf_utils.h"
16
17#include <stdarg.h>
18
19namespace LIBC_NAMESPACE_DECL {
20
21LLVM_LIBC_FUNCTION(int, printf, (const char *__restrict format, ...)) {
22 va_list vlist;
23 va_start(vlist, format);
24 cpp::string_view str_view(format);
25 int ret_val = vfprintf_internal(stdout, format, str_view.size() + 1, vlist);
26 va_end(vlist);
27 return ret_val;
28}
29
30} // namespace LIBC_NAMESPACE_DECL
31

source code of libc/src/stdio/gpu/printf.cpp