Skip to contentSkip to conversation

Add compat eventfd header

PATCH In review Michael S. Tsirkin 4 participants 6 messages Jun 30, 2011 – Jul 3, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add compat eventfd header

Support build on rhel 5.X where we have syscall for eventfd but not userspace wrapper.

(cherry-picked from commit 9e3269181e9bc56feb43bcd4e8ce0b82cd543e65
in qemu-kvm.git).

---

Changes from v1:
checkpatch fix
address comments by agraf
verify we are on linux

 compat/sys/eventfd.h |   20 ++++++++++++++++++++
 configure            |    6 ++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 compat/sys/eventfd.h
compat/sys/eventfd.h new file +20 -0
new file mode 100644
index 0000000..1801a5f
@@ -0,0 +1,20 @@
+#ifndef _COMPAT_SYS_EVENTFD
+#define _COMPAT_SYS_EVENTFD
+
+#ifdef CONFIG_EVENTFD
+
+#ifndef __linux__
+#error __linux__ is not defined: eventfd is only supported on linux
+#endif
+
+#include <unistd.h>
+#include <syscall.h>
+
+static inline int eventfd(int count, int flags)
+{
+    return syscall(SYS_eventfd, count, flags);
+}
+
+#endif
+
+#endif
configure +4 -2
index 856b41e..6f7dd74 100755
@@ -822,7 +822,6 @@ esac
 
 [ -z "$guest_base" ] && guest_base="$host_guest_base"
 
-
 default_target_list=""
 
 # these targets are portable
@@ -891,6 +890,9 @@ sparc64-bsd-user \
 "
 fi
 
+#compat headers
+QEMU_CFLAGS="$QEMU_CFLAGS -idirafter $source_path/compat"
+
 if test x"$show_help" = x"yes" ; then
 cat << EOF
 
@@ -2122,7 +2124,7 @@ int main(void)
     return 0;
 }
 EOF
-if compile_prog "" "" ; then
+if compile_prog "-DCONFIG_EVENTFD" "" ; then
   eventfd=yes
 fi
 
Signature · 1 line
1.7.5.53.gc233e
Acked-by on v2 1/1
#1 lore raw
Quoted 68 lines · Michael S. Tsirkin

Support build on rhel 5.X where we have syscall for eventfd but not userspace wrapper.

(cherry-picked from commit 9e3269181e9bc56feb43bcd4e8ce0b82cd543e65
in qemu-kvm.git).

---

Changes from v1:
checkpatch fix
address comments by agraf
verify we are on linux

  compat/sys/eventfd.h |   20 ++++++++++++++++++++
  configure            |    6 ++++--
  2 files changed, 24 insertions(+), 2 deletions(-)

create mode 100644 compat/sys/eventfd.h

compat/sys/eventfd.h new file +20 -0
new file mode 100644
index 0000000..1801a5f
@@ -0,0 +1,20 @@
+#ifndef _COMPAT_SYS_EVENTFD
+#define _COMPAT_SYS_EVENTFD
+
+#ifdef CONFIG_EVENTFD
+
+#ifndef __linux__
+#error __linux__ is not defined: eventfd is only supported on linux
+#endif
+
+#include<unistd.h>
+#include<syscall.h>
+
+static inline int eventfd(int count, int flags)
+{
+    return syscall(SYS_eventfd, count, flags);
+}
+
+#endif
+
+#endif
configure +3 -1
index 856b41e..6f7dd74 100755
@@ -822,7 +822,6 @@ esac
 
  [ -z "$guest_base" ]&&  guest_base="$host_guest_base"
 
-
  default_target_list=""
 
  # these targets are portable
@@ -891,6 +890,9 @@ sparc64-bsd-user \
  "
  fi
 
+#compat headers
+QEMU_CFLAGS="$QEMU_CFLAGS -idirafter $source_path/compat"
+
  if test x"$show_help" = x"yes" ; then
  cat<<  EOF
 

