CAI Qian, Mike Frysinger, and Vijay Kumar,
thanks you for the reviewing.

After submitting the last patch, I found a surprise; 
io_set_eventfd is defined in aio.h, not in libaio.
So I've rewritten ltp-eventfd.m4.

CAI Qian wrote:
---------------
> Looks like I have problem to apply this patch on top of the current
> CVS version.

Sorry. I fixed it in new patch.

> In addition, I have seen you remove the previous checking of kernel
> version. Since I can't apply the patch, I need to ask. what happens
> when the kernel does not support this system call? Does it still give
> us a TCONF if the system call is unavailable?
I guess ENOSYS is set to errno.
Anyway, about version check I withdrew my change; and revert to the original 
code
 in the 
new patch.

Mike Frysinger:
--------------
> > +AC_CHECK_HEADERS(sys/eventfd.h)
> > +
> > +AC_CHECK_HEADERS(libaio.h)
> 
> AC_CHECK_HEADERS_ONCE() is preferred

After rewritten AC_CHECK_HEADERS is really needed. So
I'm still using AC_CHECK_HEADERS in the new patch.

> > +AC_CHECK_LIB(aio,io_setup)
> > +for x in $LIBS; do
> > +    if test "$x" = -laio; then
> > +      AIO_LIBS="$AIO_LIBS -laio"
> > +    fi
> > +done
> > +AC_SUBST(AIO_LIBS)
> 
> this is pretty hackish.  just do:
> AC_CHECK_LIB(aio, io_setup, AIO_LIBS="-laio", AIO_LIBS="")
> AC_SUBST(AIO_LIBS)

Thanks. I've reflected your advice to the new patch.

Vijay Kumar wrote:
------------------
> > Before my change ltp own eventfd wrapper calls eventfd
> > system call like this:
> > static int
> >  myeventfd(unsigned int initval, int flags)
> >  {
> >     return syscall(__NR_eventfd, initval);
> >  }
> > As you can see, FLAGS argument is not used. I guess this is a bug. So I 
> > changed like:
> > static int
> >  myeventfd(unsigned int initval, int flags)
> >  {
> >     return syscall(__NR_eventfd, initval, flags);
> >  }
> 
> The eventfd() syscall does not have a flags argument. But there is another 
> syscall recently introduced in the kernel(> 2.6.27) called eventfd2() which 
> has the flags argument. From the eventfd() man page 
> http://www.kernel.org/doc/man-pages/online/pages/man2/eventfd.2.html
> 
> <quote>
> There are two underlying Linux system calls: eventfd() and the more recent
> eventfd2(). The former system call does not implement a flags argument. The
> latter system call implements the flags values described above. The glibc
> wrapper function will use eventfd2() where it is available.
> </quote>
> 
> You can also check the code
> http://lxr.linux.no/linux+v2.6.27.10/fs/eventfd.c#L201

Thanks. I withdrew my change; and revert to the original code in the 
new patch.


Could you retry new patch?

diff --git a/config.mk.in b/config.mk.in
new file mode 100644
index 0000000..22bad68
--- /dev/null
+++ b/config.mk.in
@@ -0,0 +1 @@
+AIO_LIBS = @AIO_LIBS@
diff --git a/configure.ac b/configure.ac
index e137d5b..b5f0d30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,7 @@
 AC_PREREQ([2.61])
 AC_INIT([ltp], [cvs], [ltp-resu...@lists.sourceforge.net])
 AC_CONFIG_HEADERS([include/config.h])
+AC_CONFIG_FILES([config.mk])
 
 
 m4_include([m4/ltp-signalfd.m4])
@@ -9,6 +10,11 @@ LTP_CHECK_SYSCALL_SIGNALFD
 m4_include([m4/ltp-modify_ldt.m4])
 LTP_CHECK_SYSCALL_MODIFY_LDT
 
+m4_include([m4/ltp-eventfd.m4])
+LTP_CHECK_SYSCALL_EVENTFD
+
+AC_CHECK_HEADERS([sys/inotify.h])
+
 AC_CHECK_HEADERS([ifaddrs.h])
 
 AC_OUTPUT
