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