0

man 2 eventfd says:

SYNOPSIS

   #include <sys/eventfd.h>

   int eventfd(unsigned int initval, int flags);

but in /usr/include/sys/eventfd.h I see:

extern int eventfd (int __count, int __flags) __THROW;

I hit this because I needed to pass eventfd as a function pointer and I got a warning when it had the signature described in the manpage. Is this signature non-portable? Do I need to be aware of this in code I write?

Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
  • 2
    in the glibc tree you've linked to it's `unsigned int __count` – Ingo Leonhardt Mar 17 '16 at 17:57
  • Ask maintainers of glibc man page. Most likely, signature was changed but no one cared to update man page. You can even contribute and make a change yourself! – SergeyA Mar 17 '16 at 17:59
  • @IngoLeonhardt Whoops, you're right, I had a braindead moment there. Looking at the history shows they changed it in 2014, which is an answer to my portability question. I've self-answered with the info below, but please feel free to replace it with your own and I'll accept it. – Patrick Collins Mar 17 '16 at 18:06
  • The man page is part of the [https://www.kernel.org/doc/man-pages/](Linux man-pages) project. It's not maintained by the same people as glibc. The latest version of the `eventfd` man page in the Git repo still has the non-current declaration. – Keith Thompson Mar 17 '16 at 18:18

1 Answers1

1

The signature in glibc was changed in 2014 with this commit to the glibc tree:

diff --git a/sysdeps/unix/sysv/linux/hppa/sys/eventfd.h b/sysdeps/unix/sysv/linux/hppa/sys/eventfd.h
index 2d198a8..a3c340e 100644 (file)
--- a/sysdeps/unix/sysv/linux/hppa/sys/eventfd.h
+++ b/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);

I suppose in terms of portability, then, if you have an old version of glibc, the best you can do is cast your pointer to eventfd to int (*f)(unsigned int, int).

Patrick Collins
  • 10,306
  • 5
  • 30
  • 69