diff --git a/acinclude.m4 b/acinclude.m4 index 709fb287..c10437d2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -75,6 +75,22 @@ AC_DEFUN([ACX_CHECK_CXX_STDLIB], [ fi ])dnl ACX_CHECK_CXX_STDLIB +AC_DEFUN([ACX_CHECK_GETPWUID_R], [ + AC_MSG_CHECKING([for working getpwuid_r]) + AC_TRY_LINK([#include ], + [char buffer[4096]; struct passwd pwd, *pwdp; + getpwuid_r(0, &pwd, buffer, sizeof(buffer), &pwdp);], + acx_getpwuid_r_ok=yes, acx_getpwuid_r_ok=no) + AC_MSG_RESULT($acx_getpwuid_r_ok) + if test x"$acx_getpwuid_r_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_GETPWUID_R,1,[Define if you have a working \`getpwuid_r\' function.]),[$1]) + : + else + acx_getpwuid_r_ok=no + $2 + fi +])dnl ACX_CHECK_GETPWUID_R + AC_DEFUN([ACX_CHECK_POLL], [ AC_MSG_CHECKING([for poll]) AC_TRY_LINK([#include ], diff --git a/configure.in b/configure.in index 75ec64de..9d6b7b93 100644 --- a/configure.in +++ b/configure.in @@ -46,14 +46,17 @@ AC_CHECK_HEADERS([windows.h]) AC_HEADER_TIME AC_PATH_X AC_PATH_XTRA +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$X_CFLAGS $CPPFLAGS" AC_CHECK_HEADERS([X11/extensions/XTest.h]) +CPPFLAGS="$save_CPPFLAGS" dnl checks for types AC_TYPE_SIZE_T dnl checks for structures AC_STRUCT_TM -AC_CHECK_TYPES(mbstate_t,,,[#include ]) +AC_CHECK_TYPES(mbstate_t,,,[#include ]) dnl checks for compiler characteristics AC_CHECK_SIZEOF(char, 1) @@ -72,7 +75,7 @@ AC_FUNC_FORK AC_FUNC_MEMCMP AC_FUNC_STRFTIME AC_CHECK_FUNCS(gmtime_r) -AC_CHECK_FUNCS(getpwuid_r) +ACX_CHECK_GETPWUID_R AC_CHECK_FUNCS(vsnprintf) AC_CHECK_FUNCS(wcrtomb mbrtowc mbsinit) AC_FUNC_SELECT_ARGTYPES diff --git a/lib/io/CUnicode.h b/lib/io/CUnicode.h index 43ee5470..19816b17 100644 --- a/lib/io/CUnicode.h +++ b/lib/io/CUnicode.h @@ -17,7 +17,7 @@ #include "CString.h" #include "BasicTypes.h" -#include +#include //! Unicode utility functions /*! diff --git a/lib/net/CNetwork.h b/lib/net/CNetwork.h index 30401ff2..eacff229 100644 --- a/lib/net/CNetwork.h +++ b/lib/net/CNetwork.h @@ -19,6 +19,13 @@ #include "CString.h" #include "stdvector.h" +// Darwin is so unsure what to use for socklen_t it makes us choose +#if defined(__APPLE__) +# if !defined(_BSD_SOCKLEN_T_) +# define _BSD_SOCKLEN_T_ int +# endif +#endif + #if HAVE_SYS_TYPES_H # include #endif diff --git a/lib/platform/CUnixPlatform.cpp b/lib/platform/CUnixPlatform.cpp index f0e447eb..feed3318 100644 --- a/lib/platform/CUnixPlatform.cpp +++ b/lib/platform/CUnixPlatform.cpp @@ -141,7 +141,11 @@ CUnixPlatform::getUserDirectory() const #if HAVE_GETPWUID_R struct passwd pwent; struct passwd* pwentp; +#if defined(_SC_GETPW_R_SIZE_MAX) long size = sysconf(_SC_GETPW_R_SIZE_MAX); +#else + long size = BUFSIZ; +#endif char* buffer = new char[size]; getpwuid_r(getuid(), &pwent, buffer, size, &pwentp); delete[] buffer;