configure int main(void) · line 2130

Quoted 8 lines
configure +1 -1
@@ -2122,7 +2124,7 @@ int main(void)
      return 0;
  }
  EOF
-if compile_prog "" "" ; then
+if compile_prog "-DCONFIG_EVENTFD" "" ; then
    eventfd=yes
  fi
 

Paolo

#2 lore raw
In reply to Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
configure +0 -0
index 856b41e..6f7dd74 100755
@@ -822,7 +822,6 @@ esac
 

 [ -z "$guest_base" ] && guest_base="$host_guest_base"

Quoted 4 lines

-
 default_target_list=""

 # these targets are portable

This hunk looks like a stray unrelated whitespace change?

-- PMM

#3 lore raw
Quoted 9 lines · Peter Maydell
Quoted 8 lines · Michael S. Tsirkin
configure +0 -0
index 856b41e..6f7dd74 100755
@@ -822,7 +822,6 @@ esac
 

 [ -z "$guest_base" ] && guest_base="$host_guest_base"

Quoted 8 lines
Quoted 4 lines

-
 default_target_list=""

 # these targets are portable

This hunk looks like a stray unrelated whitespace change?

-- PMM

It's unrelated but I don't believe it's stray. Seems too trivial to split this to a separate patch.

Signature · 1 line
MST
#4 lore raw
In reply to Michael S. Tsirkin

compat/sys/eventfd.h

Quoted 24 lines · Michael S. Tsirkin

Support build on rhel 5.X where we have syscall for eventfd but not userspace wrapper.

(cherry-picked from commit 9e3269181e9bc56feb43bcd4e8ce0b82cd543e65 in qemu-kvm.git).

---

Changes from v1:
 checkpatch fix
 address comments by agraf
 verify we are on linux

 compat/sys/eventfd.h |   20 ++++++++++++++++++++
 configure            |    6 ++++--

 2 files changed, 24 insertions(+), 2 deletions(-)

 create mode 100644 compat/sys/eventfd.h

compat/sys/eventfd.h new file +0 -0
new file mode 100644
index 0000000..1801a5f

Since we have linux-headers directory now, the directory should be compat-headers. I'd also add 'linux' directory below that to avoid collisions, so the full path would be compat-headers/linux/sys/eventfd.h.

compat/sys/eventfd.h line 8

Quoted 9 lines
compat/sys/eventfd.h new file +8 -0
@@ -0,0 +1,20 @@
+#ifndef _COMPAT_SYS_EVENTFD
+#define _COMPAT_SYS_EVENTFD
+
+#ifdef CONFIG_EVENTFD
+
+#ifndef __linux__
+#error __linux__ is not defined: eventfd is only supported on linux
+#endif

With the linux directory, this check wouldn't be needed. It's not incorrect and we could add more specific checks later (for example if SYS_eventfd is not defined).

Quoted 28 lines
compat/sys/eventfd.h new file +12 -0
+
+#include <unistd.h>
+#include <syscall.h>
+
+static inline int eventfd(int count, int flags)
+{
+    return syscall(SYS_eventfd, count, flags);
+}
+
+#endif
+
+#endif
configure +0 -0
index 856b41e..6f7dd74 100755
@@ -822,7 +822,6 @@ esac
 

 [ -z "$guest_base" ] && guest_base="$host_guest_base"

-
 default_target_list=""

 # these targets are portable
configure +0 -0
@@ -891,6 +890,9 @@ sparc64-bsd-user \

 "
 fi

configure sparc64-bsd-user \ · line 894

Quoted 2 lines
configure +2 -0
+#compat headers
+QEMU_CFLAGS="$QEMU_CFLAGS -idirafter $source_path/compat"

Please use $source_path/compat-headers/$targetos/.

Quoted 16 lines

+
 if test x"$show_help" = x"yes" ; then
 cat << EOF

configure +0 -0
@@ -2122,7 +2124,7 @@ int main(void)
     return 0;
  }

 EOF

configure +1 -1
-if compile_prog "" "" ; then
+if compile_prog "-DCONFIG_EVENTFD" "" ; then

  eventfd=yes
 fi

--
1.7.5.53.gc233e

#5 lore raw
Quoted 20 lines · Blue Swirl
Quoted 19 lines · Michael S. Tsirkin

Support build on rhel 5.X where we have syscall for eventfd but not userspace wrapper.

(cherry-picked from commit 9e3269181e9bc56feb43bcd4e8ce0b82cd543e65 in qemu-kvm.git).

---

Changes from v1:
 checkpatch fix
 address comments by agraf
 verify we are on linux

 compat/sys/eventfd.h |   20 ++++++++++++++++++++
 configure            |    6 ++++--

 2 files changed, 24 insertions(+), 2 deletions(-)

 create mode 100644 compat/sys/eventfd.h

Quoted 11 lines

compat/sys/eventfd.h

Quoted 5 lines
compat/sys/eventfd.h new file +0 -0
new file mode 100644
index 0000000..1801a5f

Since we have linux-headers directory now, the directory should be compat-headers. I'd also add 'linux' directory below that to avoid collisions, so the full path would be compat-headers/linux/sys/eventfd.h.

I'll make it compat-headers/sys/eventfd.h.

Actually this header is useful for non-linux as well:
CONFIG_EVENTFD is not defined there which in theory makes it possible to include sys/eventfd.h without ifdefs.

Quoted 5 lines
Quoted 5 lines
compat/sys/eventfd.h new file +4 -0
@@ -0,0 +1,20 @@
+#ifndef _COMPAT_SYS_EVENTFD
+#define _COMPAT_SYS_EVENTFD
+
+#ifdef CONFIG_EVENTFD
Quoted 8 lines

compat/sys/eventfd.h line 8

Quoted 4 lines
compat/sys/eventfd.h new file +4 -0
+
+#ifndef __linux__
+#error __linux__ is not defined: eventfd is only supported on linux
+#endif

With the linux directory, this check wouldn't be needed. It's not incorrect and we could add more specific checks later (for example if SYS_eventfd is not defined).

Yes, it's not incorrect because it is nested within CONFIG_EVENTFD. If CONFIG_EVENTFD is set and SYS_eventfd is not defined then there's a bug in the configure script.

Quoted 28 lines
Quoted 28 lines
compat/sys/eventfd.h new file +12 -0
+
+#include <unistd.h>
+#include <syscall.h>
+
+static inline int eventfd(int count, int flags)
+{
+    return syscall(SYS_eventfd, count, flags);
+}
+
+#endif
+
+#endif
configure +0 -0
index 856b41e..6f7dd74 100755
@@ -822,7 +822,6 @@ esac
 

 [ -z "$guest_base" ] && guest_base="$host_guest_base"

-
 default_target_list=""

 # these targets are portable
configure +0 -0
@@ -891,6 +890,9 @@ sparc64-bsd-user \

 "
 fi

Quoted 4 lines

configure sparc64-bsd-user \ · line 894

Quoted 2 lines
configure +2 -0
+#compat headers
+QEMU_CFLAGS="$QEMU_CFLAGS -idirafter $source_path/compat"

Please use $source_path/compat-headers/$targetos/.

I think it's best to keep it simple. When we have many compat headers we will see how to split them best.
If most of the code turns out to be common we will want to avoid duplicating it.

Quoted 16 lines
Quoted 16 lines

+
 if test x"$show_help" = x"yes" ; then
 cat << EOF

configure +0 -0
@@ -2122,7 +2124,7 @@ int main(void)
     return 0;
  }

 EOF

configure +1 -1
-if compile_prog "" "" ; then
+if compile_prog "-DCONFIG_EVENTFD" "" ; then

  eventfd=yes
 fi

--
1.7.5.53.gc233e