[libc-commits] [libc] [libc] implement mlock/mlock2/munlock/mlockall/munlockall (PR #79645)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Tue Jan 30 08:29:49 PST 2024


================
@@ -49,6 +51,28 @@ struct PageHolder {
   bool is_valid() { return addr != MAP_FAILED; }
 };
 
+static bool get_capacity(unsigned int cap) {
+  struct __user_cap_header_struct header;
+  header.pid = 0;
+  header.version = _LINUX_CAPABILITY_VERSION_3;
+  struct __user_cap_data_struct data[_LINUX_CAPABILITY_U32S_3];
+  long res = LIBC_NAMESPACE::syscall_impl(
+      SYS_capget, LIBC_NAMESPACE::cpp::bit_cast<long>(&header),
+      LIBC_NAMESPACE::cpp::bit_cast<long>(&data));
+  if (res < 0)
+    return false;
+  auto idx = CAP_TO_INDEX(cap);
+  auto shift = CAP_TO_MASK(cap);
----------------
nickdesaulniers wrote:

Please don't use `auto` here.

https://github.com/llvm/llvm-project/pull/79645


More information about the libc-commits mailing list