Various portability fixes
Hi,
These patches address various portability issues. They are needed to build util-linux against musl libc.
PATCH 1/4 Use _POSIX_VERSION to determine support for %m
%m is included in POSIX 2008, so we can check if the libc implements that before failing.
--- configure.ac | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
configure.ac +7 -1
@@ -430,6 +430,7 @@ AC_CACHE_VAL([scanf_cv_alloc_modifier], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include <stdio.h> + #include <unistd.h> #ifdef __GLIBC__
@@ -437,8 +438,13 @@ AC_CACHE_VAL([scanf_cv_alloc_modifier], #error %m is not available #endif - #else + #elif defined(_POSIX_VERSION) + #if _POSIX_VERSION < 200809L + #error %m is not available + #endif + + #else #error Your C-library is not supported. #endif ])],
Signature · 1 line
1.8.4
PATCH 2/4 Add missing includes
In reply to Michael Forneysys/types.h: For u_char typedefsys/params.h: For MAXNAMLENsys/ttydefaults.h: For various tty definitions (also add configure check)
--- configure.ac | 1 + include/ttyutils.h | 3 +++ term-utils/ttymsg.c | 1 + text-utils/display.c | 1 + 4 files changed, 6 insertions(+)
configure.ac +1 -0
@@ -204,6 +204,7 @@ AC_CHECK_HEADERS([ \ sys/swap.h \ sys/syscall.h \ sys/time.h \ + sys/ttydefaults.h \ sys/types.h \ sys/un.h \ unistd.h \
include/ttyutils.h +3 -0
@@ -13,6 +13,9 @@#ifdef HAVE_SYS_IOCTL_H #include <sys/ioctl.h> #endif +#ifdef HAVE_SYS_TTYDEFAULTS_H +#include <sys/ttydefaults.h> +#endif /* Some shorthands for control characters. */ #define CTL (x) ((x) ^ 0100)/* Assumes ASCII dialect */
term-utils/ttymsg.c +1 -0
@@ -41,6 +41,7 @@*/ #include <sys/types.h> +#include <sys/param.h> #include <sys/uio.h> #include <signal.h> #include <fcntl.h>
text-utils/display.c +1 -0
@@ -33,6 +33,7 @@#include <sys/param.h> #include <sys/stat.h> +#include <sys/types.h> #include <unistd.h> #include <errno.h> #include <ctype.h>
Signature · 1 line
1.8.4
PATCH 3/4 Check for type sighandler_t and use if present
In reply to Michael Forney__sighandler_t is libc implementation specific and should not be relied upon. Instead, we fall back upon void (*)(int), as specified by POSIX.
--- configure.ac | 4 ++++ fdisks/cfdisk.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-)
configure.ac +4 -0
@@ -497,6 +497,10 @@ AC_CHECK_TYPES([cpu_set_t], [have_cpu_set_t=yes], [], [[ AM_CONDITIONAL([HAVE_CPU_SET_T], [test "x$have_cpu_set_t" = xyes]) +AC_CHECK_TYPES([sighandler_t], [], [], [[ +#include <signal.h> +]]) + AC_CHECK_DECLS([CPU_ALLOC], [], [], [[ #include <sched.h> ]])
fdisks/cfdisk.c +5 -1
@@ -324,7 +324,11 @@ int num_parts = 0;int logical =0 ;long long logical_sectors[MAXIMUM_PARTS ]; -__sighandler_t old_SIGINT, old_SIGTERM; +#ifdef HAVE_SIGHANDLER_T +sighandler_t old_SIGINT, old_SIGTERM; +#else +void (* old_SIGINT)(int ), (* old_SIGTERM)(int ); +#endif int arrow_cursor = FALSE;int display_units =MEGABYTES ;
Signature · 1 line
1.8.4
PATCH 4/4 Fix check for __GNU_LIBRARY__
In reply to Michael ForneyIf we are not on glibc, __GNU_LIBRARY__ will not exist causing the check to always fail and try to use syscalls directly.
--- term-utils/setterm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
term-utils/setterm.c +1 -1
@@ -124,7 +124,7 @@#include "nls.h" #include "closestream.h" -#if __GNU_LIBRARY__ <5 +#if defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ <5 #ifndef __alpha__# include <linux/unistd.h> #define __NR_klogctl __NR_syslog
Signature · 1 line
1.8.4
Quoted 2 lines · Michael Forney
These patches address various portability issues. They are needed to build util-linux against musl libc.
Applied, thanks! (Please, use "Signed-off-by:" next time.)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com