xref: /llvm-project/libc/src/sys/mman/linux/shm_unlink.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1f6f42af0SSchrodinger ZHU Yifan //===---------- Linux implementation of the shm_unlink function -----------===//
2f6f42af0SSchrodinger ZHU Yifan //
3f6f42af0SSchrodinger ZHU Yifan // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4f6f42af0SSchrodinger ZHU Yifan // See https://llvm.org/LICENSE.txt for license information.
5f6f42af0SSchrodinger ZHU Yifan // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f6f42af0SSchrodinger ZHU Yifan //
7f6f42af0SSchrodinger ZHU Yifan //===----------------------------------------------------------------------===//
8f6f42af0SSchrodinger ZHU Yifan 
9f6f42af0SSchrodinger ZHU Yifan #include "src/sys/mman/shm_unlink.h"
10*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
11f6f42af0SSchrodinger ZHU Yifan #include "src/sys/mman/linux/shm_common.h"
12f6f42af0SSchrodinger ZHU Yifan #include "src/unistd/unlink.h"
13f6f42af0SSchrodinger ZHU Yifan 
14*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
15f6f42af0SSchrodinger ZHU Yifan 
16f6f42af0SSchrodinger ZHU Yifan LLVM_LIBC_FUNCTION(int, shm_unlink, (const char *name)) {
17f6f42af0SSchrodinger ZHU Yifan   using namespace shm_common;
18f6f42af0SSchrodinger ZHU Yifan   if (cpp::optional<SHMPath> buffer = translate_name(name))
19f6f42af0SSchrodinger ZHU Yifan     return unlink(buffer->data());
20f6f42af0SSchrodinger ZHU Yifan   return -1;
21f6f42af0SSchrodinger ZHU Yifan }
22f6f42af0SSchrodinger ZHU Yifan 
23*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
24