From 0019c12af37c6631152a5b6e2517086ac34a76a0 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Wed, 7 Dec 2016 16:21:08 -0800 Subject: [PATCH] changes to allow building on Solaris 10 Fixes #3456 --- configure.ac | 1 + src/fallback.cpp | 15 +++++++++++++-- src/fallback.h | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index a8bf7b29c..0c60704a6 100644 --- a/configure.ac +++ b/configure.ac @@ -323,6 +323,7 @@ AC_CHECK_FUNCS( wcslcpy lrand48_r killpg ) AC_CHECK_FUNCS( backtrace_symbols getifaddrs ) AC_CHECK_FUNCS( futimens clock_gettime ) AC_CHECK_FUNCS( getpwent flock ) +AC_CHECK_FUNCS( dirfd ) AC_CHECK_DECL( [mkostemp], [ AC_CHECK_FUNCS([mkostemp]) ] ) diff --git a/src/fallback.cpp b/src/fallback.cpp index e1ed88477..d7803a0dc 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -91,7 +91,6 @@ char *tparm_solaris_kludge(char *str, ...) { #endif -#if __APPLE__ /// Fallback implementations of wcsdup and wcscasecmp. On systems where these are not needed (e.g. /// building on Linux) these should end up just being stripped, as they are static functions that /// are not referenced in this file. @@ -105,7 +104,6 @@ __attribute__((unused)) static wchar_t *wcsdup_fallback(const wchar_t *in) { memcpy(out, in, sizeof(wchar_t) * (len + 1)); return out; } -#endif __attribute__((unused)) static int wcscasecmp_fallback(const wchar_t *a, const wchar_t *b) { if (*a == 0) { @@ -160,6 +158,19 @@ int wcsncasecmp(const wchar_t *a, const wchar_t *b, size_t n) { #endif // __DARWIN_C_LEVEL >= 200809L #endif // __APPLE__ +/// These functions are missing from Solaris 10 +#ifndef HAVE_WCSDUP +wchar_t *wcsdup(const wchar_t *in) { return wcsdup_fallback(in); } +#endif +#ifndef HAVE_WCSCASECMP +int wcscasecmp(const wchar_t *a, const wchar_t *b) { return wcscasecmp_fallback(a, b); } +#endif +#ifndef HAVE_WCSNCASECMP +int wcsncasecmp(const wchar_t *a, const wchar_t *b, size_t n) { + return wcsncasecmp_fallback(a, b, n); +} +#endif + #ifndef HAVE_WCSNDUP wchar_t *wcsndup(const wchar_t *in, size_t c) { wchar_t *res = (wchar_t *)malloc(sizeof(wchar_t) * (c + 1)); diff --git a/src/fallback.h b/src/fallback.h index 946b4e3a0..a986b16ad 100644 --- a/src/fallback.h +++ b/src/fallback.h @@ -77,6 +77,24 @@ wchar_t *wcsndup(const wchar_t *in, size_t c); #endif #endif //__APPLE__ +/// These functions are missing from Solaris 10 +#ifndef HAVE_WCSDUP +wchar_t *wcsdup(const wchar_t *in); +#endif +#ifndef HAVE_WCSCASECMP +int wcscasecmp(const wchar_t *a, const wchar_t *b); +#endif +#ifndef HAVE_WCSNCASECMP +int wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n); +#endif +#ifndef HAVE_DIRFD +#ifndef __XOPEN_OR_POSIX +#define dirfd(d) (d->dd_fd) +#else +#define dirfd(d) (d->d_fd) +#endif +#endif + #ifndef HAVE_WCSNDUP /// Fallback for wcsndup function. Returns a copy of \c in, truncated to a maximum length of \c c. wchar_t *wcsndup(const wchar_t *in, size_t c);