160c0d303SJoseph Huber //===-- GPU implementation of putchar -------------------------------------===// 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/putchar.h" 105aed6d67SMichael Jones #include "file.h" 115ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 1260c0d303SJoseph Huber 13*c63112a9Slntue #include "hdr/stdio_macros.h" // for EOF and stdout. 1460c0d303SJoseph Huber 155ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 1660c0d303SJoseph Huber 1760c0d303SJoseph Huber LLVM_LIBC_FUNCTION(int, putchar, (int c)) { 1860c0d303SJoseph Huber unsigned char uc = static_cast<unsigned char>(c); 1960c0d303SJoseph Huber 2060c0d303SJoseph Huber size_t written = file::write(stdout, &uc, 1); 2160c0d303SJoseph Huber if (1 != written) 2260c0d303SJoseph Huber return EOF; 2360c0d303SJoseph Huber 2460c0d303SJoseph Huber return 0; 2560c0d303SJoseph Huber } 2660c0d303SJoseph Huber 275ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 28