在哪里可以找到Linux版本系统/队列。h头文件?

时间:2022-07-17 06:26:27

sys/queue.h first appeared in 4.4BSD. Linux has included it in its distribution, but the version seems not up-to-date.

sys /队列。h第一次出现在4bsd。Linux已经将它包含在它的发行版中,但是这个版本似乎不是最新的。

FreeBSD version implements singly-linked lists, singly-linked tail queues, lists and tail queues. Linux version implements lists, tail queues, and circular queues.

FreeBSD版本实现了单链接列表、单链接尾队列、列表和尾队列。Linux版本实现了列表、尾队列和循环队列。

I installed libbsd-dev package in my Ubuntu PC and then found BSD version's sys/queue.h in /usr/include/bsd/sys/queue.h.

我在我的Ubuntu PC上安装了libbsd-dev包,然后找到了BSD版本的sys/queue。h /usr/include/bsd/sys/queue.h.

My questions:

我的问题:

  • Where can I find the Linux version of this header file?

    我在哪里可以找到这个头文件的Linux版本?

  • What's the main difference between these two implementations? Is Linux version just a out-dated version of BSD's ?

    这两种实现的主要区别是什么?Linux版本仅仅是BSD的过时版本吗?

2 个解决方案

#1


1  

They share the same ancestry, but it looks like any development that have been done in them diverged a long time ago.

他们有着相同的祖先,但看起来在他们身上所做的任何发展在很久以前都是不同的。

If you want to use it in your project your best bet is to just copy the one you like the most into your project and use that. Don't depend on the system providing it for you. It's just a header file with a bunch of macros and doesn't need a library or any dependencies to work and as such isn't operating system specific at all. I usually take the one from OpenBSD for my projects.

如果你想在你的项目中使用它,最好的办法就是把你最喜欢的一个复制到你的项目中并使用它。不要依赖于为你提供的系统。它只是一个带有大量宏的头文件,不需要一个库或任何依赖项来工作,因为这样根本就不需要操作系统。我通常从OpenBSD中获取一个项目。

#2


0  

Looks like Linux's version is seriously outdated. CIRCLEQ is (rather strongly) deprecated in BSDs since 2001, and it even got removed from the documentation, even if the implementation is still in queue.h. We are supposed to use TAILQ, which offers the same functionality with better performance/less problems/saner implementation.

看起来Linux的版本已经过时了。CIRCLEQ自2001年以来(相当强烈地)在BSDs中被弃用,甚至从文档中删除,即使实现仍然在queue.h中。我们应该使用TAILQ,它提供相同的功能,具有更好的性能/更少的问题/更安全的实现。

Meanwhile, in Linux it's still even documented, but you can find changes in kconfig migrating from CIRCLEQ to TAILQ citing the BSD deprecation.

与此同时,在Linux中,它甚至还被记录在案,但是您可以发现kconfig从CIRCLEQ迁移到TAILQ,并引用了BSD弃用。

The concrete problem in CIRCLEQ seems to be that it uses a specific head, different to a list node, but which is anyway linked as a node; so the head pointer has to be kept around and checked at every node access to see if the node turns out to be the head. So there are 2 problems: the checks at every access, and the need to keep the head pointer at hand, taking registers or cache.

CIRCLEQ的具体问题似乎是它使用了一个特定的head,不同于列表节点,但是它是作为一个节点链接的;因此,头指针必须保持在周围,并在每个节点访问时检查,以确定节点是否为头。因此,有两个问题:每个访问的检查,以及保持头部指针在手边,接收寄存器或缓存的需要。

#1


1  

They share the same ancestry, but it looks like any development that have been done in them diverged a long time ago.

他们有着相同的祖先,但看起来在他们身上所做的任何发展在很久以前都是不同的。

If you want to use it in your project your best bet is to just copy the one you like the most into your project and use that. Don't depend on the system providing it for you. It's just a header file with a bunch of macros and doesn't need a library or any dependencies to work and as such isn't operating system specific at all. I usually take the one from OpenBSD for my projects.

如果你想在你的项目中使用它,最好的办法就是把你最喜欢的一个复制到你的项目中并使用它。不要依赖于为你提供的系统。它只是一个带有大量宏的头文件,不需要一个库或任何依赖项来工作,因为这样根本就不需要操作系统。我通常从OpenBSD中获取一个项目。

#2


0  

Looks like Linux's version is seriously outdated. CIRCLEQ is (rather strongly) deprecated in BSDs since 2001, and it even got removed from the documentation, even if the implementation is still in queue.h. We are supposed to use TAILQ, which offers the same functionality with better performance/less problems/saner implementation.

看起来Linux的版本已经过时了。CIRCLEQ自2001年以来(相当强烈地)在BSDs中被弃用,甚至从文档中删除,即使实现仍然在queue.h中。我们应该使用TAILQ,它提供相同的功能,具有更好的性能/更少的问题/更安全的实现。

Meanwhile, in Linux it's still even documented, but you can find changes in kconfig migrating from CIRCLEQ to TAILQ citing the BSD deprecation.

与此同时,在Linux中,它甚至还被记录在案,但是您可以发现kconfig从CIRCLEQ迁移到TAILQ,并引用了BSD弃用。

The concrete problem in CIRCLEQ seems to be that it uses a specific head, different to a list node, but which is anyway linked as a node; so the head pointer has to be kept around and checked at every node access to see if the node turns out to be the head. So there are 2 problems: the checks at every access, and the need to keep the head pointer at hand, taking registers or cache.

CIRCLEQ的具体问题似乎是它使用了一个特定的head,不同于列表节点,但是它是作为一个节点链接的;因此,头指针必须保持在周围,并在每个节点访问时检查,以确定节点是否为头。因此,有两个问题:每个访问的检查,以及保持头部指针在手边,接收寄存器或缓存的需要。