1 //===-- Implementation of creat -------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "src/fcntl/creat.h"
11 #include "src/__support/OSUtil/syscall.h" // For internal syscall function.
12 #include "src/__support/common.h"
13 #include "src/errno/libc_errno.h"
16 #include <sys/syscall.h> // For syscall numbers.
18 namespace __llvm_libc
{
20 LLVM_LIBC_FUNCTION(int, creat
, (const char *path
, int mode_flags
)) {
22 int fd
= __llvm_libc::syscall_impl(SYS_open
, path
,
23 O_CREAT
| O_WRONLY
| O_TRUNC
, mode_flags
);
25 int fd
= __llvm_libc::syscall_impl(SYS_openat
, AT_FDCWD
, path
,
26 O_CREAT
| O_WRONLY
| O_TRUNC
, mode_flags
);
36 } // namespace __llvm_libc