You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/09 00:41:55 UTC

(nuttx) branch master updated: circbuf: Move from mm/circbuf to libs/libc/misc

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b068e2357a circbuf: Move from mm/circbuf to libs/libc/misc
b068e2357a is described below

commit b068e2357add8e4131dfcfbc943fa6c5b36ca541
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Mar 4 18:14:35 2024 +0800

    circbuf: Move from mm/circbuf to libs/libc/misc
    
    so that it can be used by userspace program.
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Signed-off-by: Neo Xu <ne...@gmail.com>
---
 arch/arm/src/phy62xx/uart.c                        |  2 +-
 arch/risc-v/src/common/espressif/esp_rmt.c         |  2 +-
 arch/xtensa/src/common/espressif/esp_rmt.c         |  2 +-
 arch/xtensa/src/esp32/esp32_i2s.c                  |  2 +-
 arch/xtensa/src/esp32s2/esp32s2_i2s.c              |  2 +-
 arch/xtensa/src/esp32s3/esp32s3_i2s.c              |  2 +-
 boards/risc-v/bl602/bl602evb/src/bl602_bringup.c   |  2 +-
 drivers/input/keyboard_upper.c                     |  2 +-
 drivers/input/mouse_upper.c                        |  2 +-
 drivers/input/touchscreen_upper.c                  |  2 +-
 drivers/ipcc/ipcc_register.c                       |  2 +-
 drivers/pipes/pipe_common.h                        |  2 +-
 drivers/rc/lirc_dev.c                              |  2 +-
 drivers/rmt/rmtchar.c                              |  2 +-
 drivers/sensors/gnss_uorb.c                        |  2 +-
 drivers/sensors/sensor.c                           |  2 +-
 drivers/serial/uart_bth4.c                         |  2 +-
 drivers/serial/uart_bth5.c                         |  2 +-
 drivers/video/fb.c                                 |  2 +-
 include/nuttx/{mm => }/circbuf.h                   |  6 ++---
 include/nuttx/input/touchscreen.h                  |  2 +-
 include/nuttx/ipcc.h                               |  2 +-
 libs/libc/misc/CMakeLists.txt                      |  1 +
 libs/libc/misc/Make.defs                           |  4 +--
 .../circbuf.c => libs/libc/misc/lib_circbuf.c      | 14 +++++-----
 mm/Makefile                                        |  1 -
 mm/circbuf/CMakeLists.txt                          | 22 ----------------
 mm/circbuf/Make.defs                               | 30 ----------------------
 net/rpmsg/rpmsg_sockif.c                           |  2 +-
 29 files changed, 35 insertions(+), 87 deletions(-)

diff --git a/arch/arm/src/phy62xx/uart.c b/arch/arm/src/phy62xx/uart.c
index 7526a16eaf..1765bd13ec 100644
--- a/arch/arm/src/phy62xx/uart.c
+++ b/arch/arm/src/phy62xx/uart.c
@@ -46,7 +46,7 @@
 #include <nuttx/arch.h>
 #include <nuttx/fs/ioctl.h>
 #include <nuttx/serial/serial.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 
 #define UART_TX_BUFFER_SIZE   64
 #define UART_RX_BUFFER_SIZE   64
diff --git a/arch/risc-v/src/common/espressif/esp_rmt.c b/arch/risc-v/src/common/espressif/esp_rmt.c
index 0e94dbd950..d1af3861aa 100644
--- a/arch/risc-v/src/common/espressif/esp_rmt.c
+++ b/arch/risc-v/src/common/espressif/esp_rmt.c
@@ -39,7 +39,7 @@
 #include <nuttx/arch.h>
 #include <nuttx/rmt/rmt.h>
 #include <nuttx/spinlock.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 
 #include "esp_gpio.h"
 #include "esp_irq.h"
