14eea8849SSiva Chandra Reddy //===-- Implementation of setvbuf -----------------------------------------===// 24eea8849SSiva Chandra Reddy // 34eea8849SSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 44eea8849SSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information. 54eea8849SSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 64eea8849SSiva Chandra Reddy // 74eea8849SSiva Chandra Reddy //===----------------------------------------------------------------------===// 84eea8849SSiva Chandra Reddy 94eea8849SSiva Chandra Reddy #include "src/stdio/setvbuf.h" 104eea8849SSiva Chandra Reddy #include "src/__support/File/file.h" 114eea8849SSiva Chandra Reddy 125aed6d67SMichael Jones #include "hdr/types/FILE.h" 13*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 1404a9c625SMichael Jones #include "src/errno/libc_errno.h" 155aed6d67SMichael Jones #include <stddef.h> 164eea8849SSiva Chandra Reddy 17*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 184eea8849SSiva Chandra Reddy 194eea8849SSiva Chandra Reddy LLVM_LIBC_FUNCTION(int, setvbuf, 204eea8849SSiva Chandra Reddy (::FILE *__restrict stream, char *__restrict buf, int type, 214eea8849SSiva Chandra Reddy size_t size)) { 22b6bc9d72SGuillaume Chatelet int err = reinterpret_cast<LIBC_NAMESPACE::File *>(stream)->set_buffer( 23b6bc9d72SGuillaume Chatelet buf, size, type); 244eea8849SSiva Chandra Reddy if (err != 0) 2504a9c625SMichael Jones libc_errno = err; 264eea8849SSiva Chandra Reddy return err; 274eea8849SSiva Chandra Reddy } 284eea8849SSiva Chandra Reddy 29*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 30