All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] syscalls/ustat: Fix build for libc without ustat() support
@ 2017-10-10 15:26 Petr Vorel
  2017-10-11 12:52 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Vorel @ 2017-10-10 15:26 UTC (permalink / raw)
  To: ltp

This applies at least for uClibc/uClibc-ng with disabled __UCLIBC_SV4_DEPRECATED__.

Patch taken from buildroot project (thanks!), adjusted it not to be
only uClibc/uClibc-ng specific.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Reported-by: Erico Nunes <nunes.erico@gmail.com>
---
Another Buildroot patch, this one is hopefully correct.
---
 configure.ac                              |  6 +++++-
 testcases/kernel/syscalls/ustat/ustat01.c | 14 ++++++++++++--
 testcases/kernel/syscalls/ustat/ustat02.c | 10 +++++++++-
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 465655e7b..17a02050a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,9 +44,13 @@ AC_CHECK_HEADERS([ \
     sys/inotify.h \
     sys/fanotify.h \
     sys/prctl.h \
+    sys/ustat.h \
 ])
 
-AC_CHECK_FUNCS([profil])
+AC_CHECK_FUNCS([ \
+    profil \
+    ustat \
+])
 
 # Tools knobs
 
diff --git a/testcases/kernel/syscalls/ustat/ustat01.c b/testcases/kernel/syscalls/ustat/ustat01.c
index 494647bc2..74a880577 100644
--- a/testcases/kernel/syscalls/ustat/ustat01.c
+++ b/testcases/kernel/syscalls/ustat/ustat01.c
@@ -21,15 +21,19 @@
 
 #include <unistd.h>
 #include <errno.h>
-#include <sys/ustat.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "test.h"
 #include "safe_macros.h"
+#include "config.h"
+
+char *TCID = "ustat01";
+
+#if defined(HAVE_SYS_USTAT_H) && defined(HAVE_USTAT)
+#include <sys/ustat.h>
 
 static void setup(void);
 
-char *TCID = "ustat01";
 int TST_TOTAL = 1;
 
 static dev_t dev_num;
@@ -79,3 +83,9 @@ static void setup(void)
 
 	dev_num = buf.st_dev;
 }
+#else /* systems without ustat() */
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "system doesn't have ustat() support");
+}
+#endif
diff --git a/testcases/kernel/syscalls/ustat/ustat02.c b/testcases/kernel/syscalls/ustat/ustat02.c
index edada3107..cb2f0b828 100644
--- a/testcases/kernel/syscalls/ustat/ustat02.c
+++ b/testcases/kernel/syscalls/ustat/ustat02.c
@@ -22,12 +22,14 @@
 
 #include <unistd.h>
 #include <errno.h>
-#include <sys/ustat.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include "test.h"
 #include "safe_macros.h"
 
+#if defined(HAVE_SYS_USTAT_H) && defined(HAVE_USTAT)
+#include <sys/ustat.h>
+
 static void setup(void);
 
 char *TCID = "ustat02";
@@ -101,3 +103,9 @@ static void setup(void)
 
 	root_dev = buf.st_dev;
 }
+#else /* systems without ustat() */
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "system doesn't have ustat() support");
+}
+#endif
-- 
2.14.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH 1/1] syscalls/ustat: Fix build for libc without ustat() support
  2017-10-10 15:26 [LTP] [PATCH 1/1] syscalls/ustat: Fix build for libc without ustat() support Petr Vorel
@ 2017-10-11 12:52 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2017-10-11 12:52 UTC (permalink / raw)
  To: ltp

Hi!
> +#else /* systems without ustat() */
              ^
	      I think that we can avoid this comment, the TCONF message
	      below is clear enough...

> +#if defined(HAVE_SYS_USTAT_H) && defined(HAVE_USTAT)
> +#include <sys/ustat.h>

Logically following is bit cleaner, not that it matters that much:

#ifdef HAVE_USTAT
# ifdef HAVE_SYS_USTAT_H
#  include <sys/ustat.h>
# endif
...



-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-11 12:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-10 15:26 [LTP] [PATCH 1/1] syscalls/ustat: Fix build for libc without ustat() support Petr Vorel
2017-10-11 12:52 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.