[libc-commits] [libc] [libc] implement `inet_aton` (PR #162651)
    Michael Jones via libc-commits 
    libc-commits at lists.llvm.org
       
    Fri Oct 10 10:47:58 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);
----------------
michaelrj-google wrote:
ah, in that case I forgot we haven't added that yet. I'd say don't worry about testing that it doesn't work because it's not a problem if it does and we'll have to change it when binary support is added to strtointeger.
https://github.com/llvm/llvm-project/pull/162651
    
    
More information about the libc-commits
mailing list