[libc-commits] [libc] [libc] implement gethostid (PR #241866)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Tue Nov 17 20:50:43 PST 2026


================
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Linux implementation of gethostid.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/gethostid.h"
+
+#include "hdr/fcntl_macros.h"
+#include "hdr/stdint_proxy.h"
+#include "src/__support/OSUtil/linux/syscall_wrappers/close.h"
+#include "src/__support/OSUtil/linux/syscall_wrappers/open.h"
+#include "src/__support/OSUtil/linux/syscall_wrappers/read.h"
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(long, gethostid, (void)) {
+  auto fd = linux_syscalls::open("/etc/hostid", O_RDONLY | O_CLOEXEC, 0);
----------------
vonosmas wrote:

I'm a bit confused on why we'd need to add a function that doesn't at all does what the user (on Linux) expects it to do...

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


More information about the libc-commits mailing list