Skip to content

Commit

Permalink
libs/libc/queue: inline queue list to improve performance
Browse files Browse the repository at this point in the history
add a config CONFIG_LIBC_INLINE_QUEUE to inline the queue list

test:
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

Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Jul 19, 2024
1 parent b706891 commit 1faeee3
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 12 deletions.
17 changes: 17 additions & 0 deletions include/nuttx/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ extern "C"
#define EXTERN extern
#endif

#ifndef CONFIG_LIBC_INLINE_QUEUE
/* Add nodes to queues */

void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node,
Expand All @@ -361,6 +362,22 @@ FAR dq_entry_t *dq_remfirst(FAR dq_queue_t *queue);

size_t sq_count(FAR sq_queue_t *queue);
size_t dq_count(FAR dq_queue_t *queue);
#else
/****************************************************************************
* Included Files
****************************************************************************/

# include "../libs/libc/queue/dq_addafter.c"
# include "../libs/libc/queue/dq_count.c"
# include "../libs/libc/queue/dq_remafter.c"
# include "../libs/libc/queue/dq_remfirst.c"
# include "../libs/libc/queue/dq_remlast.c"
# include "../libs/libc/queue/sq_addafter.c"
# include "../libs/libc/queue/sq_count.c"
# include "../libs/libc/queue/sq_remafter.c"
# include "../libs/libc/queue/sq_remfirst.c"
# include "../libs/libc/queue/sq_remlast.c"
#endif

#undef EXTERN
#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions libs/libc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ source "libs/libc/stream/Kconfig"
source "libs/libc/regex/Kconfig"
source "libs/libc/gpsutils/Kconfig"
source "libs/libc/fdt/Kconfig"
source "libs/libc/queue/Kconfig"
26 changes: 14 additions & 12 deletions libs/libc/queue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
#
# ##############################################################################

target_sources(
c
PRIVATE sq_addafter.c
sq_remlast.c
sq_remfirst.c
sq_remafter.c
sq_count.c
dq_addafter.c
dq_remlast.c
dq_remfirst.c
dq_remafter.c
dq_count.c)
if(NOT CONFIG_LIBC_INLINE_QUEUE)
target_sources(
c
PRIVATE sq_addafter.c
sq_remlast.c
sq_remfirst.c
sq_remafter.c
sq_count.c
dq_addafter.c
dq_remlast.c
dq_remfirst.c
dq_remafter.c
dq_count.c)
endif()
10 changes: 10 additions & 0 deletions libs/libc/queue/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config LIBC_INLINE_QUEUE
bool "Inline queue list to improve the performance"
default n
---help---
Inline queue list to improve the performance
4 changes: 4 additions & 0 deletions libs/libc/queue/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#
############################################################################

ifneq ($(CONFIG_LIBC_INLINE_QUEUE),y)

# Add the queue C files to the build

CSRCS += sq_addafter.c sq_remlast.c sq_remfirst.c sq_remafter.c sq_count.c
Expand All @@ -27,3 +29,5 @@ CSRCS += dq_addafter.c dq_remlast.c dq_remfirst.c dq_remafter.c dq_count.c

DEPPATH += --dep-path queue
VPATH += :queue

endif
3 changes: 3 additions & 0 deletions libs/libc/queue/dq_addafter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
void dq_addafter(FAR dq_entry_t *prev, FAR dq_entry_t *node,
dq_queue_t *queue)
{
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/dq_count.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
size_t dq_count(FAR dq_queue_t *queue)
{
FAR dq_entry_t *node;
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/dq_remafter.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
FAR dq_entry_t *dq_remafter(FAR dq_entry_t *node, FAR dq_queue_t *queue)
{
FAR dq_entry_t *ret = node->flink;
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/dq_remfirst.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
FAR dq_entry_t *dq_remfirst(dq_queue_t *queue)
{
FAR dq_entry_t *ret = queue->head;
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/dq_remlast.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
FAR dq_entry_t *dq_remlast(dq_queue_t *queue)
{
FAR dq_entry_t *ret = queue->tail;
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/sq_addafter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node,
sq_queue_t *queue)
{
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/sq_count.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
size_t sq_count(FAR sq_queue_t *queue)
{
FAR sq_entry_t *node;
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/sq_remafter.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue)
{
FAR sq_entry_t *ret = node->flink;
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/sq_remfirst.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
FAR sq_entry_t *sq_remfirst(sq_queue_t *queue)
{
FAR sq_entry_t *ret = queue->head;
Expand Down
3 changes: 3 additions & 0 deletions libs/libc/queue/sq_remlast.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
*
****************************************************************************/

#ifdef CONFIG_LIBC_INLINE_QUEUE
static inline_function
#endif
FAR sq_entry_t *sq_remlast(sq_queue_t *queue)
{
FAR sq_entry_t *ret = queue->tail;
Expand Down

0 comments on commit 1faeee3

Please sign in to comment.