1*ad233c60SMichael Jones //===-- Implementation of printf --------------------------------*- C++ -*-===// 2*ad233c60SMichael Jones // 3*ad233c60SMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*ad233c60SMichael Jones // See https://llvm.org/LICENSE.txt for license information. 5*ad233c60SMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*ad233c60SMichael Jones // 7*ad233c60SMichael Jones //===----------------------------------------------------------------------===// 8*ad233c60SMichael Jones 9*ad233c60SMichael Jones #include "src/stdio/printf.h" 10*ad233c60SMichael Jones 11*ad233c60SMichael Jones #include "src/__support/File/file.h" 12*ad233c60SMichael Jones #include "src/__support/arg_list.h" 13*ad233c60SMichael Jones #include "src/stdio/printf_core/vfprintf_internal.h" 14*ad233c60SMichael Jones 15*ad233c60SMichael Jones #include <stdarg.h> 16*ad233c60SMichael Jones 17*ad233c60SMichael Jones namespace __llvm_libc { 18*ad233c60SMichael Jones 19*ad233c60SMichael Jones LLVM_LIBC_FUNCTION(int, printf, (const char *__restrict format, ...)) { 20*ad233c60SMichael Jones va_list vlist; 21*ad233c60SMichael Jones va_start(vlist, format); 22*ad233c60SMichael Jones internal::ArgList args(vlist); // This holder class allows for easier copying 23*ad233c60SMichael Jones // and pointer semantics, as well as handling 24*ad233c60SMichael Jones // destruction automatically. 25*ad233c60SMichael Jones va_end(vlist); 26*ad233c60SMichael Jones int ret_val = printf_core::vfprintf_internal( 27*ad233c60SMichael Jones reinterpret_cast<::FILE *>(__llvm_libc::stdout), format, args); 28*ad233c60SMichael Jones return ret_val; 29*ad233c60SMichael Jones } 30*ad233c60SMichael Jones 31*ad233c60SMichael Jones } // namespace __llvm_libc 32