diff --git a/arch/xtensa/src/common/espressif/esp_rmt.c b/arch/xtensa/src/common/espressif/esp_rmt.c
index 5a19327813..2a62719967 100644
--- a/arch/xtensa/src/common/espressif/esp_rmt.c
+++ b/arch/xtensa/src/common/espressif/esp_rmt.c
@@ -39,7 +39,7 @@
 #include <nuttx/arch.h>
 #include <nuttx/rmt/rmt.h>
 #include <nuttx/spinlock.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 
 #include "xtensa.h"
 #ifdef CONFIG_ARCH_CHIP_ESP32
diff --git a/arch/xtensa/src/esp32/esp32_i2s.c b/arch/xtensa/src/esp32/esp32_i2s.c
index 24f74bbaf9..e3e7d6a5b6 100644
--- a/arch/xtensa/src/esp32/esp32_i2s.c
+++ b/arch/xtensa/src/esp32/esp32_i2s.c
@@ -44,7 +44,7 @@
 #include <nuttx/semaphore.h>
 #include <nuttx/spinlock.h>
 #include <nuttx/mqueue.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/audio/audio.h>
 #include <nuttx/audio/i2s.h>
 
diff --git a/arch/xtensa/src/esp32s2/esp32s2_i2s.c b/arch/xtensa/src/esp32s2/esp32s2_i2s.c
index 5ccfbef171..923384bb45 100644
--- a/arch/xtensa/src/esp32s2/esp32s2_i2s.c
+++ b/arch/xtensa/src/esp32s2/esp32s2_i2s.c
@@ -42,7 +42,7 @@
 #include <nuttx/clock.h>
 #include <nuttx/semaphore.h>
 #include <nuttx/mqueue.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/audio/audio.h>
 #include <nuttx/audio/i2s.h>
 
diff --git a/arch/xtensa/src/esp32s3/esp32s3_i2s.c b/arch/xtensa/src/esp32s3/esp32s3_i2s.c
index 1daa40477a..6434bb22cc 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_i2s.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_i2s.c
@@ -45,7 +45,7 @@
 #include <nuttx/semaphore.h>
 #include <nuttx/spinlock.h>
 #include <nuttx/mqueue.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/audio/audio.h>
 #include <nuttx/audio/i2s.h>
 
diff --git a/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c b/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c
index 0ee41b2bbe..96e545dfac 100644
--- a/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c
+++ b/boards/risc-v/bl602/bl602evb/src/bl602_bringup.c
@@ -58,7 +58,7 @@
 #include <nuttx/net/bluetooth.h>
 #include <nuttx/wireless/bluetooth/bt_driver.h>
 #include <nuttx/wireless/bluetooth/bt_uart.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #if defined(CONFIG_UART_BTH4)
 #include <nuttx/serial/uart_bth4.h>
 #endif
