3 ms·
I've never written code with it, but the BSDs use these macros to implement rudimentary generic types in C: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-curre
by bjackman 12y ago
I've never written code with it, but the BSDs use these macros to implement rudimentary generic types in C: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/LIST_EMPTY.3?query=queue&sec=3&arch=i386 http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/.... Nice.
However, I've only had horrible experiences trying to read the BSDs' kernel code. There are way too many statements like "mst_fqd->f_do_skb((struct mfq_t *) q);"
- jpfr 12y agoYes! That's a really good implementations of linked lists using only preprocessor macros. sys/queue.h is also provided in all Linux systems. Easy to use, type-checked by the compiler and a lot faster than a "generic" linked list with pointers to the data. Here, the next/previous pointers get embedded in the payload struct itself.