]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/queue.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / lib / queue.h
index 04fbeee7004c98ab159eb714a9968dfd8eda94f1..26a5d4d7e6c14b381fc6062940176fe90bb63a08 100644 (file)
@@ -1,24 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * lists and queues implementations
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #ifndef _FRR_QUEUE_H
 #define _FRR_QUEUE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined(__OpenBSD__) && !defined(STAILQ_HEAD)
 #include "openbsd-queue.h"
 
 #include "freebsd-queue.h"
 #endif /* defined(__OpenBSD__) && !defined(STAILQ_HEAD) */
 
+#ifndef TAILQ_POP_FIRST
+#define TAILQ_POP_FIRST(head, field)                                           \
+       ({  typeof((head)->tqh_first) _elm = TAILQ_FIRST(head);                \
+           if (_elm) {                                                        \
+               if ((TAILQ_NEXT((_elm), field)) != NULL)                       \
+                       TAILQ_NEXT((_elm), field)->field.tqe_prev =            \
+                               &TAILQ_FIRST(head);                            \
+               else                                                           \
+                       (head)->tqh_last = &TAILQ_FIRST(head);                 \
+               TAILQ_FIRST(head) = TAILQ_NEXT((_elm), field);                 \
+       }; _elm; })
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _FRR_QUEUE_H */