[libc-commits] [libc] [libc] implement `inet_aton` (PR #162651)
Connector Switch via libc-commits
libc-commits at lists.llvm.org
Fri Oct 10 20:35:37 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:
> if it does and we'll have to change it when binary support is added to strtointeger.
Yes, so I think that's why we want to keep the binary integers test cases. That way, once binary support is added, we can immediately know if anything needs to be handled on the `inet_aton` side.
https://github.com/llvm/llvm-project/pull/162651
More information about the libc-commits
mailing list