Commit Graph

1623 Commits

Author SHA1 Message Date
guoshichao
abfb7da553 libs/libc/libc.csv: add the implemented wchar api declaration
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
5bd8e56cbe libs/libc/wchar: add fputws implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
d67090c47e libs/libc/wchar: add putwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
a9b2857754 libs/libc/wchar: add putwchar implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
f8b5f613e2 libs/libc/wchar: add fputwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
d386df4424 libs/libc/wchar: add wcswidth implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
7c0685c53d libs/libc/wchar: add wcwidth implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
f9c8461c72 libs/libc/wchar: add wcswcs implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
199bc57035 libs/libc/wchar: add wcstok implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
9070743fe8 libs/libc/wchar: add wcsstr implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
20802fcf5c libs/libc/wchar: add wcsspn implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
181a2d916d libs/libc/wchar: add wcspbrk implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-22 08:51:07 +08:00
guoshichao
2abb760564 libs/libc/wchar/CMakeList: update the cmake to add the wchar impl
add lib_wcsrtombs.c lib_wcscpy.c lib_wcscat.c lib_wcslcat.c
lib_wcsncat.c lib_wcsrchr.c lib_wcschr.c lib_wcsncpy.c
lib_wcsncmp.c lib_wcscspn.c file

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
e2962e84c5 libs/libc/wchar: add wcsspn implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
899f170826 libs/libc/wchar: add wcsncmp implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
ae4303da2f libs/libc/wchar: add wcsncpy implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
34346e38e1 libs/libc/wchar: add the wcschr implementatioin
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
206cd96426 libs/libc/wchar: add wcsrchr implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
cd19acee76 libs/libc/wchar: add wcsncat implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
4f9d304591 libs/libc/wchar: add wcslcat implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
0a1708dbb2 libs/libc/wchar: add wcscat implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
guoshichao
4b1c0220d3 libs/libc/wchar: add wcscpy implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-09-21 14:02:18 +08:00
hujun5
4268b2e297 pthread_once: use rmutex replace sched_[un]lock
sched_[un]lock can not prohibit pre-emption in smp

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-09-21 00:42:29 +08:00
Neale Ferguson
5d7f2fdf16 Fix loading of ET_DYN type of shared objects
* build-globals.sh
  - Only look in the nuttx for external symbols used when loading
    dynamic shared objects

* include/elf64.h
  - Correct the type of fields in the Elf64_Phdr structure

* libs/libc/dlfcn/lib_dlclose.c
  - Distinguish between ET_DYN and other objects as the former
    has both text and data in a single allocation to reserve
    GOT offsets

* libs/libc/dlfcn/lib_dlopen.c
  - Code formatting

* libs/libc/modlib/modlib_bind.c
  - Distinguish between relocation entry sizes by section type
  - Handle RELA style relocations

* libs/libc/modlib/modlib_globals.S
  - Formatting fixes
  - Symbols should not be weak - they exist or they don't

* include/nuttx/lib/modlib.h
  - Add an inidcator to module_s to distinguish between ET_DYN and other

* libs/libc/modlib/modlib_load.c
  - ET_DYN objects need to keep the relative displacement between the text
    and data sections due to GOT references from the former to the latter.
    This also implies that linking may require modification from the default
    for the shared objects being produced. For example, default alignment may
    mean nearly 64K of wasted space.

* libs/libc/modlib/modlib_unload.c
  sched/module/mod_rmmod.c
  - Distingusih between freeing of ET_DYN storage and other as the former
    is a single allocation.

* libs/libc/modlib/mod_insmod.c
  - Cater for ET_DYN objects having init and preinit sections
