Fix prototype for eventfd

Message ID 8761lraz3r.fsf@rasmusvillemoes.dk
State Superseded
Headers

Commit Message

Rasmus Villemoes April 30, 2014, 10:30 a.m. UTC
  Both the man-page and the actual kernel source says that the first
argument to eventfd is unsigned int, not simply int.

Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
---
 ports/sysdeps/unix/sysv/linux/hppa/sys/eventfd.h | 2 +-
 sysdeps/unix/sysv/linux/eventfd.c                | 2 +-
 sysdeps/unix/sysv/linux/sys/eventfd.h            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Rasmus Villemoes May 8, 2014, 1:07 p.m. UTC | #1
Rasmus Villemoes <rv@rasmusvillemoes.dk> writes:

> Both the man-page and the actual kernel source says that the first
> argument to eventfd is unsigned int, not simply int.
>

ping
  
Ondrej Bilka May 13, 2014, 8 p.m. UTC | #2
On Thu, May 08, 2014 at 03:07:39PM +0200, Rasmus Villemoes wrote:
> Rasmus Villemoes <rv@rasmusvillemoes.dk> writes:
> 
> > Both the man-page and the actual kernel source says that the first
> > argument to eventfd is unsigned int, not simply int.
> >
> 
> ping

looks good, I am bit concerned with compatibility, Joseph could you also
comment it?
  
Joseph Myers May 13, 2014, 8:33 p.m. UTC | #3
On Tue, 13 May 2014, Ondrej Bilka wrote:

> On Thu, May 08, 2014 at 03:07:39PM +0200, Rasmus Villemoes wrote:
> > Rasmus Villemoes <rv@rasmusvillemoes.dk> writes:
> > 
> > > Both the man-page and the actual kernel source says that the first
> > > argument to eventfd is unsigned int, not simply int.
> > >
> > 
> > ping
> 
> looks good, I am bit concerned with compatibility, Joseph could you also
> comment it?

Compatibility would be an issue if:

* the C ABI on some architecture defines int to be sign-extended to 64 
bits when passed as a function parameter, but unsigned int to be 
zero-extended;

* the code generated for eventfd relied on this in some way; and

* a user binary passes a negative value for the int argument.

I don't expect that to be an issue (in that I don't expect any dependence 
beyond the value passed to the function being passed on to the kernel 
unchanged) but haven't looked at generated code.
  
Mike Frysinger Aug. 2, 2014, 2:34 p.m. UTC | #4
On Wed 30 Apr 2014 12:30:32 Rasmus Villemoes wrote:
> Both the man-page and the actual kernel source says that the first
> argument to eventfd is unsigned int, not simply int.

i guess this is still waiting to be merged ?
-mike
  
Rasmus Villemoes Aug. 3, 2014, 12:19 p.m. UTC | #5
Mike Frysinger <vapier@gentoo.org> writes:

> On Wed 30 Apr 2014 12:30:32 Rasmus Villemoes wrote:
>> Both the man-page and the actual kernel source says that the first
>> argument to eventfd is unsigned int, not simply int.
>
> i guess this is still waiting to be merged ?

It seems that way, yes.

Rasmus
  
Mike Frysinger Aug. 3, 2014, 1:41 p.m. UTC | #6
On Sun 03 Aug 2014 14:19:08 Rasmus Villemoes wrote:
> Mike Frysinger <vapier@gentoo.org> writes:
> > On Wed 30 Apr 2014 12:30:32 Rasmus Villemoes wrote:
> >> Both the man-page and the actual kernel source says that the first
> >> argument to eventfd is unsigned int, not simply int.
> > 
> > i guess this is still waiting to be merged ?
> 
> It seems that way, yes.

let's check with Allan if we can merge before 2.20.  otherwise it'll have to 
wait for 2.21.

i think it's fine (and preferred) we merge for 2.20 since it's a user-visible 
API fix.  and it's low risk.
-mike
  
Ondrej Bilka Sept. 20, 2014, 12:07 p.m. UTC | #7
On Sun, Aug 03, 2014 at 09:41:51AM -0400, Mike Frysinger wrote:
> On Sun 03 Aug 2014 14:19:08 Rasmus Villemoes wrote:
> > Mike Frysinger <vapier@gentoo.org> writes:
> > > On Wed 30 Apr 2014 12:30:32 Rasmus Villemoes wrote:
> > >> Both the man-page and the actual kernel source says that the first
> > >> argument to eventfd is unsigned int, not simply int.
> > > 
> > > i guess this is still waiting to be merged ?
> > 
> > It seems that way, yes.
> 
> let's check with Allan if we can merge before 2.20.  otherwise it'll have to 
> wait for 2.21.
> 
> i think it's fine (and preferred) we merge for 2.20 since it's a user-visible 
> API fix.  and it's low risk.
> -mike

I pushed this synced with sysdeps files movement.
  

Patch

diff --git a/ports/sysdeps/unix/sysv/linux/hppa/sys/eventfd.h b/ports/sysdeps/unix/sysv/linux/hppa/sys/eventfd.h
index 2d198a8..a3c340e 100644
--- a/ports/sysdeps/unix/sysv/linux/hppa/sys/eventfd.h
+++ b/ports/sysdeps/unix/sysv/linux/hppa/sys/eventfd.h
@@ -40,7 +40,7 @@  __BEGIN_DECLS
 
 /* Return file descriptor for generic event channel.  Set initial
    value to COUNT.  */
-extern int eventfd (int __count, int __flags) __THROW;
+extern int eventfd (unsigned int __count, int __flags) __THROW;
 
 /* Read event counter and possibly wait for events.  */
 extern int eventfd_read (int __fd, eventfd_t *__value);
diff --git a/sysdeps/unix/sysv/linux/eventfd.c b/sysdeps/unix/sysv/linux/eventfd.c
index 425c811..83da67f 100644
--- a/sysdeps/unix/sysv/linux/eventfd.c
+++ b/sysdeps/unix/sysv/linux/eventfd.c
@@ -22,7 +22,7 @@ 
 
 
 int
-eventfd (int count, int flags)
+eventfd (unsigned int count, int flags)
 {
 #ifdef __NR_eventfd2
   int res = INLINE_SYSCALL (eventfd2, 2, count, flags);
diff --git a/sysdeps/unix/sysv/linux/sys/eventfd.h b/sysdeps/unix/sysv/linux/sys/eventfd.h
index 7f977ed..0806891 100644
--- a/sysdeps/unix/sysv/linux/sys/eventfd.h
+++ b/sysdeps/unix/sysv/linux/sys/eventfd.h
@@ -31,7 +31,7 @@  __BEGIN_DECLS
 
 /* Return file descriptor for generic event channel.  Set initial
    value to COUNT.  */
-extern int eventfd (int __count, int __flags) __THROW;
+extern int eventfd (unsigned int __count, int __flags) __THROW;
 
 /* Read event counter and possibly wait for events.  */
 extern int eventfd_read (int __fd, eventfd_t *__value);