Re: [PATCH 04/13] qemu-kvm: Remove eventfd compat header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 03.07.2011 11:57, schrieb Michael S. Tsirkin:
On Sun, Jul 03, 2011 at 12:54:06PM +0300, Michael S. Tsirkin wrote:
On Sun, Jul 03, 2011 at 11:46:51AM +0200, Bernhard Held wrote:
#ifndef _COMPAT_SYS_EVENTFD
#define _COMPAT_SYS_EVENTFD

#include<unistd.h>
#include<syscall.h>

/* Flags for signalfd.  */
enum
   {
	EFD_SEMAPHORE = 1,
#define EFD_SEMAPHORE EFD_SEMAPHORE
	EFD_CLOEXEC = 02000000,
#define EFD_CLOEXEC EFD_CLOEXEC
	EFD_NONBLOCK = 04000
#define EFD_NONBLOCK EFD_NONBLOCK
};

#ifndef __NR_eventfd2
#if defined(__x86_64__)
#define __NR_eventfd2 290
#elif defined(__i386__)
#define __NR_eventfd2 328
#else
#error Cannot detect your architecture!
#endif
#endif

Can't we use SYS_eventfd2 instead?

Looks like we can't, but __NR_eventfd2
does seem to exit?
SYS_eventfd2 is not defined on systems with old glibc. These numbers are working for me, for 32 and 64 bit linux. What means "__NR_eventfd2 does seem to exit"?

The eventfd() man page nicely documents the evolution:
http://www.kernel.org/doc/man-pages/online/pages/man2/eventfd.2.html
"eventfd() is available on Linux since kernel 2.6.22. Working support is provided in glibc since version 2.8. The eventfd2() system call (see NOTES) is available on Linux since kernel 2.6.27. Since version 2.9, the glibc eventfd() wrapper will employ the eventfd2() system call, if it is supported by the kernel."

"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."

This means that the current compat header is buggy; qemu-kvm sets the flags argument, but the wrapper uses the old eventfd() system call.

Bernhard

static inline int eventfd (int count, int flags)
{
	return syscall(__NR_eventfd2, count, flags);
}

#endif


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux