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 "llvm-libc-macros/fcntl-macros.h"
11#include "src/fcntl/open.h"
12#include "src/sys/mman/linux/shm_common.h"
13
14namespace LIBC_NAMESPACE {
15
16static constexpr int DEFAULT_OFLAGS = O_NOFOLLOW | O_CLOEXEC | O_NONBLOCK;
17
18LLVM_LIBC_FUNCTION(int, shm_open, (const char *name, int oflags, mode_t mode)) {
19 using namespace shm_common;
20 if (cpp::optional<SHMPath> buffer = translate_name(name))
21 return open(path: buffer->data(), flags: oflags | DEFAULT_OFLAGS, mode);
22 return -1;
23}
24
25} // namespace LIBC_NAMESPACE
26

source code of libc/src/sys/mman/linux/shm_open.cpp