[libc-commits] [libc] [libc] Internal getrandom implementation (PR #144427)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Jun 17 09:39:34 PDT 2025


================
@@ -0,0 +1,35 @@
+//===------------ Implementation of getrandom function ----------*- 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___SUPPORT_OSUTIL_GETRANDOM_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_GETRANDOM_H
+
+#include "hdr/types/ssize_t.h"
+#include "src/__support/OSUtil/linux/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers
+
+namespace LIBC_NAMESPACE_DECL {
+namespace internal {
+
+static inline ErrorOr<ssize_t> getrandom(void *buf, size_t buflen,
----------------
michaelrj-google wrote:


```suggestion
LIBC_INLINE static ErrorOr<ssize_t> getrandom(void *buf, size_t buflen,
```

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


More information about the libc-commits mailing list