[Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (#121656)
[llvm-project.git] / libc / src / sys / mman / linux / shm_open.cpp
blob11de482272d00a608a9cc0cf7d7bb0988a194c3d
1 //===---------- Linux implementation of the shm_open function -------------===//
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 //===----------------------------------------------------------------------===//
9 #include "src/sys/mman/shm_open.h"
10 #include "hdr/types/mode_t.h"
11 #include "src/__support/macros/config.h"
12 #include "src/fcntl/open.h"
13 #include "src/sys/mman/linux/shm_common.h"
15 namespace LIBC_NAMESPACE_DECL {
17 static constexpr int DEFAULT_OFLAGS = O_NOFOLLOW | O_CLOEXEC | O_NONBLOCK;
19 LLVM_LIBC_FUNCTION(int, shm_open, (const char *name, int oflags, mode_t mode)) {
20 using namespace shm_common;
21 if (cpp::optional<SHMPath> buffer = translate_name(name))
22 return open(buffer->data(), oflags | DEFAULT_OFLAGS, mode);
23 return -1;
26 } // namespace LIBC_NAMESPACE_DECL