* [LTP] [PATCH 1/2] Add configure time check for getdents/getdents64 APIs
@ 2019-07-26 18:25 Khem Raj
2019-07-26 18:25 ` [LTP] [PATCH 2/2] check for RES_USE_INET6 during configure Khem Raj
2019-07-29 9:59 ` [LTP] [PATCH 1/2] Add configure time check for getdents/getdents64 APIs Petr Vorel
0 siblings, 2 replies; 4+ messages in thread
From: Khem Raj @ 2019-07-26 18:25 UTC (permalink / raw)
To: ltp
glibc 2.30 has added wrapper for getdents64 this will help in detecting
right condition to use fallback
Check for getdents API as well while here
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
configure.ac | 2 ++
testcases/kernel/syscalls/getdents/getdents.h | 8 ++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,8 @@ AC_CHECK_FUNCS([ \
fallocate \
fchownat \
fstatat \
+ getdents \
+ getdents64 \
kcmp \
mkdirat \
mknodat \
--- a/testcases/kernel/syscalls/getdents/getdents.h
+++ b/testcases/kernel/syscalls/getdents/getdents.h
@@ -23,7 +23,7 @@
#include <stdint.h>
#include "test.h"
#include "lapi/syscalls.h"
-
+#include "config.h"
/*
* See fs/compat.c struct compat_linux_dirent
*/
@@ -34,12 +34,17 @@ struct linux_dirent {
char d_name[];
};
+#if HAVE_GETDENTS
+#include <unistd.h>
+#else
static inline int
getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int size)
{
return ltp_syscall(__NR_getdents, fd, dirp, size);
}
+#endif /* HAVE_GETDENTS */
+
struct linux_dirent64 {
uint64_t d_ino;
int64_t d_off;
@@ -48,10 +53,13 @@ struct linux_dirent64 {
char d_name[];
};
+#if HAVE_GETDENTS64
+#include <unistd.h>
+#else
static inline int
getdents64(unsigned int fd, struct linux_dirent64 *dirp64, unsigned int size)
{
return ltp_syscall(__NR_getdents64, fd, dirp64, size);
}
-
+#endif /* HAVE_GETDENTS64 */
#endif /* GETDENTS_H */
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH 2/2] check for RES_USE_INET6 during configure
2019-07-26 18:25 [LTP] [PATCH 1/2] Add configure time check for getdents/getdents64 APIs Khem Raj
@ 2019-07-26 18:25 ` Khem Raj
2019-07-29 11:32 ` Petr Vorel
2019-07-29 9:59 ` [LTP] [PATCH 1/2] Add configure time check for getdents/getdents64 APIs Petr Vorel
1 sibling, 1 reply; 4+ messages in thread
From: Khem Raj @ 2019-07-26 18:25 UTC (permalink / raw)
To: ltp
glibc 2.30 has remove RES_USE_INET6 define which has been on its way out
since 2.26 release, this check ensures that we detect it before using it
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
configure.ac | 13 +++++++++++++
testcases/network/multicast/mc_gethost/mc_gethost.c | 6 ++++++
2 files changed, 19 insertions(+)
diff --git a/configure.ac b/configure.ac
index 2255b5c181..ed7acccb01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,19 @@ AC_CHECK_FUNCS([ \
vmsplice \
])
+#check defines
+AC_MSG_CHECKING([for RES_USE_INET6])
+AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <resolv.h>]],
+ [[char dummy[RES_USE_INET6];]])],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED([HAVE_RES_USE_INET6], 1, [Define to 1 if you have the RES_USE_INET6 macro.])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ AC_DEFINE_UNQUOTED([HAVE_RES_USE_INET6], 0, [Define to 1 if you have the RES_USE_INET6 macro.])
+ ]
+)
# Tools knobs
# Expect
diff --git a/testcases/network/multicast/mc_gethost/mc_gethost.c b/testcases/network/multicast/mc_gethost/mc_gethost.c
index 9cc15d086b..d1cae5441a 100644
--- a/testcases/network/multicast/mc_gethost/mc_gethost.c
+++ b/testcases/network/multicast/mc_gethost/mc_gethost.c
@@ -17,6 +17,8 @@
#include <string.h>
#include <stdlib.h>
+#include "config.h"
+
#ifndef LOG_PERROR
#define LOG_PERROR 0
#endif
@@ -50,8 +52,12 @@ usage:
argv++, argc--;
}
if (argc >= 1 && !strcmp(*argv, "-6")) {
+#if HAVE_RES_USE_INET6
af = AF_INET6, size = IN6ADDRSZ;
_res.options |= RES_USE_INET6;
+#else
+ af = AF_INET, size = INADDRSZ;
+#endif
argv++, argc--;
}
if (argc >= 1 && !strcmp(*argv, "-f")) {
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH 1/2] Add configure time check for getdents/getdents64 APIs
2019-07-26 18:25 [LTP] [PATCH 1/2] Add configure time check for getdents/getdents64 APIs Khem Raj
2019-07-26 18:25 ` [LTP] [PATCH 2/2] check for RES_USE_INET6 during configure Khem Raj
@ 2019-07-29 9:59 ` Petr Vorel
1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2019-07-29 9:59 UTC (permalink / raw)
To: ltp
Hi Khem,
> glibc 2.30 has added wrapper for getdents64 this will help in detecting
> right condition to use fallback
> Check for getdents API as well while here
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Merged this patch, thanks!
Kind regards,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH 2/2] check for RES_USE_INET6 during configure
2019-07-26 18:25 ` [LTP] [PATCH 2/2] check for RES_USE_INET6 during configure Khem Raj
@ 2019-07-29 11:32 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2019-07-29 11:32 UTC (permalink / raw)
To: ltp
Hi Khem,
> glibc 2.30 has remove RES_USE_INET6 define which has been on its way out
> since 2.26 release, this check ensures that we detect it before using it
Thank you for your patch. Good point, but mc_gethost.c was actually unused,
so I removed it in 5a07ccea5.
There is no other RES_USE_INET6 use (otherwise I'd be for removing it)
therefore autotools checks aren't needed.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-29 11:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-26 18:25 [LTP] [PATCH 1/2] Add configure time check for getdents/getdents64 APIs Khem Raj
2019-07-26 18:25 ` [LTP] [PATCH 2/2] check for RES_USE_INET6 during configure Khem Raj
2019-07-29 11:32 ` Petr Vorel
2019-07-29 9:59 ` [LTP] [PATCH 1/2] Add configure time check for getdents/getdents64 APIs Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox