[libc-commits] [libc] 4f1474d - [libc] Add implementations of POSIX getpid, getppid, getuid, geteuid functions.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Wed Sep 21 11:41:36 PDT 2022
Author: Siva Chandra Reddy
Date: 2022-09-21T18:41:20Z
New Revision: 4f1474daec4fbdca779b4d0aa3de19950c8287b5
URL: https://github.com/llvm/llvm-project/commit/4f1474daec4fbdca779b4d0aa3de19950c8287b5
DIFF: https://github.com/llvm/llvm-project/commit/4f1474daec4fbdca779b4d0aa3de19950c8287b5.diff
LOG: [libc] Add implementations of POSIX getpid, getppid, getuid, geteuid functions.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D134338
Added:
libc/include/llvm-libc-types/pid_t.h
libc/src/unistd/geteuid.h
libc/src/unistd/getpid.h
libc/src/unistd/getppid.h
libc/src/unistd/getuid.h
libc/src/unistd/linux/geteuid.cpp
libc/src/unistd/linux/getpid.cpp
libc/src/unistd/linux/getppid.cpp
libc/src/unistd/linux/getuid.cpp
libc/test/src/unistd/geteuid_test.cpp
libc/test/src/unistd/getpid_test.cpp
libc/test/src/unistd/getppid_test.cpp
libc/test/src/unistd/getuid_test.cpp
Modified:
libc/config/linux/api.td
libc/config/linux/x86_64/entrypoints.txt
libc/include/CMakeLists.txt
libc/include/llvm-libc-types/CMakeLists.txt
libc/spec/posix.td
libc/src/unistd/CMakeLists.txt
libc/src/unistd/linux/CMakeLists.txt
libc/test/src/unistd/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td
index 665620e8533be..8dbe3aa3b3e85 100644
--- a/libc/config/linux/api.td
+++ b/libc/config/linux/api.td
@@ -269,7 +269,7 @@ def DirentAPI : PublicAPI<"dirent.h"> {
}
def UniStdAPI : PublicAPI<"unistd.h"> {
- let Types = ["off_t", "size_t", "ssize_t"];
+ let Types = ["off_t", "pid_t", "size_t", "ssize_t", "uid_t"];
}
def SysResourceAPI : PublicAPI<"sys/resource.h"> {
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 5d5d73e9c6989..04f403dd0baab 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -132,6 +132,10 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.unistd.fchdir
libc.src.unistd.fsync
libc.src.unistd.ftruncate
+ libc.src.unistd.geteuid
+ libc.src.unistd.getpid
+ libc.src.unistd.getppid
+ libc.src.unistd.getuid
libc.src.unistd.link
libc.src.unistd.linkat
libc.src.unistd.lseek
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 30b4af0fd652d..cc7ec17b9afb8 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -169,8 +169,10 @@ add_gen_header(
.llvm_libc_common_h
.llvm-libc-macros.file_seek_macros
.llvm-libc-macros.unistd_macros
+ .llvm-libc-types.pid_t
.llvm-libc-types.size_t
.llvm-libc-types.ssize_t
+ .llvm-libc-types.uid_t
)
add_gen_header(
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 432278e41f4c2..5fde05a3665ae 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -32,6 +32,7 @@ add_header(mtx_t HDR mtx_t.h DEPENDS .__futex_word .__mutex_type)
add_header(nlink_t HDR nlink_t.h)
add_header(off_t HDR off_t.h)
add_header(once_flag HDR once_flag.h DEPENDS .__futex_word)
+add_header(pid_t HDR pid_t.h)
add_header(pthread_attr_t HDR pthread_attr_t.h DEPENDS .size_t)
add_header(pthread_key_t HDR pthread_key_t.h)
add_header(pthread_mutex_t HDR pthread_mutex_t.h DEPENDS .__futex_word .__mutex_type)
diff --git a/libc/include/llvm-libc-types/pid_t.h b/libc/include/llvm-libc-types/pid_t.h
new file mode 100644
index 0000000000000..d78fde74f34ad
--- /dev/null
+++ b/libc/include/llvm-libc-types/pid_t.h
@@ -0,0 +1,14 @@
+//===-- Definition of pid_t type ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_TYPES_PID_t_H__
+#define __LLVM_LIBC_TYPES_PID_t_H__
+
+typedef __INT32_TYPE__ pid_t;
+
+#endif // __LLVM_LIBC_TYPES_PID_t_H__
diff --git a/libc/spec/posix.td b/libc/spec/posix.td
index 3c5e093b2b1de..df35e557153cc 100644
--- a/libc/spec/posix.td
+++ b/libc/spec/posix.td
@@ -23,6 +23,7 @@ def BlkSizeT : NamedType<"blksize_t">;
def BlkCntT : NamedType<"blkcnt_t">;
def NLinkT : NamedType<"nlink_t">;
def TimeSpec : NamedType<"struct timespec">;
+def PidT : NamedType<"pid_t">;
def StatType : NamedType<"struct stat">;
def StatTypePtr : PtrType<StatType>;
@@ -270,6 +271,8 @@ def POSIX : StandardSpec<"POSIX"> {
OffTType,
SSizeTType,
SizeTType,
+ PidT,
+ UidT,
],
[], // Enumerations
[
@@ -318,6 +321,81 @@ def POSIX : StandardSpec<"POSIX"> {
RetValSpec<IntType>,
[ArgSpec<ConstCharPtr>, ArgSpec<OffTType>]
>,
+ FunctionSpec<
+ "geteuid",
+ RetValSpec<UidT>,
+ [ArgSpec<VoidType>]
+ >,
+ FunctionSpec<
+ "getpid",
+ RetValSpec<PidT>,
+ [ArgSpec<VoidType>]
+ >,
+ FunctionSpec<
+ "getppid",
+ RetValSpec<PidT>,
+ [ArgSpec<VoidType>]
+ >,
+ FunctionSpec<
+ "getuid",
+ RetValSpec<UidT>,
+ [ArgSpec<VoidType>]
+ >,
+ FunctionSpec<
+ "link",
+ RetValSpec<IntType>,
+ [ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>]
+ >,
+ FunctionSpec<
+ "linkat",
+ RetValSpec<IntType>,
+ [ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>, ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
+ >,
+ FunctionSpec<
+ "lseek",
+ RetValSpec<OffTType>,
+ [ArgSpec<IntType>, ArgSpec<OffTType>, ArgSpec<IntType>]
+ >,
+ FunctionSpec<
+ "pread",
+ RetValSpec<SSizeTType>,
+ [ArgSpec<IntType>, ArgSpec<VoidPtr>, ArgSpec<SizeTType>, ArgSpec<OffTType>]
+ >,
+ FunctionSpec<
+ "pwrite",
+ RetValSpec<SSizeTType>,
+ [ArgSpec<IntType>, ArgSpec<ConstVoidPtr>, ArgSpec<SizeTType>, ArgSpec<OffTType>]
+ >,
+ FunctionSpec<
+ "read",
+ RetValSpec<SSizeTType>,
+ [ArgSpec<IntType>, ArgSpec<VoidPtr>, ArgSpec<SizeTType>]
+ >,
+ FunctionSpec<
+ "readlink",
+ RetValSpec<SSizeTType>,
+ [ArgSpec<ConstCharRestrictedPtr>, ArgSpec<CharRestrictedPtr>, ArgSpec<SizeTType>]
+ >,
+ FunctionSpec<
+ "readlinkat",
+ RetValSpec<SSizeTType>,
+ [ArgSpec<ConstCharRestrictedPtr>, ArgSpec<CharRestrictedPtr>, ArgSpec<SizeTType>]
+ >,
+ FunctionSpec<
+ "rmdir",
+ RetValSpec<IntType>,
+ [ArgSpec<ConstCharPtr>]
+ >,
+ FunctionSpec<
+ "getpid",
+ RetValSpec<IntType>,
+ [ArgSpec<VoidType>]
+ >,
+ FunctionSpec<
+ "getppid",
+ RetValSpec<IntType>,
+ [ArgSpec<VoidType>]
+ >,
FunctionSpec<
"link",
RetValSpec<IntType>,
diff --git a/libc/src/unistd/CMakeLists.txt b/libc/src/unistd/CMakeLists.txt
index bc501570ccd82..437556c3a4585 100644
--- a/libc/src/unistd/CMakeLists.txt
+++ b/libc/src/unistd/CMakeLists.txt
@@ -65,6 +65,34 @@ add_entrypoint_object(
.${LIBC_TARGET_OS}.ftruncate
)
+add_entrypoint_object(
+ getpid
+ ALIAS
+ DEPENDS
+ .${LIBC_TARGET_OS}.getpid
+)
+
+add_entrypoint_object(
+ getppid
+ ALIAS
+ DEPENDS
+ .${LIBC_TARGET_OS}.getppid
+)
+
+add_entrypoint_object(
+ geteuid
+ ALIAS
+ DEPENDS
+ .${LIBC_TARGET_OS}.geteuid
+)
+
+add_entrypoint_object(
+ getuid
+ ALIAS
+ DEPENDS
+ .${LIBC_TARGET_OS}.getuid
+)
+
add_entrypoint_object(
link
ALIAS
diff --git a/libc/src/unistd/geteuid.h b/libc/src/unistd/geteuid.h
new file mode 100644
index 0000000000000..0df98fbee9553
--- /dev/null
+++ b/libc/src/unistd/geteuid.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for geteuid -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_UNISTD_GETEUID_H
+#define LLVM_LIBC_SRC_UNISTD_GETEUID_H
+
+#include <unistd.h>
+
+namespace __llvm_libc {
+
+uid_t geteuid();
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_UNISTD_GETEUID_H
diff --git a/libc/src/unistd/getpid.h b/libc/src/unistd/getpid.h
new file mode 100644
index 0000000000000..7b6b9b1600ccd
--- /dev/null
+++ b/libc/src/unistd/getpid.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for getpid ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_UNISTD_GETPID_H
+#define LLVM_LIBC_SRC_UNISTD_GETPID_H
+
+#include <unistd.h>
+
+namespace __llvm_libc {
+
+pid_t getpid();
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_UNISTD_GETPID_H
diff --git a/libc/src/unistd/getppid.h b/libc/src/unistd/getppid.h
new file mode 100644
index 0000000000000..c5744778b5f97
--- /dev/null
+++ b/libc/src/unistd/getppid.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for getppid -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_UNISTD_GETPPID_H
+#define LLVM_LIBC_SRC_UNISTD_GETPPID_H
+
+#include <unistd.h>
+
+namespace __llvm_libc {
+
+pid_t getppid();
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_UNISTD_GETPPID_H
diff --git a/libc/src/unistd/getuid.h b/libc/src/unistd/getuid.h
new file mode 100644
index 0000000000000..e3501ca04bf99
--- /dev/null
+++ b/libc/src/unistd/getuid.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for getuid ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_UNISTD_GETUID_H
+#define LLVM_LIBC_SRC_UNISTD_GETUID_H
+
+#include <unistd.h>
+
+namespace __llvm_libc {
+
+uid_t getuid();
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_UNISTD_GETUID_H
diff --git a/libc/src/unistd/linux/CMakeLists.txt b/libc/src/unistd/linux/CMakeLists.txt
index 186fdc2631004..6c1bf34f70392 100644
--- a/libc/src/unistd/linux/CMakeLists.txt
+++ b/libc/src/unistd/linux/CMakeLists.txt
@@ -116,6 +116,54 @@ add_entrypoint_object(
libc.src.errno.errno
)
+add_entrypoint_object(
+ geteuid
+ SRCS
+ geteuid.cpp
+ HDRS
+ ../geteuid.h
+ DEPENDS
+ libc.include.unistd
+ libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
+)
+
+add_entrypoint_object(
+ getpid
+ SRCS
+ getpid.cpp
+ HDRS
+ ../getpid.h
+ DEPENDS
+ libc.include.unistd
+ libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
+)
+
+add_entrypoint_object(
+ getppid
+ SRCS
+ getppid.cpp
+ HDRS
+ ../getppid.h
+ DEPENDS
+ libc.include.unistd
+ libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
+)
+
+add_entrypoint_object(
+ getuid
+ SRCS
+ getuid.cpp
+ HDRS
+ ../getuid.h
+ DEPENDS
+ libc.include.unistd
+ libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
+)
+
add_entrypoint_object(
link
SRCS
diff --git a/libc/src/unistd/linux/geteuid.cpp b/libc/src/unistd/linux/geteuid.cpp
new file mode 100644
index 0000000000000..734da5abd4847
--- /dev/null
+++ b/libc/src/unistd/linux/geteuid.cpp
@@ -0,0 +1,22 @@
+//===-- Linux implementation of geteuid -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/geteuid.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(uid_t, geteuid, ()) {
+ return __llvm_libc::syscall(SYS_geteuid);
+}
+
+} // namespace __llvm_libc
diff --git a/libc/src/unistd/linux/getpid.cpp b/libc/src/unistd/linux/getpid.cpp
new file mode 100644
index 0000000000000..d00112f8b929b
--- /dev/null
+++ b/libc/src/unistd/linux/getpid.cpp
@@ -0,0 +1,22 @@
+//===-- Linux implementation of getpid ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/getpid.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(pid_t, getpid, ()) {
+ return __llvm_libc::syscall(SYS_getpid);
+}
+
+} // namespace __llvm_libc
diff --git a/libc/src/unistd/linux/getppid.cpp b/libc/src/unistd/linux/getppid.cpp
new file mode 100644
index 0000000000000..be5ab23cfcb34
--- /dev/null
+++ b/libc/src/unistd/linux/getppid.cpp
@@ -0,0 +1,22 @@
+//===-- Linux implementation of getppid -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/getppid.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(pid_t, getppid, ()) {
+ return __llvm_libc::syscall(SYS_getppid);
+}
+
+} // namespace __llvm_libc
diff --git a/libc/src/unistd/linux/getuid.cpp b/libc/src/unistd/linux/getuid.cpp
new file mode 100644
index 0000000000000..716fa61de762c
--- /dev/null
+++ b/libc/src/unistd/linux/getuid.cpp
@@ -0,0 +1,22 @@
+//===-- Linux implementation of getuid ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/getuid.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(uid_t, getuid, ()) {
+ return __llvm_libc::syscall(SYS_getuid);
+}
+
+} // namespace __llvm_libc
diff --git a/libc/test/src/unistd/CMakeLists.txt b/libc/test/src/unistd/CMakeLists.txt
index c4ad96b9eebaa..8f35efe947e55 100644
--- a/libc/test/src/unistd/CMakeLists.txt
+++ b/libc/test/src/unistd/CMakeLists.txt
@@ -321,3 +321,43 @@ add_libc_unittest(
libc.src.unistd.close
libc.src.unistd.unlinkat
)
+
+add_libc_unittest(
+ getpid_test
+ SUITE
+ libc_unistd_unittests
+ SRCS
+ getpid_test.cpp
+ DEPENDS
+ libc.src.unistd.getpid
+)
+
+add_libc_unittest(
+ getppid_test
+ SUITE
+ libc_unistd_unittests
+ SRCS
+ getppid_test.cpp
+ DEPENDS
+ libc.src.unistd.getppid
+)
+
+add_libc_unittest(
+ getuid_test
+ SUITE
+ libc_unistd_unittests
+ SRCS
+ getuid_test.cpp
+ DEPENDS
+ libc.src.unistd.getuid
+)
+
+add_libc_unittest(
+ geteuid_test
+ SUITE
+ libc_unistd_unittests
+ SRCS
+ geteuid_test.cpp
+ DEPENDS
+ libc.src.unistd.geteuid
+)
diff --git a/libc/test/src/unistd/geteuid_test.cpp b/libc/test/src/unistd/geteuid_test.cpp
new file mode 100644
index 0000000000000..878a16cf90e9c
--- /dev/null
+++ b/libc/test/src/unistd/geteuid_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for geteuid ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/geteuid.h"
+#include "utils/UnitTest/Test.h"
+
+TEST(LlvmLibcGetEuidTest, SmokeTest) {
+ // geteuid always succeeds. So, we just call it as a smoke test.
+ __llvm_libc::geteuid();
+}
diff --git a/libc/test/src/unistd/getpid_test.cpp b/libc/test/src/unistd/getpid_test.cpp
new file mode 100644
index 0000000000000..15510bc0604de
--- /dev/null
+++ b/libc/test/src/unistd/getpid_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for getpid ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/getpid.h"
+#include "utils/UnitTest/Test.h"
+
+TEST(LlvmLibcGetPidTest, SmokeTest) {
+ // getpid always succeeds. So, we just call it as a smoke test.
+ __llvm_libc::getpid();
+}
diff --git a/libc/test/src/unistd/getppid_test.cpp b/libc/test/src/unistd/getppid_test.cpp
new file mode 100644
index 0000000000000..061c7ad4ebf18
--- /dev/null
+++ b/libc/test/src/unistd/getppid_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for getppid ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/getppid.h"
+#include "utils/UnitTest/Test.h"
+
+TEST(LlvmLibcGetPpidTest, SmokeTest) {
+ // getppid always succeeds. So, we just call it as a smoke test.
+ __llvm_libc::getppid();
+}
diff --git a/libc/test/src/unistd/getuid_test.cpp b/libc/test/src/unistd/getuid_test.cpp
new file mode 100644
index 0000000000000..3d43a42324668
--- /dev/null
+++ b/libc/test/src/unistd/getuid_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for getuid ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/getuid.h"
+#include "utils/UnitTest/Test.h"
+
+TEST(LlvmLibcGetUidTest, SmokeTest) {
+ // getuid always succeeds. So, we just call it as a smoke test.
+ __llvm_libc::getuid();
+}
More information about the libc-commits
mailing list