Windows 上的 libeio

发布于 2024-09-14 16:50:17 字数 116 浏览 4 评论 0原文

libeio 移植到 Windows 需要什么?

What would it take to port libeio to windows?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

童话里做英雄 2024-09-21 16:50:17

大约一年后,您可能想要研究的内容(您或其他通过搜索或 Google 找到此内容的人)是 libuv ,以前称为 liboio。与公认的答案相反,Windows 并不是(或者当时)缺乏事件化 I/O 的概念,只是它在 Windows API 的神秘圈子之外并不为人所知。开发商。在 Windows 领域,类似的概念被实现为 I /O 完成端口,所以 libeio 版本/端口/fork/analog 并不需要重新实现轮子,它只需要有一个类似 libeio 的 API 来支持在下面使用 IOCP 的东西引擎盖。

Almost a year later, what you may want to look into (you, or anyone else finding this via search or Google) is libuv, formerly liboio. Contrary to the the accepted answer, it's not so much that Windows is, or at the time was, bereft of the concept of evented i/o, it just wasn't well-known outside of the arcane circle of deep-knowledge Windows API developers. In the Windows space, a similar concept is implemented as I/O Completion Ports, so it's not so much that a libeio version/port/fork/analog would need to reimplement the wheel, it'd just have to have a libeio-looking API to something that was using IOCP under the hood.

泪之魂 2024-09-21 16:50:17

Libeio 使用的是 Windows 世界中未知的 unix API 和 unix 概念。您拥有的解决方案是:

  • 在 Windows 上使用 unix 抽象层:例如 cygwin适用于 Unix 的 Windows 服务。但即使有了这些层,运行 libeio 代码也会遇到困难,因为有很多与系统相关的代码,如下所示:
# if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
#  define _DIRENT_HAVE_D_TYPE /* sigh */
#  define D_INO(de) (de)->d_fileno
#  define D_NAMLEN(de) (de)->d_namlen
# elif __linux || defined d_ino || _XOPEN_SOURCE >= 600
#  define D_INO(de) (de)->d_ino
# endif
  • 使用可移植的抽象库重写 libeio,例如 GTK+glib 事实上)、wxWidgetsQt。这些框架已经为低级例程、通信服务、I/O 通道和异步队列实现了强大的 API。这些框架的开发人员付出了很多努力来实现其代码的可移植性。您不必重新发明轮子。

当然,考虑到 libeio 唯一的 C 文件 eio.c 的大小相对较小,第二种解决方案是最好的解决方案。

Libeio is using unix APIs and unix concepts which are unknown on the Windows world. The solutions you have are :

  • use a unix abstraction layer on windows : like cygwin or Windows Services for Unix. But even with those layers, you'll have difficulties running libeio code as there are a lot of system-dependent code like this :
# if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
#  define _DIRENT_HAVE_D_TYPE /* sigh */
#  define D_INO(de) (de)->d_fileno
#  define D_NAMLEN(de) (de)->d_namlen
# elif __linux || defined d_ino || _XOPEN_SOURCE >= 600
#  define D_INO(de) (de)->d_ino
# endif
  • rewrite libeio with a portable abstraction library like GTK+ (glib in fact), wxWidgets or Qt. Thoses frameworks already implement powerful API for low level routines, communication services, i/o channels and asynchronous queues. Developers of those frameworks had made a lot of effort to allow portability of their code. You don't have to reinvent the wheel.

Definitely, the second solution is the best one, considering the relatively small size of eio.c, the only C file of libeio.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文