[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:48 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);
+ return (data[idx].effective & shift) != 0;
+}
+
+static bool is_permitted_size(size_t size) {
+ struct rlimit rlimits;
----------------
nickdesaulniers wrote:
remove `struct`
https://github.com/llvm/llvm-project/pull/79645
More information about the libc-commits
mailing list