[libc-commits] [libc] [libc] Implement getprotobyname_r (PR #243486)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Tue Nov 17 12:58:27 PST 2026
================
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Implementation of getprotobyname_r.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/netdb/getprotobyname_r.h"
+
+#include "hdr/errno_macros.h"
+#include "hdr/stdint_proxy.h"
+#include "hdr/types/size_t.h"
+#include "hdr/types/struct_protoent.h"
+#include "src/__support/CPP/optional.h"
+#include "src/__support/CPP/scope.h"
+#include "src/__support/CPP/span.h"
+#include "src/__support/CPP/string_view.h"
+#include "src/__support/File/file.h"
+#include "src/__support/common.h"
+#include "src/__support/ctype_utils.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/null_check.h"
+#include "src/__support/str_to_integer.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+static constexpr const char *DEFAULT_PROTOCOLS_PATH = "/etc/protocols";
+
+#ifndef LIBC_COPT_PUBLIC_PACKAGING
+static LIBC_THREAD_LOCAL const char *protocols_path = nullptr;
+
+void netdb::set_protocols_path(const char *path) { protocols_path = path; }
+#endif // LIBC_COPT_PUBLIC_PACKAGING
+
+namespace {
----------------
michaelrj-google wrote:
all of the support code would be the same for `getprotoent`, so it should go in a shared file. Maybe `getproto_internal.cpp`?
https://github.com/llvm/llvm-project/pull/243486
More information about the libc-commits
mailing list