xref: /llvm-project/libc/src/stdio/gpu/fputc.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
160c0d303SJoseph Huber //===-- GPU implementation of fputc ---------------------------------------===//
260c0d303SJoseph Huber //
360c0d303SJoseph Huber // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
460c0d303SJoseph Huber // See https://llvm.org/LICENSE.txt for license information.
560c0d303SJoseph Huber // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
660c0d303SJoseph Huber //
760c0d303SJoseph Huber //===----------------------------------------------------------------------===//
860c0d303SJoseph Huber 
960c0d303SJoseph Huber #include "src/stdio/fputc.h"
105aed6d67SMichael Jones #include "file.h"
11*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
1260c0d303SJoseph Huber 
135aed6d67SMichael Jones #include "hdr/stdio_macros.h" // for EOF.
145aed6d67SMichael Jones #include "hdr/types/FILE.h"
1560c0d303SJoseph Huber 
16*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
1760c0d303SJoseph Huber 
1860c0d303SJoseph Huber LLVM_LIBC_FUNCTION(int, fputc, (int c, ::FILE *stream)) {
1960c0d303SJoseph Huber   unsigned char uc = static_cast<unsigned char>(c);
2060c0d303SJoseph Huber 
2160c0d303SJoseph Huber   size_t written = file::write(stream, &uc, 1);
2260c0d303SJoseph Huber   if (1 != written)
2360c0d303SJoseph Huber     return EOF;
2460c0d303SJoseph Huber 
2560c0d303SJoseph Huber   return 0;
2660c0d303SJoseph Huber }
2760c0d303SJoseph Huber 
28*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
29