From: Michael Jeanson Date: Thu, 17 Sep 2015 16:43:40 +0000 (-0400) Subject: Port: Add macro for socket linking on solaris X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=11a2fd460f033afa2d5f41a70eb1fd3a84fcf89d Port: Add macro for socket linking on solaris Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/config/ax_lib_socket_nsl.m4 b/config/ax_lib_socket_nsl.m4 new file mode 100644 index 000000000..058e97515 --- /dev/null +++ b/config/ax_lib_socket_nsl.m4 @@ -0,0 +1,40 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_lib_socket_nsl.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIB_SOCKET_NSL +# +# DESCRIPTION +# +# This macro figures out what libraries are required on this platform to +# link sockets programs. +# +# The common cases are not to need any extra libraries, or to need +# -lsocket and -lnsl. We need to avoid linking with libnsl unless we need +# it, though, since on some OSes where it isn't necessary it will totally +# break networking. Unisys also includes gethostbyname() in libsocket but +# needs libnsl for socket(). +# +# LICENSE +# +# Copyright (c) 2008 Russ Allbery +# Copyright (c) 2008 Stepan Kasal +# Copyright (c) 2008 Warren Young +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL]) +AC_DEFUN([AX_LIB_SOCKET_NSL], +[ + AC_SEARCH_LIBS([gethostbyname], [nsl]) + AC_SEARCH_LIBS([socket], [socket], [], [ + AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"], + [], [-lnsl])]) +]) diff --git a/configure.ac b/configure.ac index dda8f27ca..e80ccc8b4 100644 --- a/configure.ac +++ b/configure.ac @@ -362,6 +362,8 @@ else fi +AX_LIB_SOCKET_NSL + # Epoll check. If not present, the build will fallback on poll() API AX_HAVE_EPOLL( [AX_CONFIG_FEATURE_ENABLE(epoll)], diff --git a/src/common/compat/socket.h b/src/common/compat/socket.h index 6a490bebb..5a6802aac 100644 --- a/src/common/compat/socket.h +++ b/src/common/compat/socket.h @@ -74,8 +74,9 @@ typedef struct lttng_sock_cred lttng_sock_cred; #include -static int -getpeereid(int s, uid_t *euid, gid_t *gid) + +static inline +int getpeereid(int s, uid_t *euid, gid_t *gid) { int ret = 0; ucred_t *ucred = NULL;