mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
Solaris build fixes: use _sys_errs if available
This commit is contained in:
parent
90629caa61
commit
147078f43d
3 changed files with 68 additions and 2 deletions
50
configure.ac
50
configure.ac
|
@ -694,6 +694,56 @@ else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for sys_errlist
|
||||||
|
AC_MSG_CHECKING([for sys_errlist array])
|
||||||
|
AC_TRY_LINK(
|
||||||
|
[
|
||||||
|
#include <stdio.h>
|
||||||
|
],
|
||||||
|
[
|
||||||
|
const char *p;
|
||||||
|
p = sys_errlist[sys_nerr];
|
||||||
|
],
|
||||||
|
have_sys_errlist=yes,
|
||||||
|
have_sys_errlist=no
|
||||||
|
)
|
||||||
|
if test "$have_sys_errlist" = yes; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(
|
||||||
|
[HAVE_SYS_ERRLIST],
|
||||||
|
[1],
|
||||||
|
[Define to 1 if the sys_errlist array is available.]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for _sys_errs
|
||||||
|
AC_MSG_CHECKING([for _sys_errs array])
|
||||||
|
AC_TRY_LINK(
|
||||||
|
[
|
||||||
|
#include <string>
|
||||||
|
],
|
||||||
|
[
|
||||||
|
std::string p;
|
||||||
|
extern const char _sys_errs[];
|
||||||
|
extern const int _sys_index[];
|
||||||
|
p = _sys_errs[_sys_index[0]];
|
||||||
|
],
|
||||||
|
have__sys__errs=yes,
|
||||||
|
have__sys__errs=no
|
||||||
|
)
|
||||||
|
if test "$have__sys__errs" = yes; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(
|
||||||
|
[HAVE__SYS__ERRS],
|
||||||
|
[1],
|
||||||
|
[Define to 1 if the _sys_errs array is available.]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if getopt_long exists and works
|
# Check if getopt_long exists and works
|
||||||
AC_MSG_CHECKING([if getopt_long exists and works])
|
AC_MSG_CHECKING([if getopt_long exists and works])
|
||||||
AC_TRY_LINK(
|
AC_TRY_LINK(
|
||||||
|
|
|
@ -114,6 +114,9 @@
|
||||||
*/
|
*/
|
||||||
/* #undef HAVE_SYS_DIR_H */
|
/* #undef HAVE_SYS_DIR_H */
|
||||||
|
|
||||||
|
/* Define to 1 if the sys_errlist array is available. */
|
||||||
|
#define HAVE_SYS_ERRLIST 1
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||||
#define HAVE_SYS_IOCTL_H 1
|
#define HAVE_SYS_IOCTL_H 1
|
||||||
|
|
||||||
|
@ -194,6 +197,9 @@
|
||||||
/* Define to 1 if you have the file `/proc/self/stat'. */
|
/* Define to 1 if you have the file `/proc/self/stat'. */
|
||||||
/* #undef HAVE__PROC_SELF_STAT */
|
/* #undef HAVE__PROC_SELF_STAT */
|
||||||
|
|
||||||
|
/* Define to 1 if the _sys_errs array is available. */
|
||||||
|
/* #undef HAVE__SYS__ERRS */
|
||||||
|
|
||||||
/* Define to 1 if the __environ symbol is exported. */
|
/* Define to 1 if the __environ symbol is exported. */
|
||||||
/* #undef HAVE___ENVIRON */
|
/* #undef HAVE___ENVIRON */
|
||||||
|
|
||||||
|
|
14
wutil.cpp
14
wutil.cpp
|
@ -323,12 +323,23 @@ const char *safe_strerror(int err)
|
||||||
// uClibc does not have sys_errlist, however, its strerror is believed to be async-safe
|
// uClibc does not have sys_errlist, however, its strerror is believed to be async-safe
|
||||||
// See #808
|
// See #808
|
||||||
return strerror(err);
|
return strerror(err);
|
||||||
#else
|
#elif defined(HAVE__SYS__ERRS) || defined(HAVE_SYS_ERRLIST)
|
||||||
|
#ifdef HAVE_SYS_ERRLIST
|
||||||
if (err >= 0 && err < sys_nerr && sys_errlist[err] != NULL)
|
if (err >= 0 && err < sys_nerr && sys_errlist[err] != NULL)
|
||||||
{
|
{
|
||||||
return sys_errlist[err];
|
return sys_errlist[err];
|
||||||
}
|
}
|
||||||
|
#elif defined(HAVE__SYS__ERRS)
|
||||||
|
extern const char _sys_errs[];
|
||||||
|
extern const int _sys_index[];
|
||||||
|
extern int _sys_num_err;
|
||||||
|
|
||||||
|
if (err >= 0 && err < _sys_num_err) {
|
||||||
|
return &_sys_errs[_sys_index[err]];
|
||||||
|
}
|
||||||
|
#endif // either HAVE__SYS__ERRS or HAVE_SYS_ERRLIST
|
||||||
else
|
else
|
||||||
|
#endif // defined(HAVE__SYS__ERRS) || defined(HAVE_SYS_ERRLIST)
|
||||||
{
|
{
|
||||||
int saved_err = errno;
|
int saved_err = errno;
|
||||||
|
|
||||||
|
@ -345,7 +356,6 @@ const char *safe_strerror(int err)
|
||||||
errno = saved_err;
|
errno = saved_err;
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void safe_perror(const char *message)
|
void safe_perror(const char *message)
|
||||||
|
|
Loading…
Reference in a new issue