diff --git a/m4/ltp-eventfd.m4 b/m4/ltp-eventfd.m4
new file mode 100644
index 0000000..12a0321
--- /dev/null
+++ b/m4/ltp-eventfd.m4
@@ -0,0 +1,44 @@
+dnl
+dnl Copyright (c) Red Hat Inc., 2008
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+dnl Author: Masatake YAMATO <yam...@redhat.com>
+dnl
+
+dnl
+dnl LTP_CHECK_SYSCALL_EVENTFD
+dnl ----------------------------
+dnl
+AC_DEFUN([LTP_CHECK_SYSCALL_EVENTFD],
+[dnl
+AH_TEMPLATE(HAVE_IO_SET_EVENTFD, 
+[Define to 1 if you have the `io_set_eventfd' function.])
+AC_CHECK_HEADERS(libaio.h,[
+       AC_CHECK_LIB(aio,io_setup,[
+               LIBS="$LIBS -laio"
+               AIO_LIBS="-laio"
+               AC_MSG_CHECKING([io_set_eventfd is defined in aio library or 
aio header])
+               AC_TRY_LINK([#include <stdio.h>
+                             #include <libaio.h>
+                           ],
+                            [int main() { io_set_eventfd(NULL, 0); return 0; }
+                           ],
+                           [AC_DEFINE(HAVE_IO_SET_EVENTFD)
+                            AC_MSG_RESULT(yes)],
+                            [AC_MSG_RESULT(no)])],
+               AIO_LIBS="")])
+AC_SUBST(AIO_LIBS)
+])
diff --git a/testcases/kernel/syscalls/eventfd/Makefile 
b/testcases/kernel/syscalls/eventfd/Makefile
index fc31597..6073b6b 100644
--- a/testcases/kernel/syscalls/eventfd/Makefile
+++ b/testcases/kernel/syscalls/eventfd/Makefile
@@ -16,42 +16,17 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-include ../utils/cond.mk
+
+include ../../../../config.mk
 
 
 CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
-
-check_aio_eventfd = $(shell \
-       if printf \
-       "\#include <libaio.h>\n\
-       int main() \
-       { \
-       io_set_eventfd(NULL, 0); \
-       return 0; \
-       }" | $(CC) -xc -laio - > /dev/null 2>&1 ; \
-       then echo yes ; \
-       else echo no ; fi)
-
-HAS_LIBAIO = $(call check_header,libaio.h)
-HAS_LIBAIO_EVENTFD = $(call check_aio_eventfd)
-
-ifeq ($(HAS_LIBAIO_EVENTFD),yes)
-CFLAGS += -DHAS_AIO_EVENTFD
-LDLIBS += -laio
-endif
+LDLIBS += -L../../../../lib $(AIO_LIBS) -lltp
 
 SRCS    = $(wildcard *.c)
 TARGETS = $(patsubst %.c, %, $(wildcard *.c))
 
 all: $(TARGETS)
-ifeq ($(HAS_LIBAIO),no)
-       @echo "Note: Libaio is required for eventfd overflow testing.";
-else
-ifeq ($(HAS_LIBAIO_EVENTFD),no)
-       @echo "Note: Eventfd support is required in libaio for overflow 
testing.";
-endif
-endif
 
 install:
        @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
diff --git a/testcases/kernel/syscalls/eventfd/eventfd01.c 
b/testcases/kernel/syscalls/eventfd/eventfd01.c
index 4cf0bc4..2eac57d 100644
--- a/testcases/kernel/syscalls/eventfd/eventfd01.c
+++ b/testcases/kernel/syscalls/eventfd/eventfd01.c
@@ -44,6 +44,8 @@
  *     None
  */
 
+#include "config.h"
+
 #include <sys/select.h>
 #include <sys/signal.h>
 #include <sys/types.h>
@@ -59,21 +61,27 @@
 #include <usctest.h>
 #include <linux_syscall_numbers.h>
 
-#ifdef HAS_AIO_EVENTFD
+#ifdef HAVE_LIBAIO_H
 #include <libaio.h>
 #endif
 
 static void setup(void);
 static void cleanup(void);
 
-char *TCID = "eventfd01";
+TCID_DEFINE(eventfd01);
 int TST_TOTAL = 15;
 extern int Tst_count;
 
 static int
 myeventfd(unsigned int initval, int flags)
 {
-       return syscall(__NR_eventfd, initval);
+  /* eventfd2 uses FLAGS but eventfd doesn't take FLAGS. */
+#if defined (__NR_eventfd)
+    return syscall(__NR_eventfd, initval);
+#else
+    errno = ENOSYS;
+    return -1;
+#endif
 }
 
 /*
@@ -512,7 +520,7 @@ child_inherit_test(int fd)
        }
 }
 
-#ifdef HAS_AIO_EVENTFD
+#ifdef HAVE_IO_SET_EVENTFD
 /*
  * Test whether counter overflow is detected and handled correctly. 
  *

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to