2023-09-20 09:35:28 -04:00
dongjiuzhu1
3884087396 libc/mod: fix minor issue about description
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-09-20 17:02:29 +08:00
dongjiuzhu1
e8c9541263 libs/modlib: avoid double free when call modlib_unload with erro
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-09-20 17:02:29 +08:00
dongjiuzhu1
310ba09ed7 libs/modlib: avoid seeking in each reading
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-09-20 17:02:29 +08:00
dongjiuzhu1
13bdaaec99 libs/modlib: close fd when error happen
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-09-20 17:02:29 +08:00
chao an
6b070b2b00 libs/libc: currect usage of getpid/gettid in library
Signed-off-by: chao an <anchao@xiaomi.com>
2023-09-20 10:08:24 +08:00
hujun5
51a412c6b4 pthread_cleanup: rm sched_[un]lock
Since TLS is only used within a single thread and requires no additional protection.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-09-20 00:44:19 +08:00
chenrun1
4ce205cf08 lib_iconv.c:Fix possible out-of-bounds reads
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-09-19 09:34:48 +08:00
Petro Karashchenko
587f01a5e2 libs/libxx/libcxx: fix CI compilation issue reported on MACOS
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-19 01:17:17 +08:00
chao an
5026a96cfa nxstyle: cleanup UTF-8 Unicode to ASCII
Signed-off-by: chao an <anchao@xiaomi.com>
2023-09-18 11:54:17 -04:00
yanghuatao
7ea52505c2 libm/libmcs: Fix clang build download libmcs warning
VELAPLATFO-16865

Fix warnings:
CC:  libmcs/libmcs/libm/common/fenv.c libmcs/libmcs/libm/common/fenv.c:26:15: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
int fegetround()
              ^
               void
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
2023-09-18 23:00:38 +08:00
yanghuatao
88193d3ad5 libm/libmcs: Fix clang build libmcs warning
VELAPLATFO-15795

Fix warnings:
1 warning generated.
CC:  libmcs/libmcs/libm/mathd/lrintd.c libmcs/libmcs/libm/mathd/lrintd.c:141:20: warning: implicit conversion from 'unsigned long long' to 'long' changes value from 9223372036854775808 to 0 [-Wconstant-conversion]
            return __MIN_LONG;
            ~~~~~~ ^~~~~~~~~~
/mnt/yang/vela_keystore_sim/nuttx/libs/libm/libmcs/libmcs/libm/include/internal_config.h:50:24: note: expanded from macro '__MIN_LONG'
    #define __MIN_LONG 0x8000000000000000L
                       ^~~~~~~~~~~~~~~~~~~
libmcs/libmcs/libm/mathd/lrintd.c:144:20: warning: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Wconstant-conversion]
            return __MAX_LONG;
            ~~~~~~ ^~~~~~~~~~
/mnt/yang/vela_keystore_sim/nuttx/libs/libm/libmcs/libmcs/libm/include/internal_config.h:49:24: note: expanded from macro '__MAX_LONG'
    #define __MAX_LONG 0x7FFFFFFFFFFFFFFFL
                       ^~~~~~~~~~~~~~~~~~~
2 warnings generated.
CC:  libmcs/libmcs/libm/mathd/lroundd.c libmcs/libmcs/libm/mathd/lroundd.c:123:20: warning: implicit conversion from 'unsigned long long' to 'long' changes value from 9223372036854775808 to 0 [-Wconstant-conversion]
            return __MIN_LONG;
            ~~~~~~ ^~~~~~~~~~
/mnt/yang/vela_keystore_sim/nuttx/libs/libm/libmcs/libmcs/libm/include/internal_config.h:50:24: note: expanded from macro '__MIN_LONG'
    #define __MIN_LONG 0x8000000000000000L
                       ^~~~~~~~~~~~~~~~~~~
libmcs/libmcs/libm/mathd/lroundd.c:126:20: warning: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Wconstant-conversion]
            return __MAX_LONG;
            ~~~~~~ ^~~~~~~~~~
/mnt/yang/vela_keystore_sim/nuttx/libs/libm/libmcs/libmcs/libm/include/internal_config.h:49:24: note: expanded from macro '__MAX_LONG'
    #define __MAX_LONG 0x7FFFFFFFFFFFFFFFL
                       ^~~~~~~~~~~~~~~~~~~
2 warnings generated.
CC:  libmcs/libmcs/libm/mathf/lrintf.c libmcs/libmcs/libm/mathf/lrintf.c:67:20: warning: implicit conversion from 'unsigned long long' to 'long' changes value from 9223372036854775808 to 0 [-Wconstant-conversion]
            return __MIN_LONG;
            ~~~~~~ ^~~~~~~~~~
