queue: inline queue
Summary
queue: inline queue
Impact
Testing
We can use qemu for testing. compiling make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20 running qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx
I think we should keep balance with small memory footprint devices, FYI: https://github.com/apache/nuttx/pull/6766
How about implement a similar function like list_gen? we could use similar methods elegantly in c files or header files
https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/sys/list_gen.h
https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/sys/slist.h
How about implement a similar function like
list_gen? we could use similar methods elegantly in c files or header files https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/sys/list_gen.h https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/sys/slist.h
but, zephyr approach is similar as https://github.com/apache/nuttx/blob/master/include/nuttx/list.h. Why not continue use list.h?
How about using macros to isolate different implementations? list.h:
#ifdef INLINE_QUEUE
#define STATIC_INLINE static line
#else
#define STATIC_INLINE
#endif
STATIC_INLINE void add_queue(void);
#ifdef INLINE_QUEUE
STATIC_INLINE void add_queue(void)
{
#implement
}
#endif
list.c:
#undef INLINE_QUEUE
#include <list.h>
Make.defs
ifneq ($(INLINE_QUEUE),y)
CSRCS += list.c
endif
Do we have any details on this change? Like performance vs size measurements. What is the value that we are trying to achieve with this change?
How about using macros to isolate different implementations? list.h:
#ifdef INLINE_QUEUE #define STATIC_INLINE static line #else #define STATIC_INLINE #endif STATIC_INLINE void add_queue(void); #ifdef INLINE_QUEUE STATIC_INLINE void add_queue(void) { #implement } #endiflist.c:
#undef INLINE_QUEUE #include <list.h>Make.defs
ifneq ($(INLINE_QUEUE),y) CSRCS += list.c endif
@hujun260 How about this approach? You could still merge all list implementations into the header file
How about using macros to isolate different implementations? list.h:
#ifdef INLINE_QUEUE #define STATIC_INLINE static line #else #define STATIC_INLINE #endif STATIC_INLINE void add_queue(void); #ifdef INLINE_QUEUE STATIC_INLINE void add_queue(void) { #implement } #endiflist.c:
#undef INLINE_QUEUE #include <list.h>Make.defs
ifneq ($(INLINE_QUEUE),y) CSRCS += list.c endif@hujun260 How about this approach? You could still merge all list implementations into the header file
If we use this approach, we would need to write the same implementation in both the header file and the source file. Subsequent modifications could lead to omissions.
If we use this approach, we would need to write the same implementation in both the header file and the source file. Subsequent modifications could lead to omissions.
You only need to keep one implementation in the header file, and the C source file needs to include the header file without implementing the function