Skip to content

Commit

Permalink
circbuf: Move from mm/circbuf to libs/libc/misc
Browse files Browse the repository at this point in the history
so that it can be used by userspace program.

Signed-off-by: Xiang Xiao <[email protected]>
Signed-off-by: Neo Xu <[email protected]>
  • Loading branch information
xiaoxiang781216 committed Oct 9, 2024
1 parent 066cd79 commit b068e23
Show file tree
Hide file tree
Showing 29 changed files with 35 additions and 87 deletions.
2 changes: 1 addition & 1 deletion arch/arm/src/phy62xx/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/espressif/esp_rmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/common/espressif/esp_rmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/esp32/esp32_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/esp32s2/esp32s2_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/esp32s3/esp32s3_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion boards/risc-v/bl602/bl602evb/src/bl602_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/keyboard_upper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/mouse_upper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/touchscreen_upper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/ipcc/ipcc_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion drivers/pipes/pipe_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion drivers/rc/lirc_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion drivers/rmt/rmtchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion drivers/sensors/gnss_uorb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion drivers/sensors/sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion drivers/serial/uart_bth4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion drivers/serial/uart_bth5.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion drivers/video/fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions include/nuttx/mm/circbuf.h → include/nuttx/circbuf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* include/nuttx/mm/circbuf.h
* include/nuttx/circbuf.h
*
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion include/nuttx/input/touchscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion include/nuttx/ipcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/mm/circbuf.h>
#include <nuttx/circbuf.h>
#include <nuttx/semaphore.h>

#include <poll.h>
Expand Down
1 change: 1 addition & 0 deletions libs/libc/misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ list(
APPEND
SRCS
lib_bitmap.c
lib_circbuf.c
lib_mknod.c
lib_umask.c
lib_utsname.c
Expand Down
4 changes: 2 additions & 2 deletions libs/libc/misc/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions mm/circbuf/circbuf.c → libs/libc/misc/lib_circbuf.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* mm/circbuf/circbuf.c
* libs/libc/misc/lib_circbuf.c
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion mm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions mm/circbuf/CMakeLists.txt

This file was deleted.

30 changes: 0 additions & 30 deletions mm/circbuf/Make.defs

This file was deleted.

2 changes: 1 addition & 1 deletion net/rpmsg/rpmsg_sockif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit b068e23

Please sign in to comment.