[libc-commits] [libc] c0a74ad - [libc] Use QUEUE_TYPEOF in STAILQ_LAST (#79011)

via libc-commits libc-commits at lists.llvm.org
Mon Jan 22 10:25:10 PST 2024


Author: Petr Hosek
Date: 2024-01-22T10:25:06-08:00
New Revision: c0a74ad90c34de5e17f713cd2a97223a425dfeb7

URL: https://github.com/llvm/llvm-project/commit/c0a74ad90c34de5e17f713cd2a97223a425dfeb7
DIFF: https://github.com/llvm/llvm-project/commit/c0a74ad90c34de5e17f713cd2a97223a425dfeb7.diff

LOG: [libc] Use QUEUE_TYPEOF in STAILQ_LAST (#79011)

This is to ensure this macro is compatible with both C and C++.

Added: 
    

Modified: 
    libc/include/llvm-libc-macros/sys-queue-macros.h

Removed: 
    


################################################################################
diff  --git a/libc/include/llvm-libc-macros/sys-queue-macros.h b/libc/include/llvm-libc-macros/sys-queue-macros.h
index f41e7363e418bf..59e6a9a392c978 100644
--- a/libc/include/llvm-libc-macros/sys-queue-macros.h
+++ b/libc/include/llvm-libc-macros/sys-queue-macros.h
@@ -160,7 +160,9 @@
 #define STAILQ_EMPTY(head) ((head)->first == NULL)
 #define STAILQ_FIRST(head) ((head)->first)
 #define STAILQ_LAST(head, type, field)                                         \
-  (STAILQ_EMPTY(head) ? NULL : __containerof((head)->last, type, field.next))
+  (STAILQ_EMPTY(head)                                                          \
+       ? NULL                                                                  \
+       : __containerof((head)->last, QUEUE_TYPEOF(type), field.next))
 #define STAILQ_NEXT(elem, field) ((elem)->field.next)
 
 #define STAILQ_FOREACH(var, head, field)                                       \


        


More information about the libc-commits mailing list