diff --git a/drivers/input/keyboard_upper.c b/drivers/input/keyboard_upper.c
index cfaf3ed226..1e42c09227 100644
--- a/drivers/input/keyboard_upper.c
+++ b/drivers/input/keyboard_upper.c
@@ -34,7 +34,7 @@
 #include <nuttx/input/virtio-input-event-codes.h>
 #include <nuttx/kmalloc.h>
 #include <nuttx/list.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/mutex.h>
 
 /****************************************************************************
diff --git a/drivers/input/mouse_upper.c b/drivers/input/mouse_upper.c
index fb0d9f0872..22caee8702 100644
--- a/drivers/input/mouse_upper.c
+++ b/drivers/input/mouse_upper.c
@@ -32,7 +32,7 @@
 #include <nuttx/kmalloc.h>
 #include <nuttx/mutex.h>
 #include <nuttx/list.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 
 /****************************************************************************
  * Private Types
diff --git a/drivers/input/touchscreen_upper.c b/drivers/input/touchscreen_upper.c
index bce5711059..11ebc3c104 100644
--- a/drivers/input/touchscreen_upper.c
+++ b/drivers/input/touchscreen_upper.c
@@ -38,7 +38,7 @@
 #include <nuttx/kmalloc.h>
 #include <nuttx/mutex.h>
 #include <nuttx/list.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 
 /****************************************************************************
  * Private Types
diff --git a/drivers/ipcc/ipcc_register.c b/drivers/ipcc/ipcc_register.c
index 46644f4b91..3f7abfb4bf 100644
--- a/drivers/ipcc/ipcc_register.c
+++ b/drivers/ipcc/ipcc_register.c
@@ -25,7 +25,7 @@
 #include <nuttx/config.h>
 #include <nuttx/ipcc.h>
 #include <nuttx/kmalloc.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 
 #include <assert.h>
 #include <errno.h>
diff --git a/drivers/pipes/pipe_common.h b/drivers/pipes/pipe_common.h
index 48f4279d79..dc150998f8 100644
--- a/drivers/pipes/pipe_common.h
+++ b/drivers/pipes/pipe_common.h
@@ -27,7 +27,7 @@
 
 #include <nuttx/config.h>
 #include <nuttx/mutex.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <sys/types.h>
 
 #include <stdint.h>
diff --git a/drivers/rc/lirc_dev.c b/drivers/rc/lirc_dev.c
index b763e6737c..1aae588932 100644
--- a/drivers/rc/lirc_dev.c
+++ b/drivers/rc/lirc_dev.c
@@ -34,7 +34,7 @@
 
 #include <nuttx/kmalloc.h>
 #include <nuttx/mutex.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/rc/lirc_dev.h>
 
 /****************************************************************************
diff --git a/drivers/rmt/rmtchar.c b/drivers/rmt/rmtchar.c
index bc0dad8591..77b12ff3a9 100644
--- a/drivers/rmt/rmtchar.c
+++ b/drivers/rmt/rmtchar.c
@@ -36,7 +36,7 @@
 
 #include <nuttx/fs/fs.h>
 #include <nuttx/kmalloc.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/mutex.h>
 #include <nuttx/rmt/rmt.h>
 
diff --git a/drivers/sensors/gnss_uorb.c b/drivers/sensors/gnss_uorb.c
index 92212647b0..0077a15c67 100644
--- a/drivers/sensors/gnss_uorb.c
+++ b/drivers/sensors/gnss_uorb.c
@@ -26,7 +26,7 @@
 
 #include <nuttx/kmalloc.h>
 #include <nuttx/list.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/sensors/sensor.h>
 #include <nuttx/sensors/gnss.h>
 
diff --git a/drivers/sensors/sensor.c b/drivers/sensors/sensor.c
index 9465e52727..b7177c7cbe 100644
--- a/drivers/sensors/sensor.c
+++ b/drivers/sensors/sensor.c
@@ -36,7 +36,7 @@
 #include <fcntl.h>
 #include <nuttx/list.h>
 #include <nuttx/kmalloc.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/mutex.h>
 #include <nuttx/sensors/sensor.h>
 
diff --git a/drivers/serial/uart_bth4.c b/drivers/serial/uart_bth4.c
index c5da4443f1..88301a68d8 100644
--- a/drivers/serial/uart_bth4.c
+++ b/drivers/serial/uart_bth4.c
@@ -26,7 +26,7 @@
 #include <nuttx/kmalloc.h>
 #include <nuttx/mutex.h>
 #include <nuttx/semaphore.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 
 #include <fcntl.h>
 #include <string.h>
diff --git a/drivers/serial/uart_bth5.c b/drivers/serial/uart_bth5.c
index 3ca56254d0..21a528b8c2 100644
--- a/drivers/serial/uart_bth5.c
+++ b/drivers/serial/uart_bth5.c
@@ -24,7 +24,7 @@
 
 #include <nuttx/fs/fs.h>
 #include <nuttx/kmalloc.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/mutex.h>
 #include <nuttx/semaphore.h>
 
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 0bef1d3cb2..d17c36eafe 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -41,7 +41,7 @@
 #include <nuttx/video/fb.h>
 #include <nuttx/clock.h>
 #include <nuttx/wdog.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 
 /****************************************************************************
  * Pre-processor definitions
diff --git a/include/nuttx/mm/circbuf.h b/include/nuttx/circbuf.h
similarity index 99%
rename from include/nuttx/mm/circbuf.h
rename to include/nuttx/circbuf.h
index 5334bd0ef5..3295c175cf 100644
--- a/include/nuttx/mm/circbuf.h
+++ b/include/nuttx/circbuf.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * include/nuttx/mm/circbuf.h
+ * include/nuttx/circbuf.h
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -20,8 +20,8 @@
  *
  ****************************************************************************/
 
