c - 为什么 glibc 不同意 eventfd 联机帮助页?

标签 c linux system-calls manpage

man 2 eventfd 说:

SYNOPSIS

   #include <sys/eventfd.h>

   int eventfd(unsigned int initval, int flags);

但在 /usr/include/sys/eventfd.h 我看到:

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

我点击它是因为我需要将 eventfd 作为函数指针传递,当它具有联机帮助页中描述的签名时我收到了警告。这个签名是不可移植的吗?我需要在我编写的代码中意识到这一点吗?

最佳答案

glibc 中的签名在 2014 年更改为 this commit到 glibc 树:

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);

我想就可移植性而言,如果你有旧版本的 glibc,你能做的最好的事情就是将指向 eventfd 的指针转换为 int (*f)(unsigned int, int).

关于c - 为什么 glibc 不同意 eventfd 联机帮助页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36068070/

相关文章:

c - ANSI C 不允许在固定时间段后在同一位置打印每个字符吗?

python - 如何将 C 结构传递给 Python 以获取数据?

linux - 查找目录是否是 perforce 中的最新目录

c - 在 C 中调用系统调用函数的问题

C - 参数名称省略?找不到错误

c - 如何将多个 .c 文件编译为一个可执行文件

linux - 如何查找特定软件何时安装在服务器上?

linux - `wait()` 和 `exit()` 这两种用法哪个更好?

c - 如何识别 linux 系统调用 unshare(CLONE_NEWNET) 中的性能瓶颈

linux-kernel - 在 Linux Kernel 中从 entry_32.S 调用 C 函数