• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- Linux implementation of write -------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "src/unistd/write.h"
10 
11 #include "config/linux/syscall.h" // For internal syscall function.
12 #include "include/sys/syscall.h"  // For syscall numbers.
13 #include "src/__support/common.h"
14 #include "src/errno/llvmlibc_errno.h"
15 
16 namespace __llvm_libc {
17 
LLVM_LIBC_ENTRYPOINT(write)18 ssize_t LLVM_LIBC_ENTRYPOINT(write)(int fd, const void *buf, size_t count) {
19   long ret = __llvm_libc::syscall(SYS_write, fd, buf, count);
20   if (ret < 0) {
21     llvmlibc_errno = -ret;
22     return -1;
23   }
24   return ret;
25 }
26 
27 } // namespace __llvm_libc
28