/mnt/yang/vela_keystore_sim/nuttx/libs/libm/libmcs/libmcs/libm/include/internal_config.h:50:24: note: expanded from macro '__MIN_LONG'
    #define __MIN_LONG 0x8000000000000000L
                       ^~~~~~~~~~~~~~~~~~~
libmcs/libmcs/libm/mathf/lrintf.c:70:20: warning: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Wconstant-conversion]
            return __MAX_LONG;
            ~~~~~~ ^~~~~~~~~~
/mnt/yang/vela_keystore_sim/nuttx/libs/libm/libmcs/libmcs/libm/include/internal_config.h:49:24: note: expanded from macro '__MAX_LONG'
    #define __MAX_LONG 0x7FFFFFFFFFFFFFFFL
                       ^~~~~~~~~~~~~~~~~~~
2 warnings generated.
CC:  libmcs/libmcs/libm/mathf/lroundf.c libmcs/libmcs/libm/mathf/lroundf.c:32:20: warning: implicit conversion from 'unsigned long long' to 'long' changes value from 9223372036854775808 to 0 [-Wconstant-conversion]
            return __MIN_LONG;
            ~~~~~~ ^~~~~~~~~~
/mnt/yang/vela_keystore_sim/nuttx/libs/libm/libmcs/libmcs/libm/include/internal_config.h:50:24: note: expanded from macro '__MIN_LONG'
    #define __MIN_LONG 0x8000000000000000L
                       ^~~~~~~~~~~~~~~~~~~
libmcs/libmcs/libm/mathf/lroundf.c:34:20: warning: implicit conversion from 'long long' to 'long' changes value from 9223372036854775807 to -1 [-Wconstant-conversion]
            return __MAX_LONG;
            ~~~~~~ ^~~~~~~~~~
/mnt/yang/vela_keystore_sim/nuttx/libs/libm/libmcs/libmcs/libm/include/internal_config.h:49:24: note: expanded from macro '__MAX_LONG'
    #define __MAX_LONG 0x7FFFFFFFFFFFFFFFL

Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
2023-09-18 21:02:39 +08:00
dongjiuzhu1
4763ca849a libxx/libcxx: select PTHREAD_MUTEX_TYPES to support recursive mutex
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-09-18 15:34:44 +08:00
Daniel Appiagyei
5bfda12634 c++ compatibility: rename reserved c++ keywords 'public' and 'this' 2023-09-16 19:45:02 +08:00
SPRESENSE
3c96621e1e libs:netdb: Restrict DNS query types
Corresponds to the problem of name resolution with different IP
address types in networks where only one of IPv4 or IPv6 can be
used due to physical layer reasons (e.g., LTE networks).
2023-09-16 14:43:12 +08:00
Petro Karashchenko
8a72eaf557 libs/libc/modlib: fix nxstyle issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00
Petro Karashchenko
440be65010 spinlock: use spinlock API instead of direct asignment/compare
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00
Petro Karashchenko
f06c509f9e libs/libc/pthread: correct description on pthread_setcanceltype
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-09-16 14:17:47 +08:00
Xiang Xiao
368198706a lib/machine: Add LIBC_PREVENT_xxx which select LIBC_PREVENT_XXX_[KERNEL|USER] automatically
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-15 22:31:34 +03:00
yangdongdong
fa620dee9d Provide flat mode the chip string customization.
Signed-off-by: yangdongdong <yangdongdong@xiaomi.com>
2023-09-15 13:34:55 +08:00
Roy Feng
e90d58c3da esp32: Use newlib-esp32
When we are using newlib as libm, we can consider newlib-esp32 for esp32
hardware. An it contains some optimization for esp32 hardware.
Besides, two small issues has been fixed.
1. add the tar ball to .gitignore
2. Fix the some build warnings
2023-09-14 19:33:50 +08:00
Ville Juven
c178fa3260 stdio/lib_libfread: Fix buffer overflow issue
If the gulp size in the stdio buffer the remaining user buffer size it will:
- Corrupt memory in dest (user memory) and
- Keep corrupting KERNEL memory via the stdio character buffer until the
  whole system crashes, as the 'remaining' count underflows

