24 lines · cpp
1//===-- Implementation of inet_addr function ------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/arpa/inet/inet_addr.h"10#include "include/llvm-libc-macros/netinet-in-macros.h"11#include "include/llvm-libc-types/in_addr.h"12#include "include/llvm-libc-types/in_addr_t.h"13#include "src/__support/common.h"14#include "src/arpa/inet/inet_aton.h"15 16namespace LIBC_NAMESPACE_DECL {17 18LLVM_LIBC_FUNCTION(in_addr_t, inet_addr, (const char *cp)) {19 in_addr addr;20 return inet_aton(cp, &addr) ? addr.s_addr : INADDR_NONE;21}22 23} // namespace LIBC_NAMESPACE_DECL24