circbuf: Move from mm/circbuf to libs/libc/misc

so that it can be used by userspace program.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Xiang Xiao
2024-03-04 18:14:35 +08:00
committed by Xiang Xiao
parent 066cd799d4
commit b068e2357a
29 changed files with 35 additions and 87 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
@@ -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
+1 -1
View File
@@ -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>
/****************************************************************************
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
/****************************************************************************
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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
@@ -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.
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -28,7 +28,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm/circbuf.h>
#include <nuttx/circbuf.h>
#include <nuttx/semaphore.h>
#include <poll.h>
+1
View File
@@ -27,6 +27,7 @@ list(
APPEND
SRCS
lib_bitmap.c
lib_circbuf.c
lib_mknod.c
lib_umask.c
lib_utsname.c
+2 -2
View File
@@ -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
@@ -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));
-1
View File
@@ -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
-22
View File
@@ -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)
-30
View File
@@ -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
+1 -1
View File
@@ -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>