This patch fixes this behavior.
2023-09-13 21:52:57 +08:00
chao an
9f10ddc9b0 nuttx/build: Restore ARLOCK to improve compile speed in incremental case
To solve the issue of carrying object files from previous builds,
Matias changed the archiving process to re-archive libapps.a on every compilation,
if libapps.a carries more object files, incremental compilation will waste too
many time in re-archiving, compared with the previous implement, this is a degradation
of the build system.  Referring to mature engineering projects such as cmake, if there
is configuration or source file changed, the best solution should be to reconfigure
the environment.

Revert this PR to ensure the compilation speed during incremental compilation.

|  commit 34b34e2d45 (tag: nuttx-20200914-172150)
|  Author: Matias N <matias@protobits.dev>
|  Date:   Fri Sep 11 22:31:38 2020 -0300
|
|      Fix: ensure archive files do not carry object files from prior builds
|
|      In some cases, when NuttX configuration changes and this makes the
|      object list used to build one of the .a libraries change as well,
|      since the command used to build it is "ar crs" and this simply appends
|      the list of object files, the library could still include object
|      files from prior builds. This commit modifies the ARCHIVE macro to
|      erase the .a file if it already exists.
|
|      Since in some cases this behavior was actually expected (object
|      files from a subdirectory were appended to a library created one
|      level above) I added a ARCHIVE_ADD which works as ARCHIVE did.
|
|      This change should greatly improve behavior of building after
|      configuration changes.

Testing:

sim:nsh
-------------------------------
|   Patched    |  Current
-------------------------------
|$ time make   |  $ time make
|real 0m1.270s |  real 0m1.728s
|user 0m0.971s |  user 0m1.276s
|sys  0m0.363s |  sys  0m0.530s
-------------------------------

Private project (20+ 3rd library needs archive to libapps.a)
-------------------------------
|   Patched     |  Current
-------------------------------
|$ time make    |  $ time make
|real 0m21.181s |  real 0m39.721s
|user 0m14.638s |  user 0m24.837s
|sys  0m6.919s  |  sys  0m14.394s
-------------------------------

Signed-off-by: chao an <anchao@xiaomi.com>
2023-09-12 21:55:23 +08:00
wangming9
61a38ca680 libs/libxx/libcxx: Fix compilation warnings
Summary
Workaround the following warning with "GCC 12"
CXX:  libcxxabi/src/cxa_demangle.cpp In file included from libcxx/src/locale.cpp:15:
In member function 'std::__1::_EnableIf<std::__1::__is_cpp17_forward_iterator<_ForwardIterator>::value> std::__1::basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = const wchar_t*; _CharT = wchar_t; _Traits = std::__1::char_traits<wchar_t>; _Allocator = std::__1::allocator<wchar_t>]',    inlined from 'std::__1::basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator, _InputIterator) [with _InputIterator = const wchar_t*; <template-parameter-2-2> = void; _CharT = wchar_t; _Traits = std::__1::char_traits<wchar_t>; _Allocator = std::__1::allocator<wchar_t>]' at include/libcxx/string:2182:11,
    inlined from 'virtual int std::__1::collate_byname<wchar_t>::do_compare(const char_type*, const char_type*, const char_type*, const char_type*) const' at libcxx/src/locale.cpp:764:33:
include/libcxx/string:2156:35: warning: 'lhs' may be used uninitialized [-Wmaybe-uninitialized]
 2156 |         this->__throw_length_error();
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~

include/libcxx/new:237:24: warning: argument 1 value '18446744073709551599' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
  237 |   return ::operator new(__args...);
      |          ~~~~~~~~~~~~~~^~~~~~~~~~~

Signed-off-by: wangming9 <wangming9@xiaomi.com>
2023-09-09 17:08:23 +03:00
wangming9
6265596cd0 libs/libc: Modify the Kconfig error description
Signed-off-by: wangming9 <wangming9@xiaomi.com>
2023-09-09 17:08:23 +03:00
yangyalei
fd776e8cee fix wait after vfork return error
vfork use waitpid hang father process,
but waitpid release child processs information by default.
So when user call wait, it return errno 10.

Signed-off-by: yangyalei <yangyalei@xiaomi.com>
2023-09-08 00:53:56 +03:00
yangyalei
eba2f163ed Revert "fix wait after vfork return error"
This reverts commit 50428979d0.
2023-09-08 00:53:56 +03:00