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 | //===----------------------------------------------------------------------===// |
8 | |
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" |
14 | |
15 | namespace LIBC_NAMESPACE_DECL { |
16 | |
17 | static constexpr int DEFAULT_OFLAGS = O_NOFOLLOW | O_CLOEXEC | O_NONBLOCK; |
18 | |
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; |
24 | } |
25 | |
26 | } // namespace LIBC_NAMESPACE_DECL |
27 |