-#ifndef __INCLUDE_NUTTX_MM_CIRCBUF_H
-#define __INCLUDE_NUTTX_MM_CIRCBUF_H
+#ifndef __INCLUDE_NUTTX_CIRCBUF_H
+#define __INCLUDE_NUTTX_CIRCBUF_H
 
 /* Note about locking: There is no locking required while only one reader
  * and one writer is using the circular buffer.
diff --git a/include/nuttx/input/touchscreen.h b/include/nuttx/input/touchscreen.h
index b5efd54e30..a06043b96c 100644
--- a/include/nuttx/input/touchscreen.h
+++ b/include/nuttx/input/touchscreen.h
@@ -38,7 +38,7 @@
 
 #include <nuttx/config.h>
 #include <nuttx/fs/ioctl.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/semaphore.h>
 #include <time.h>
 #include <inttypes.h>
diff --git a/include/nuttx/ipcc.h b/include/nuttx/ipcc.h
index 4b7c1c0804..68cf724497 100644
--- a/include/nuttx/ipcc.h
+++ b/include/nuttx/ipcc.h
@@ -28,7 +28,7 @@
  ****************************************************************************/
 
 #include <nuttx/config.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/semaphore.h>
 
 #include <poll.h>
diff --git a/libs/libc/misc/CMakeLists.txt b/libs/libc/misc/CMakeLists.txt
index 8dc028c0e6..ed29e81df3 100644
--- a/libs/libc/misc/CMakeLists.txt
+++ b/libs/libc/misc/CMakeLists.txt
@@ -27,6 +27,7 @@ list(
   APPEND
   SRCS
   lib_bitmap.c
+  lib_circbuf.c
   lib_mknod.c
   lib_umask.c
   lib_utsname.c
diff --git a/libs/libc/misc/Make.defs b/libs/libc/misc/Make.defs
index 2369fec786..398fa21fb2 100644
--- a/libs/libc/misc/Make.defs
+++ b/libs/libc/misc/Make.defs
@@ -22,8 +22,8 @@
 
 # Add the internal C files to the build
 
-CSRCS += lib_bitmap.c lib_mknod.c lib_umask.c lib_utsname.c lib_getrandom.c
-CSRCS += lib_xorshift128.c lib_tea_encrypt.c lib_tea_decrypt.c
+CSRCS += lib_bitmap.c lib_circbuf.c lib_mknod.c lib_umask.c lib_utsname.c
+CSRCS += lib_getrandom.c lib_xorshift128.c lib_tea_encrypt.c lib_tea_decrypt.c
 CSRCS += lib_cxx_initialize.c lib_impure.c lib_memfd.c lib_mutex.c
 CSRCS += lib_fchmodat.c lib_fstatat.c lib_getfullpath.c lib_openat.c
 CSRCS += lib_mkdirat.c lib_utimensat.c lib_mallopt.c lib_memoryregion.c
diff --git a/mm/circbuf/circbuf.c b/libs/libc/misc/lib_circbuf.c
similarity index 98%
rename from mm/circbuf/circbuf.c
rename to libs/libc/misc/lib_circbuf.c
index be42998b40..3006060003 100644
--- a/mm/circbuf/circbuf.c
+++ b/libs/libc/misc/lib_circbuf.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * mm/circbuf/circbuf.c
+ * libs/libc/misc/lib_circbuf.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -35,8 +35,8 @@
 
 #include <assert.h>
 
-#include <nuttx/kmalloc.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
+#include <nuttx/lib/lib.h>
 
 /****************************************************************************
  * Private Types
@@ -74,7 +74,7 @@ int circbuf_init(FAR struct circbuf_s *circ, FAR void *base, size_t bytes)
 
   if (!base && bytes)
     {
-      base = kmm_malloc(bytes);
+      base = lib_malloc(bytes);
       if (!base)
         {
           return -ENOMEM;
@@ -118,7 +118,7 @@ int circbuf_resize(FAR struct circbuf_s *circ, size_t bytes)
 
   if (bytes)
     {
-      tmp = kmm_malloc(bytes);
+      tmp = lib_malloc(bytes);
       if (!tmp)
         {
           return -ENOMEM;
@@ -134,7 +134,7 @@ int circbuf_resize(FAR struct circbuf_s *circ, size_t bytes)
       circbuf_read(circ, tmp, len);
     }
 
-  kmm_free(circ->base);
+  lib_free(circ->base);
 
   circ->base = tmp;
   circ->size = bytes;
@@ -176,7 +176,7 @@ void circbuf_uninit(FAR struct circbuf_s *circ)
 
   if (!circ->external)
     {
-      kmm_free(circ->base);
+      lib_free(circ->base);
     }
 
   memset(circ, 0, sizeof(*circ));
diff --git a/mm/Makefile b/mm/Makefile
index 7ea82e21e9..4b03bf6a96 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -30,7 +30,6 @@ include kmm_heap/Make.defs
 include mm_gran/Make.defs
 include shm/Make.defs
 include iob/Make.defs
-include circbuf/Make.defs
 include mempool/Make.defs
 include kasan/Make.defs
 include ubsan/Make.defs
diff --git a/mm/circbuf/CMakeLists.txt b/mm/circbuf/CMakeLists.txt
deleted file mode 100644
index 46ff9e3e30..0000000000
--- a/mm/circbuf/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# ##############################################################################
-# mm/circbuf/CMakeLists.txt
-#
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more contributor
-# license agreements.  See the NOTICE file distributed with this work for
-# additional information regarding copyright ownership.  The ASF licenses this
-# file to you under the Apache License, Version 2.0 (the "License"); you may not
-# use this file except in compliance with the License.  You may obtain a copy of
-# the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
-# License for the specific language governing permissions and limitations under
-# the License.
-#
-# ##############################################################################
-target_sources(mm PRIVATE circbuf.c)
diff --git a/mm/circbuf/Make.defs b/mm/circbuf/Make.defs
deleted file mode 100644
index 5812225dc8..0000000000
--- a/mm/circbuf/Make.defs
+++ /dev/null
@@ -1,30 +0,0 @@
-############################################################################
-# mm/circbuf/Make.defs
-#
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.  The
-# ASF licenses this file to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance with the
-# License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-############################################################################
-
-# Circular buffer management
-
-CSRCS += circbuf.c
-
-# Add the circular buffer directory to the build
-
-DEPPATH += --dep-path circbuf
-VPATH += :circbuf
diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c
index ac589ff241..d3302c47a1 100644
--- a/net/rpmsg/rpmsg_sockif.c
+++ b/net/rpmsg/rpmsg_sockif.c
@@ -35,7 +35,7 @@
 #include <debug.h>
 
 #include <nuttx/kmalloc.h>
-#include <nuttx/mm/circbuf.h>
+#include <nuttx/circbuf.h>
 #include <nuttx/rpmsg/rpmsg.h>
 #include <nuttx/mutex.h>
 #include <nuttx/semaphore.h>