libs/libc: add a option to disable path buffer by default
If the current platform does not require a large PATH_MAX size support and toolchain supports alloca(), we could turn off this option to improve performance. Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
parent
1f65af208a
commit
cf060b6bf2
4 changed files with 30 additions and 3 deletions
|
@ -31,6 +31,9 @@
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <alloca.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -119,8 +122,13 @@ unsigned long nrand(unsigned long limit);
|
||||||
|
|
||||||
/* Functions defined in lib_pathbuffer.c ************************************/
|
/* Functions defined in lib_pathbuffer.c ************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIBC_PATHBUFFER
|
||||||
FAR char *lib_get_pathbuffer(void);
|
FAR char *lib_get_pathbuffer(void);
|
||||||
void lib_put_pathbuffer(FAR char *buffer);
|
void lib_put_pathbuffer(FAR char *buffer);
|
||||||
|
#else
|
||||||
|
# define lib_get_pathbuffer() alloca(PATH_MAX)
|
||||||
|
# define lib_put_pathbuffer(b)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Functions defined in lib_realpath.c **************************************/
|
/* Functions defined in lib_realpath.c **************************************/
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,11 @@ list(
|
||||||
lib_mkdirat.c
|
lib_mkdirat.c
|
||||||
lib_utimensat.c
|
lib_utimensat.c
|
||||||
lib_mallopt.c
|
lib_mallopt.c
|
||||||
lib_getnprocs.c
|
lib_getnprocs.c)
|
||||||
lib_pathbuffer.c)
|
|
||||||
|
if(CONFIG_LIBC_PATHBUFFER)
|
||||||
|
list(APPEND SRCS lib_pathbuffer.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Support for platforms that do not have long long types
|
# Support for platforms that do not have long long types
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,16 @@ config LIBC_MEM_FD_VFS_PATH
|
||||||
---help---
|
---help---
|
||||||
The relative path to where memfd will exist in the tmpfs namespace.
|
The relative path to where memfd will exist in the tmpfs namespace.
|
||||||
|
|
||||||
|
config LIBC_PATHBUFFER
|
||||||
|
bool "Enable global path buffer"
|
||||||
|
default !DEFAULT_SMALL
|
||||||
|
---help---
|
||||||
|
Enable this option to enable the global path buffer, otherwise use stack variables via alloca().
|
||||||
|
If the current platform does not require a large PATH_MAX size support and toolchain supports alloca(),
|
||||||
|
we could turn off this option to improve performance.
|
||||||
|
|
||||||
|
if LIBC_PATHBUFFER
|
||||||
|
|
||||||
config LIBC_MAX_PATHBUFFER
|
config LIBC_MAX_PATHBUFFER
|
||||||
int "Maximum size of a temporary file path buffer array"
|
int "Maximum size of a temporary file path buffer array"
|
||||||
range 0 32
|
range 0 32
|
||||||
|
@ -133,6 +143,8 @@ config LIBC_PATHBUFFER_MALLOC
|
||||||
---help---
|
---help---
|
||||||
Enable malloc path buffer from the heap when pathbuffer is insufficient.
|
Enable malloc path buffer from the heap when pathbuffer is insufficient.
|
||||||
|
|
||||||
|
endif # LIBC_PATHBUFFER
|
||||||
|
|
||||||
config LIBC_BACKTRACE_BUFFSIZE
|
config LIBC_BACKTRACE_BUFFSIZE
|
||||||
int "The size of backtrace record buffer"
|
int "The size of backtrace record buffer"
|
||||||
depends on SCHED_BACKTRACE
|
depends on SCHED_BACKTRACE
|
||||||
|
|
|
@ -27,7 +27,11 @@ 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_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_fchmodat.c lib_fstatat.c lib_getfullpath.c lib_openat.c
|
||||||
CSRCS += lib_mkdirat.c lib_utimensat.c lib_mallopt.c
|
CSRCS += lib_mkdirat.c lib_utimensat.c lib_mallopt.c
|
||||||
CSRCS += lib_idr.c lib_getnprocs.c lib_pathbuffer.c
|
CSRCS += lib_idr.c lib_getnprocs.c
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_LIBC_PATHBUFFER),y)
|
||||||
|
CSRCS += lib_pathbuffer.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Support for platforms that do not have long long types
|
# Support for platforms that do not have long long types
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue