nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

queue: inline queue

Open hujun260 opened this issue 1 year ago • 8 comments

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

hujun260 avatar Jul 01 '24 01:07 hujun260

I think we should keep balance with small memory footprint devices, FYI: https://github.com/apache/nuttx/pull/6766

anchao avatar Jul 01 '24 01:07 anchao

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

anchao avatar Jul 01 '24 02:07 anchao

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?

xiaoxiang781216 avatar Jul 01 '24 02:07 xiaoxiang781216

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

anchao avatar Jul 01 '24 02:07 anchao

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?

pkarashchenko avatar Jul 03 '24 18:07 pkarashchenko

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

@hujun260 How about this approach? You could still merge all list implementations into the header file

anchao avatar Jul 20 '24 00:07 anchao

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

@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.

hujun260 avatar Jul 21 '24 03:07 hujun260

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

anchao avatar Jul 21 '24 03:07 anchao