Skip to content

Commit

Permalink
Add inet_net_pton() to compat layer (for musl libc) (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-scheck authored Nov 28, 2022
1 parent 2c4dd37 commit 7e92d0c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compat/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ if !HAVE_FREEZERO
libcompat_la_SOURCES += freezero.c
endif

if !HAVE_INET_NET_PTON
libcompat_la_SOURCES += inet_net_pton.c
endif

if !HAVE_PIPE2
libcompat_la_SOURCES += pipe2.c
endif
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ fi
AC_SEARCH_LIBS([ibuf_open], [util])
AC_CHECK_FUNCS([ibuf_open])

# check functions that are expected to be in libresolv
AC_SEARCH_LIBS([inet_net_pton],[resolv])
AC_CHECK_FUNCS([inet_net_pton])

# check functions that may be in different libs on other systems
AC_SEARCH_LIBS([fts_open],[fts])
AC_CHECK_FUNCS([fts_open])
Expand All @@ -255,6 +259,7 @@ AM_CONDITIONAL([HAVE_UNVEIL], [test "x$ac_cv_func_unveil" = xyes])
AM_CONDITIONAL([HAVE_GETDTABLECOUNT], [test "x$ac_cv_func_getdtablecount" = xyes])
AM_CONDITIONAL([HAVE_PIPE2], [test "x$ac_cv_func_pipe2" = xyes])
AM_CONDITIONAL([HAVE_PPOLL], [test "x$ac_cv_func_ppoll" = xyes])
AM_CONDITIONAL([HAVE_INET_NET_PTON], [test "x$ac_cv_func_inet_net_pton" = xyes])
AM_CONDITIONAL([HAVE_STRNVIS], [test "x$ac_cv_func_strnvis" = xyes])
AM_CONDITIONAL([BROKEN_STRNVIS], [test "x$ac_cv_broken_strnvis" = xyes])
AM_CONDITIONAL([HAVE_IMSG], [test "x$ac_cv_func_ibuf_open" = xyes])
Expand Down
1 change: 1 addition & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
noinst_HEADERS =
noinst_HEADERS += arpa/inet.h
noinst_HEADERS += sys/_null.h
noinst_HEADERS += sys/queue.h
noinst_HEADERS += sys/socket.h
Expand Down
15 changes: 15 additions & 0 deletions include/arpa/inet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Public domain
* arpa/inet.h compatibility shim
*/

#include_next <arpa/inet.h>

#ifndef LIBCOMPAT_ARPA_INET_H
#define LIBCOMPAT_ARPA_INET_H

#ifndef HAVE_INET_NET_PTON
int inet_net_pton(int, const char *, void *, size_t);
#endif

#endif
1 change: 1 addition & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ for i in reallocarray.c recallocarray.c strtonum.c; do
done
${CP_LIBC} "${libc_src}/hash/sha2.c" compat
${CP_LIBC} "${libc_src}/gen/vis.c" compat
${CP_LIBC} "${libc_src}/net/inet_net_pton.c" compat
${CP} "${libutil_src}/imsg.c" compat/
${CP} "${libutil_src}/imsg-buffer.c" compat/
(cd compat; ${PATCH} -p0 < "${patches}/patch-imsg.c")
Expand Down

0 comments on commit 7e92d0c

Please sign in to comment.