1dnl Check for a working inet_ntoa. 2dnl $Id: inet-ntoa.m4 10246 2018-02-16 21:12:42Z iulius $ 3dnl 4dnl Check whether inet_ntoa is present and working. Since calling inet_ntoa 5dnl involves passing small structs on the stack, present and working versions 6dnl may still not function with gcc on some platforms (such as IRIX). 7dnl Provides INN_FUNC_INET_NTOA and defines HAVE_INET_NTOA if inet_ntoa is 8dnl present and working. 9dnl 10dnl The canonical version of this file is maintained in the rra-c-util 11dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>. 12dnl 13dnl Copyright 1999-2001, 2003 Russ Allbery <eagle@eyrie.org> 14dnl Copyright 2008-2009 15dnl The Board of Trustees of the Leland Stanford Junior University 16dnl 17dnl This file is free software; the authors give unlimited permission to copy 18dnl and/or distribute it, with or without modifications, as long as this 19dnl notice is preserved. 20dnl 21dnl SPDX-License-Identifier: FSFULLR 22 23dnl Source used by INN_FUNC_INET_NTOA. 24AC_DEFUN([_INN_FUNC_INET_NTOA_SOURCE], [[ 25#include <sys/types.h> 26#include <sys/socket.h> 27#include <netinet/in.h> 28#include <arpa/inet.h> 29#include <string.h> 30 31int 32main(void) 33{ 34 struct in_addr in; 35 in.s_addr = htonl(0x7f000000L); 36 return (strcmp(inet_ntoa(in), "127.0.0.0") == 0) ? 0 : 1; 37} 38]]) 39 40dnl The public macro. 41AC_DEFUN([INN_FUNC_INET_NTOA], 42[AC_CACHE_CHECK(for working inet_ntoa, inn_cv_func_inet_ntoa_works, 43 [AC_RUN_IFELSE([AC_LANG_SOURCE([_INN_FUNC_INET_NTOA_SOURCE])], 44 [inn_cv_func_inet_ntoa_works=yes], 45 [inn_cv_func_inet_ntoa_works=no], 46 [inn_cv_func_inet_ntoa_works=no])]) 47 AS_IF([test x"$inn_cv_func_inet_ntoa_works" = xyes], 48 [AC_DEFINE([HAVE_INET_NTOA], 1, 49 [Define if your system has a working inet_ntoa function.])], 50 [AC_LIBOBJ([inet_ntoa])])]) 51