Garrett, thank you for input.
> Why not default with whatever's the newest standard, then fallback to
> the deprecated version?
I think my patch works as you wrote.
My patch tries sys/signalfd.h then linux/signalfd.h.
So I can say my patch tries "whatever's the newest standard"(glibc header file)
then "deprecated version"(no glibc header but kernel header file).
> FWIW, not all systems have signalfd.h at:
>
> /usr/include/linux/
>
> not should you look for that header there if cross-compilation is
> being performed.
It is important point. Thank you.
CROSS_CFLAGS should be considered when checking the existance of header file.
I update the last patch. It does
1. If sys/signalfd.h is not available, use syscall to invoke signalfd.
2. CFLAGS is considered when checking the existance of signalfd.h.
3. Checking the existance of signalfd.h in addition to checking
sys/signalfd.h and linux/signalfd.h.
Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]>
diff --git a/testcases/kernel/syscalls/signalfd/Makefile
b/testcases/kernel/syscalls/signalfd/Makefile
index be34bb1..93517da 100644
--- a/testcases/kernel/syscalls/signalfd/Makefile
+++ b/testcases/kernel/syscalls/signalfd/Makefile
@@ -20,7 +20,10 @@ include ../utils/cond.mk
CFLAGS += -I../../../../include \
- $(call check_header,sys/signalfd.h, -DHAS_SIGNALFD_H, ) -Wall
+ $(call check_header,sys/signalfd.h, -DHAS_SYS_SIGNALFD_H
-DHAS_SIGNALFD, ) \
+ $(call check_header,linux/signalfd.h, -DHAS_LINUX_SIGNALFD_H
-DHAS_SIGNALFD, ) \
+ $(call check_header,signalfd.h, -DHAS_SIGNALFD_H -DHAS_SIGNALFD, )
\
+ -Wall
LDLIBS += -L../../../../lib -lltp
SRCS = $(wildcard *.c)
diff --git a/testcases/kernel/syscalls/signalfd/signalfd01.c
b/testcases/kernel/syscalls/signalfd/signalfd01.c
index da3b258..15d69df 100644
--- a/testcases/kernel/syscalls/signalfd/signalfd01.c
+++ b/testcases/kernel/syscalls/signalfd/signalfd01.c
@@ -50,9 +50,36 @@ TCID_DEFINE(signalfd01);
int TST_TOTAL = 1;
extern int Tst_count;
-# ifdef HAS_SIGNALFD_H
+#ifdef HAS_SIGNALFD
+
+#ifdef HAS_SYS_SIGNALFD_H
+
#include <sys/signalfd.h>
+#elif HAS_LINUX_SIGNALFD_H || HAS_SIGNALFD_H
+
+#include <linux/types.h>
+
+#ifdef HAS_LINUX_SIGNALFD_H
+#include <linux/signalfd.h>
+#else
+#include <signalfd.h>
+#endif /* HAS_LINUX_SIGNALFD_H */
+
+#include "linux_syscall_numbers.h"
+#ifndef __NR_signalfd
+#define __NR_signalfd 0
+#endif
+
+int
+signalfd(int fd, const sigset_t *mask, int flags)
+{
+ /* Taken from GLIBC. */
+ return (syscall(__NR_signalfd, fd, mask, _NSIG / 8));
+}
+
+#endif /* HAS_SYS_SIGNALFD_H */
+
void cleanup(void);
void setup(void);
@@ -315,7 +342,7 @@ cleanup(void)
}
-#else /* !HAS_SIGNALFD_H */
+#else /* !HAS_SIGNALFD */
int
main(int argc, char** argv)
@@ -326,4 +353,4 @@ main(int argc, char** argv)
}
-#endif /* !HAS_SIGNALFD_H */
+#endif /* !HAS_SIGNALFD */
diff --git a/testcases/kernel/syscalls/utils/cond.mk
b/testcases/kernel/syscalls/utils/cond.mk
index 2656c0a..372f81f 100644
--- a/testcases/kernel/syscalls/utils/cond.mk
+++ b/testcases/kernel/syscalls/utils/cond.mk
@@ -65,12 +65,21 @@
# CFLAGS += $(call check_header,foo.h,-DHAS_FOO_H, )
# CFLAGS += $(call check_header,foo.h,-DHAS_FOO_H,)
#
+
+# If check_header refers CFLAGS directly, expression like
+#
+# CFLAGS += $(call check_header ...)
+#
+# causes "Recursive variable `CFLAGS' references itself" error.
+# COND_CFLAGS is introduced to avoid the error.
+COND_CFLAGS := $(CFLAGS)
check_header = $(shell
\
if [ "x$(2)" = "x" ]; then FOUND=yes; else FOUND="$(2)"; fi;
\
if [ "x$(3)" = "x" ]; then NOTFOUND=no; else NOTFOUND="$(3)"; fi;
\
- if echo "\#include <$(1)>" | $(CC) -E - > /dev/null 2>&1 ;
\
+ if echo "\#include <$(1)>" | $(CPP) $(COND_CFLAGS) - > /dev/null 2>&1 ;
\
then echo "$${FOUND}" ;
\
- else echo "$${NOTFOUND}" ; fi)
+# TODO: CPPFLAGS should be used here.
+
#COND_MK_DEBUG=yes
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list