* Various portability fixes
@ 2013-10-03 9:36 Michael Forney
2013-10-03 9:36 ` [PATCH 1/4] Use _POSIX_VERSION to determine support for %m Michael Forney
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Michael Forney @ 2013-10-03 9:36 UTC (permalink / raw)
To: util-linux
Hi,
These patches address various portability issues. They are needed to build
util-linux against musl libc.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] Use _POSIX_VERSION to determine support for %m
2013-10-03 9:36 Various portability fixes Michael Forney
@ 2013-10-03 9:36 ` Michael Forney
2013-10-03 9:39 ` [PATCH 2/4] Add missing includes Michael Forney
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michael Forney @ 2013-10-03 9:36 UTC (permalink / raw)
To: util-linux
%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(-)
diff --git a/configure.ac b/configure.ac
index cbcda46..95ff8b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
])],
--
1.8.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] Add missing includes
2013-10-03 9:36 Various portability fixes Michael Forney
2013-10-03 9:36 ` [PATCH 1/4] Use _POSIX_VERSION to determine support for %m Michael Forney
@ 2013-10-03 9:39 ` Michael Forney
2013-10-03 9:39 ` [PATCH 3/4] Check for type sighandler_t and use if present Michael Forney
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michael Forney @ 2013-10-03 9:39 UTC (permalink / raw)
To: util-linux
sys/types.h: For u_char typedef
sys/params.h: For MAXNAMLEN
sys/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(+)
diff --git a/configure.ac b/configure.ac
index 95ff8b3..12d0bab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 \
diff --git a/include/ttyutils.h b/include/ttyutils.h
index 13495ba..4f2fd88 100644
--- a/include/ttyutils.h
+++ b/include/ttyutils.h
@@ -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 */
diff --git a/term-utils/ttymsg.c b/term-utils/ttymsg.c
index d610826..8bf993c 100644
--- a/term-utils/ttymsg.c
+++ b/term-utils/ttymsg.c
@@ -41,6 +41,7 @@
*/
#include <sys/types.h>
+#include <sys/param.h>
#include <sys/uio.h>
#include <signal.h>
#include <fcntl.h>
diff --git a/text-utils/display.c b/text-utils/display.c
index 1f9a11b..1130366 100644
--- a/text-utils/display.c
+++ b/text-utils/display.c
@@ -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>
--
1.8.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] Check for type sighandler_t and use if present
2013-10-03 9:36 Various portability fixes Michael Forney
2013-10-03 9:36 ` [PATCH 1/4] Use _POSIX_VERSION to determine support for %m Michael Forney
2013-10-03 9:39 ` [PATCH 2/4] Add missing includes Michael Forney
@ 2013-10-03 9:39 ` Michael Forney
2013-10-03 9:39 ` [PATCH 4/4] Fix check for __GNU_LIBRARY__ Michael Forney
2013-10-04 10:30 ` Various portability fixes Karel Zak
4 siblings, 0 replies; 6+ messages in thread
From: Michael Forney @ 2013-10-03 9:39 UTC (permalink / raw)
To: util-linux
__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(-)
diff --git a/configure.ac b/configure.ac
index 12d0bab..93572fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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>
]])
diff --git a/fdisks/cfdisk.c b/fdisks/cfdisk.c
index 5007fc9..bb32433 100644
--- a/fdisks/cfdisk.c
+++ b/fdisks/cfdisk.c
@@ -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;
--
1.8.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] Fix check for __GNU_LIBRARY__
2013-10-03 9:36 Various portability fixes Michael Forney
` (2 preceding siblings ...)
2013-10-03 9:39 ` [PATCH 3/4] Check for type sighandler_t and use if present Michael Forney
@ 2013-10-03 9:39 ` Michael Forney
2013-10-04 10:30 ` Various portability fixes Karel Zak
4 siblings, 0 replies; 6+ messages in thread
From: Michael Forney @ 2013-10-03 9:39 UTC (permalink / raw)
To: util-linux
If 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(-)
diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index d41e335..f179ea8 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -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
--
1.8.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: Various portability fixes
2013-10-03 9:36 Various portability fixes Michael Forney
` (3 preceding siblings ...)
2013-10-03 9:39 ` [PATCH 4/4] Fix check for __GNU_LIBRARY__ Michael Forney
@ 2013-10-04 10:30 ` Karel Zak
4 siblings, 0 replies; 6+ messages in thread
From: Karel Zak @ 2013-10-04 10:30 UTC (permalink / raw)
To: Michael Forney; +Cc: util-linux
On Thu, Oct 03, 2013 at 02:36:04AM -0700, Michael Forney wrote:
> 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
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-10-04 10:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-03 9:36 Various portability fixes Michael Forney
2013-10-03 9:36 ` [PATCH 1/4] Use _POSIX_VERSION to determine support for %m Michael Forney
2013-10-03 9:39 ` [PATCH 2/4] Add missing includes Michael Forney
2013-10-03 9:39 ` [PATCH 3/4] Check for type sighandler_t and use if present Michael Forney
2013-10-03 9:39 ` [PATCH 4/4] Fix check for __GNU_LIBRARY__ Michael Forney
2013-10-04 10:30 ` Various portability fixes Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox