[C] Is there any problem with the application of the double linked list in the kernel at the upper level? (list.h)

  html5, question

I put the list.h file of the double linked list in the kernel on the upper layer (currently there are no problems on Ubuntu system), does it imply some problems? ? ?

Since some header files of the kernel used in list.h cannot be included in the upper application, I directly transplanted some macros into list.h, and other codes did not change. The migrated macros are as follows:

#define prefetch(x) __builtin_prefetch(x)
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #define container_of(ptr, type, member) ({            \
 const typeof( ((type *)0)->member ) *__mptr = (ptr);  \
 (type *)( (char *)__mptr - offsetof(type,member) );  })

Some articles use “use’-d in compilation” when using list.h file in upper application.KERNELIs it appropriate to switch “cheat” the compiler? (This is no essential difference from me extracting the list.h file to the upper application separately)

There will be no problem. This is an extension of GNU/c compiler, but be careful when using it. You cannot add the same node, otherwise a loop will be formed. In addition, the red and black trees of the kernel can also be used. The implementation of these structures is very detailed. As far as my current use is concerned, I don’t have any compilation options for this file. I just need to extract the list.h file and add the above macros