buxiasen
4028132910
libc/localtime: rename offsetp to poffset
...
Fix spell check error
lib_localtime.c:1291: offsetp ==> offset
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-12-19 13:46:21 -05:00
buxiasen
bda9ab9287
libc/localtime: tz_lock/unlock should not touch tcb except FLAT
...
Causing kernel build report undefined reference 'g_nx_initstate'
Also protect build, as user elf have no access of kernel objects.
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-12-19 13:46:21 -05:00
raiden00pl
7e11edba5d
libs: unify Private Types banners
...
unify Private Types banners according to NuttX coding standard
Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-28 10:17:15 +08:00
Lars Kruse
3ce85ca54e
style: fix spelling in code comments and strings
2025-05-23 10:48:41 +08:00
Lars Kruse
4568110d63
fix misspelled names in locally scoped code
...
These misspelled words are used in strictly local scopes.
Renaming these variables should not cause any problems.
2025-05-15 10:12:12 +08:00
ouyangxiangzhen
3622e4830a
sched: Correct word spelling mistakes.
...
This commit fixed serveral word spelling mistakes.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-05-12 19:56:29 +08:00
Tim Kan(SSS)
4dd042d00b
fix(libc): lib_strftime %F month number off-by-one
...
Corrects the month number output for the %F format specifier in lib_strftime.
2025-01-21 18:24:35 +08:00
ouyangxiangzhen
17c51c0667
userspace: Exclude nuttx/arch.h
...
This patch fixed userspace headers conflict. Architecture-related definition and API should not be exposed to users.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-11-01 16:59:37 +08:00
chenjiahua1
c1fb6974ac
strptime.c:len is not defined.
...
Bring all code that uses the variable len under the CONFIG_LIBC_LOCALE
Signed-off-by: chenjiahua1 <chenjiahua1@xiaomi.com>
2024-10-16 17:02:51 +08:00
chenjiahua1
64eecbfede
libc/time: add lib_strptime
...
The community deleted strptime due to license reasons, and we replaced it with musl.
Signed-off-by: chenjiahua1 <chenjiahua1@xiaomi.com>
2024-10-16 17:02:51 +08:00
hujun5
a567148888
sched: add up_this_task and up_change_task macro stub
...
reason:
We can utilize percpu storage to hold information about the
current running task. If we intend to implement this feature, we would
need to define two macros that help us manage this percpu information
effectively.
up_this_task: This macro is designed to read the contents of the percpu
register to retrieve information about the current
running task.This allows us to quickly access
task-specific data without having to disable interrupts,
access global variables and obtain the current cpu index.
up_update_task: This macro is responsible for updating the contents of
the percpu register.It is typically called during
initialization or when a context switch occurs to ensure
that the percpu register reflects the information of the
newly running task.
Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
-machine virt,virtualization=on,gic-version=3 \
-net none -chardev stdio,id=con,mux=on -serial chardev:con \
-mon chardev=con,mode=readline -kernel ./nuttx
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-15 15:25:55 +08:00
Alin Jerpelea
6b5dddd5d7
libs/libc: migrate to SPDX identifier
...
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-10-01 12:25:52 +08:00
wanggang26
f6d378e528
enable O_CLOEXEC explicitly to avoid fd leak
...
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-17 02:07:34 +08:00
dongjiuzhu1
7f99a15ccf
libc/time: add g_lcl_lock to protect local context in localsub
...
0x0c1561f8 in localsub (tmp=0x3c887088, offset=0, timep=0x3c887078) at time/lib_localtime.c:1993
localtime_r (timep=0x3c887078, timep@entry=0x3c887088, tmp=0x3c887088, tmp@entry=0x3c887098) at time/lib_localtime.c:2819
0x0c1225c8 in nx_vsyslog (priority=7, fmt=0x2c6d9700 <error: Cannot access memory at address 0x2c6d9700>,
ap=0x3c887170, ap@entry=0x3c887178) at syslog/vsyslog.c:135
0x0c152068 in vsyslog (priority=priority@entry=7,
fmt=fmt@entry=0x2c6d9700 <error: Cannot access memory at address 0x2c6d9700>, ap=ap@entry=...) at syslog/lib_syslog.c:68
0x0c152098 in syslog (priority=priority@entry=7, fmt=0x2c6d9700 <error: Cannot access memory at address 0x2c6d9700>) at syslog/lib_syslog.c:100
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 10:35:17 +08:00
ligd
f0d3c8ab2b
usleep: use div_const to optimize the usleep
...
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-12 18:14:39 +08:00
chao an
85c39e96d6
global/variables: add g_ prefix to some global variables
...
Signed-off-by: chao an <anchao@lixiang.com>
2024-09-02 18:23:57 +08:00
Alin Jerpelea
fe642f1cfd
libc/time: remove lib_strptime
...
This code is licensed under BSD-4-Clause license which may render the OS unusable for some products.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-08-22 16:45:15 +08:00
anjiahao
3fdff878bc
libc:Add macro restrictions to code that uses floating point numbers
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-08-21 13:33:45 +08:00
Xiang Xiao
7aad7eebff
libc: Change errno to set_errno and get_errno
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-29 17:16:09 +02:00
dongjiuzhu1
fbd6484532
libc/localtime: fix the timezone error caused by minor error
...
align: https://github.com/eggert/tz/blob/main/localtime.c
correct timeone in test:
server> timedatectl set-timezone Pacific/Auckland
server> timedatectl
TimeZone: NZDT, 46800
Local time: Sat, Oct 21 21:47:34 2023 NZDT
Universal time: Sat, Oct 21 08:47:34 2023 UTC
RTC time: Sat, Oct 21 08:47:35 2023
error timezone:
server> timedatectl set-timezone Pacific/Auckland
server> timedatectl
TimeZone: NZST, 43200
Local time: Sat, Oct 21 20:52:27 2023 NZST
Universal time: Sat, Oct 21 08:52:27 2023 UTC
RTC time: Sat, Oct 21 08:52:27 2023
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 00:10:04 +08:00
guoshichao
714926e6ea
libs/libc/strftime: add modifier character support to strftime
...
1. make the ltp/open_posix_testsuite/strftime 2-1.c case
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-24 10:34:23 -07:00
guoshichao
0092b3e30f
sched/signal/sig_nanosleep: fix the clock_nanosleep posix case
...
1. make the clock_nanosleep can pass
ltp/open_posix_testsuite/clock_nanosleep 13-1, 10-1, 9-1 cases
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-07-23 22:02:03 -07:00
chao an
6ee9ec7656
build: add initial cmake build system
...
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)
------------------
How to test
From within nuttx/. Configure:
cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja
(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja
This uses ninja generator (install with sudo apt install ninja-build). To build:
$ cmake --build build
menuconfig:
$ cmake --build build -t menuconfig
--------------------------
2. cmake/build: reformat the cmake style by cmake-format
https://github.com/cheshirekow/cmake_format
$ pip install cmakelang
$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done
Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
guoshichao
083c11ef1a
libs/libc/time/strftime: complete the strftime implementation
...
1. make the strftime implementation can pass the
ltp/open_posix_testsuite/strftime/1-1 testcase
2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-06-30 12:02:23 +08:00
Xiang Xiao
7f80b4aeba
clock: Move the content of include/nuttx/time.h to include/nuttx/clock.h
...
and remove include/nuttx/time.h to reduce the nuttx specific header files
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-26 19:14:08 +03:00
Alan Carvalho de Assis
9b8eedd218
lib_strftime: Also fix %l to avoid printing 0:xx AM/PM
2023-06-21 12:18:00 +08:00
Alan Carvalho de Assis
95f131c3c2
lib_strftime: Fix %I to avoid printing 00:xx AM/PM
...
Currently strftime is printing 00:00 AM and 00:00 PM instead of
12:00 AM and 12:00 PM when using %I.
This commit fixes this issue!
2023-06-21 12:18:00 +08:00
chao an
fb9b41221d
semantic/parser: fix compile warning found by sparse
...
Reference:
https://linux.die.net/man/1/sparse
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-30 23:00:00 +08:00
chao an
c839fc45af
libc/settimeofday: correct prototype of settimeofday()
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-03-21 11:16:30 -03:00
lilei19
38f64f559d
change strcpy to strlcpy
...
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-02-24 12:15:40 +08:00
chao an
3a0fdb019d
nuttx: replace all ARRAY_SIZE()/ARRAYSIZE() to nitems()
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-09 20:05:44 +08:00
chao an
7625126c91
Remove the remain MIN/MAX like macro
...
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-03 23:22:41 +08:00
ligd
367fa640c1
asctime_r: add param check to asctime_r()
2023-01-28 23:23:12 +02:00
ligd
f243e4f268
localtime: fix deadlock when print syslog in romfs
...
thread1:
romfs_seek -> take romfslock -> syslog -> tzset
thread2:
sylsog -> tzset -> tz_load -> romfs_open -> deadlock
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-11-28 18:04:38 +08:00
Petro Karashchenko
6908b6823c
libs/libc/time: fix regression in clock_calendar2utc
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-10-28 10:21:05 +08:00
Petro Karashchenko
fdff92fd19
libs/libc/time: mktime normalize struct tm
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-10-27 21:22:08 +08:00
Xavier Del Campo
8684814e09
strftime: Add support for the %T specifier
2022-10-26 00:54:59 +08:00
Xavier Del Campo
097faac22f
strftime: Add support for the %R specifier
2022-10-26 00:54:59 +08:00
Fotis Panagiotopoulos
ec93385dfa
strftime: Added support for the %w format specifier.
2022-10-19 12:43:28 +08:00
Fotis Panagiotopoulos
f9fd53cda1
gmtimer: Fixed range of tm_yday.
2022-10-19 12:39:04 +08:00
dongjiuzhu1
55106685fa
libc/localtime: Update to consistent with mainline
...
https://github.com/eggert/tz
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-19 10:27:52 +08:00
dongjiuzhu1
7b2371f0ed
libc/localtime: fix timegm return error when tz with isdst
...
testcase:
set TZ CEST
time_t t = time(NULL);
struct tm *ts = localtime(&t);
t = timegm(ts);
t will return (time_t)-1;
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-19 10:27:52 +08:00
Jiuzhu Dong
1b9ed5725b
libc/time: Return failed when lock is already held to avoid deadlock
...
when enable LIBC_LOCALTIME and SYSLOG_TIMESTAMP_LOCALTIME
and zoneinfo/posixrulesi isn't exist
[ EMERG] [ap] backtrace:
[ EMERG] [ap] [20] [<0xc1cc3c4>] arm_switchcontext+0xc/0x10
[ EMERG] [ap] [20] [<0xc1ac67a>] sem_wait+0x5a/0xc0
[ EMERG] [ap] [20] [<0xc1c4588>] tzset.part.0+0x8/0x160
[ EMERG] [ap] [20] [<0xc1c58de>] localtime_r+0xc6/0x114
[ EMERG] [ap] [20] [<0xc1a910a>] clock_gettime+0x16/0xa8
[ EMERG] [ap] [20] [<0xc1b7622>] nx_vsyslog+0x9e/0xc0
[ EMERG] [ap] [20] [<0xc4ba7e0>] romfs_stat+0xa4/0xf4
[ EMERG] [ap] [20] [<0xc4b47bc>] inode_semtake+0x24/0x5c
[ EMERG] [ap] [20] [<0xc1c0102>] bsearch+0x26/0x6c
[ EMERG] [ap] [20] [<0xc1c265a>] vsyslog+0x16/0x24
[ EMERG] [ap] [20] [<0xc1c2676>] syslog+0xe/0x1c
[ EMERG] [ap] [20] [<0xc4bae12>] romfs_open+0xee/0x178 <--- err log
[ EMERG] [ap] [20] [<0xc4b68ae>] file_vopen+0x116/0x144
[ EMERG] [ap] [20] [<0xc4b6ac8>] open+0x20/0x60
[ EMERG] [ap] [20] [<0xc1c3df4>] tzload+0x84/0x810
[ EMERG] [ap] [20] [<0xc1c6ef4>] mm_zalloc+0x10/0x18
[ EMERG] [ap] [20] [<0xc4bb426>] romfs_checkmount+0x22/0x58
[ EMERG] [ap] [20] [<0xc4bad74>] romfs_open+0x50/0x178
[ EMERG] [ap] [20] [<0xc1c392c>] tzparse+0x2c/0x470
[ EMERG] [ap] [20] [<0xc1ac5da>] nxsem_wait_uninterruptible+0x8a/0xd0
[ EMERG] [ap] [20] [<0xc1ac690>] sem_wait+0x70/0xc0
[ EMERG] [ap] [20] [<0xc4b47bc>] inode_semtake+0x24/0x5c
[ EMERG] [ap] [20] [<0xc4b481c>] inode_semgive+0x28/0x58
[ EMERG] [ap] [20] [<0xc4b58b4>] file_close+0x18/0x44
[ EMERG] [ap] [20] [<0xc4b4690>] close+0x80/0xb4
[ EMERG] [ap] [20] [<0xc1c43f4>] tzload+0x684/0x810
[ EMERG] [ap] [20] [<0xc1c4616>] tzset.part.0+0x96/0x160
[ EMERG] [ap] [20] [<0xc1c58de>] localtime_r+0xc6/0x114
[ EMERG] [ap] [20] [<0xc1a910a>] clock_gettime+0x16/0xa8
[ EMERG] [ap] [20] [<0xc1ea692>] cmd_date+0x276/0x37c
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-19 10:27:52 +08:00
wangbowen6
8b84d19771
lib_localtime: gmtime_r should get right time in OS init process
...
Enable CONFIG_LIBC_LOCALTIME,CONFIG_RTC and CONFIG_SCHED_TICKLESS
In os clock init process, clock_initialize() --> ... -->
sim_rtc_rdtime() --> gmtime_r() --> gmtsub() --> return NULL
get the error rtctime.
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-10-19 10:27:52 +08:00
Jiuzhu Dong
0bff62e3e8
libc/time: don't take semaphore in idle task
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-10-19 10:27:52 +08:00
anjiahao
d1d46335df
Replace nxsem API when used as a lock with nxmutex API
...
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Xiang Xiao
bdeaea3742
Remove the unnessary empty line after label
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-30 17:54:56 +02:00
Junbo Zheng
74ab851ac4
nuttx/libs/libc/time: fix runtime error by UBSan
...
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2022-09-05 14:55:25 +08:00
Huang Qi
e4e3208180
Replace all strncpy with strlcpy for safety
...
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-08-25 13:38:36 +08:00
Nathan Hartman
1867bc2210
Fix compiler warnings (-Wunused-parameter) in various functions
...
Fixes the -Wunused-parameter warning in:
* group/group_signal.c: group_signal()
* irq/irq_unexpectedisr.c: irq_unexpected_isr()
* task/task_spawn.c: nxtask_spawn_proxy()
* timer/timer_getoverrun.c: timer_getoverrun()
* misc/dev_null.c: devnull_read(), devnull_write(), devnull_poll()
* misc/dev_zero.c: devzero_read(), devzero_write(), devzero_poll()
* syslog/syslog_channel.c: syslog_default_write()
* syslog/syslog_device.c: syslog_dev_flush()
* grp/lib_initgroups.c: initgroups()
* misc/lib_mknod.c: mknod()
* misc/lib_glob.c: ignore_err()
* pthread/pthread_barrierinit.c: pthread_barrier_init()
* pthread/pthread_atfork.c: pthread_atfork()
* semaphore/sem_init.c: nxsem_init()
* stream/lib_nullinstream.c: nullinstream_getc()
* stream/lib_nulloutstream.c: nulloutstream_putc()
* stream/lib_libnoflush.c: lib_noflush()
* stream/lib_libsnoflush.c: lib_snoflush()
* string/lib_strerror.c: strerror()
* time/lib_gettimeofday.c: gettimeofday()
* time/lib_settimeofday.c: settimeofday()
* unistd/lib_pathconf.c: fpathconf(), pathconf()
* unistd/lib_getrusage.c: getrusage()
* unistd/lib_setrlimit.c: setrlimit()
* unistd/lib_getrlimit.c: getrlimit()
* unistd/lib_setpriority.c: setpriority()
2022-07-12 11:42:34 +08:00