File tree Expand file tree Collapse file tree 10 files changed +98
-0
lines changed Expand file tree Collapse file tree 10 files changed +98
-0
lines changed Original file line number Diff line number Diff line change @@ -341,6 +341,7 @@ set(TARGET_LIBC_ENTRYPOINTS
341341 libc.src.unistd.readlink
342342 libc.src.unistd.readlinkat
343343 libc.src.unistd.rmdir
344+ libc.src.unistd.setsid
344345 libc.src.unistd.symlink
345346 libc.src.unistd.symlinkat
346347 libc.src.unistd.sysconf
Original file line number Diff line number Diff line change @@ -337,6 +337,7 @@ set(TARGET_LIBC_ENTRYPOINTS
337337 libc.src.unistd.readlink
338338 libc.src.unistd.readlinkat
339339 libc.src.unistd.rmdir
340+ libc.src.unistd.setsid
340341 libc.src.unistd.symlink
341342 libc.src.unistd.symlinkat
342343 libc.src.unistd.sysconf
Original file line number Diff line number Diff line change @@ -340,6 +340,7 @@ set(TARGET_LIBC_ENTRYPOINTS
340340 libc.src.unistd.readlink
341341 libc.src.unistd.readlinkat
342342 libc.src.unistd.rmdir
343+ libc.src.unistd.setsid
343344 libc.src.unistd.symlink
344345 libc.src.unistd.symlinkat
345346 libc.src.unistd.sysconf
Original file line number Diff line number Diff line change @@ -275,6 +275,12 @@ functions:
275275 - type : const void *__restrict
276276 - type : void *
277277 - type : ssize_t
278+ - name : setsid
279+ standards :
280+ - POSIX
281+ return_type : pid_t
282+ arguments :
283+ - type : void
278284 - name : symlink
279285 standards :
280286 - POSIX
Original file line number Diff line number Diff line change @@ -231,6 +231,13 @@ add_entrypoint_object(
231231 .${LIBC_TARGET_OS} .rmdir
232232)
233233
234+ add_entrypoint_object(
235+ setsid
236+ ALIAS
237+ DEPENDS
238+ .${LIBC_TARGET_OS} .setsid
239+ )
240+
234241add_entrypoint_object(
235242 symlink
236243 ALIAS
Original file line number Diff line number Diff line change @@ -459,6 +459,18 @@ add_entrypoint_object(
459459 libc.src.errno.errno
460460)
461461
462+ add_entrypoint_object(
463+ setsid
464+ SRCS
465+ setsid.cpp
466+ HDRS
467+ ../setsid.h
468+ DEPENDS
469+ libc.hdr.types.pid_t
470+ libc.include .sys_syscall
471+ libc.src.__support.OSUtil.osutil
472+ )
473+
462474add_entrypoint_object(
463475 symlink
464476 SRCS
Original file line number Diff line number Diff line change 1+ // ===-- Linux implementation of setsid-------------------------------------===//
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/unistd/setsid.h"
10+
11+ #include " hdr/types/pid_t.h"
12+ #include " src/__support/OSUtil/syscall.h" // For internal syscall function.
13+ #include " src/__support/common.h"
14+ #include " src/__support/macros/config.h"
15+
16+ #include < sys/syscall.h> // For syscall numbers.
17+
18+ namespace LIBC_NAMESPACE_DECL {
19+
20+ LLVM_LIBC_FUNCTION (pid_t , setsid, ()) {
21+ return LIBC_NAMESPACE::syscall_impl<pid_t >(SYS_setsid);
22+ }
23+
24+ } // namespace LIBC_NAMESPACE_DECL
Original file line number Diff line number Diff line change 1+ // ===-- Implementation header for setsid ------------------------*- C++ -*-===//
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+ #ifndef LLVM_LIBC_SRC_UNISTD_GETPID_H
10+ #define LLVM_LIBC_SRC_UNISTD_GETPID_H
11+
12+ #include " hdr/types/pid_t.h"
13+ #include " src/__support/macros/config.h"
14+
15+ namespace LIBC_NAMESPACE_DECL {
16+
17+ pid_t setsid ();
18+
19+ } // namespace LIBC_NAMESPACE_DECL
20+
21+ #endif // LLVM_LIBC_SRC_UNISTD_GETPID_H
Original file line number Diff line number Diff line change @@ -287,6 +287,16 @@ add_libc_unittest(
287287 libc.src.__support.CPP.string_view
288288)
289289
290+ add_libc_unittest(
291+ setsid_test
292+ SUITE
293+ libc_unistd_unittests
294+ SRCS
295+ setsid_test.cpp
296+ DEPENDS
297+ libc.src.unistd.setsid
298+ )
299+
290300add_libc_unittest(
291301 symlink_test
292302 SUITE
Original file line number Diff line number Diff line change 1+ // ===-- Unittests for setsid ----------------------------------------------===//
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/unistd/setsid.h"
10+ #include " test/UnitTest/Test.h"
11+
12+ TEST (LlvmLibcGetPidTest, SmokeTest) {
13+ // setsid always succeeds. So, we just call it as a smoke test.
14+ LIBC_NAMESPACE::setsid ();
15+ }
You can’t perform that action at this time.
0 commit comments