[libc-commits] [libc] [libc] implement `inet_aton` (PR #162651)
Connector Switch via libc-commits
libc-commits at lists.llvm.org
Fri Oct 10 07:35:05 PDT 2025
================
@@ -0,0 +1,68 @@
+//===-- Implementation of inet_aton function ------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/arpa/inet/inet_aton.h"
+#include "src/__support/common.h"
+#include "src/__support/endian_internal.h"
+#include "src/__support/str_to_integer.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, inet_aton, (const char *cp, in_addr *inp)) {
+ unsigned long parts[4] = {0};
+ int dot_num = 0;
+
+ for (; dot_num < 4; ++dot_num) {
+ auto result = internal::strtointeger<unsigned long>(cp, 0);
----------------
c8ef wrote:
Test case for binary integers added in https://github.com/llvm/llvm-project/pull/162651/commits/c86be34864e733c19e9a3e55a2d042c57a24d985.
https://github.com/llvm/llvm-project/pull/162651
More information about the libc-commits
mailing list