"The number of characters written if successful or negative value if an error occurred.
If the resulting string gets truncated due to buf_size limit, function returns the total
number of characters (not including the terminating null-byte) which would have been written,
if the limit was not imposed." --- https://en.cppreference.com/w/c/io/vfprintf
Signed-off-by: jihandong <jihandong@xiaomi.com>
solve:
almost the Hexadecimal string string->float
such as:
code:float num;
const char *s= "0x123p32lala";
char *p;
num=strtof(s,&p);
printf("num is %f\n",num);
printf("str is %s\n",p);
output:num is 1249835483136.000000
str is lala
but if the input number is much big;
like:
code:const char *s2= "0x999999p100";
num=strtof(s2,&p);
printf("num is %f\n",num);
printf("str is %s\n",p);
corrent : num is 12760587998944832242938906880669384704.000000
real: num is 12760587998944800000000000000000000000.000000
it didn't have enough precision
such as code: double value = +0x1.000000000000080000000000p-600;
printf("Hello, World!! %.7g:f64\n", value);
expected output : Hello, World!! 2.40992e-181:f64
but real output : Hello, World!! 2.40992e-B1:f64
the reason: we want printf "18", but the flag of character is 'B'
and 'B' is '0'+18,so printf 'B';
In order to turn longjmp context-switch safe, it's necessary
to disable interrupts before modifying windowbase and windowstart.
Otherwise, after a context switch, windowstart and windowbase
would be different, leading to a wrongly set windowstart bit due to
longjmp writing it based on the windowbase before the context switch.
This corrupts the registers at the next window overflow reaching
that wrongly set bit.
*Background:*
This PR is related to an issue first observed on ESP-IDF
https://github.com/espressif/esp-idf/issues/5229 and it was, then,
checked on NuttX using a test application.
*The test application:*
To check if the problem affects ESP32, ESP32-S2 and ESP32-S3 on
NuttX, it was created an application based on:
https://en.cppreference.com/w/c/program/longjmp
The application creates 16 tasks (`#define NUMBER_OF_TASKS 16`)
that implements the following daemon:
```
static int setjmp_longjmp_daemon(int argc, char *argv[])
{
for (int i = 0; i < NUMBER_OF_TASKS * 2; i++)
{
jmp_buf env;
volatile int count = 0;
if (setjmp(env) != UINT16_MAX)
{
foo(&env, ++count);
}
}
sem_post(&g_sem);
return EXIT_SUCCESS;
}
```
The main function also initializes a semaphore to avoid application
exiting before tasks return successfully:
```
sem_init(&g_sem, 0, -NUMBER_OF_TASKS);
```
Finally, the round-robin interval was lowered to 1ms to raise the
chances of the longjmp being interrupted by a context switch
(`CONFIG_RR_INTERVAL=1).
This setup was able to reproduce the problem prior to this patch
being applied.
When a7 curl calls dns_query via usrsock, it will wait a usrsock
response with the dns lock held. If a7 rptun recv a dns_addnameserver
event from another core at this time, rptun waits the lock held by
curl in callback. Then curl will never get its usrsock response with
rptun blocked, so the deadlock occurs.
This change will break lock when do usrsock request.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
this is fix a ltp test case and update
the error code of pthread_barrierdestroy
ltptcase is : apps/testing/ltp/ltp/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_destroy/2-1.c
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
In the past, header file paths were generated by the incdir command
Now they are generated by concatenating environment variables
In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
In the past, predefined macros were generated by define.sh scripts
Now they are generated by concatenating environment variables
In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
instead of lib_psa_[get|set]stackaddr.c since the later doesn't exist in kernel mode
regression by:
commit b9b032af72
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Thu Oct 20 03:10:23 2022 +0800
sched/spawn: Support task_spawnattr_[set|get]stacksize in kernel mode
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
modify the return value according to posix standard
------------
SCHED_GET_PRIORITY_MAX(2)
NAME
sched_get_priority_max, sched_get_priority_min - get static priority range
RETURN VALUE
On success, sched_get_priority_max() and sched_get_priority_min() return the
maximum/minimum priority value for the named scheduling policy.
On error, -1 is returned, and errno is set appropriately.
ERRORS
EINVAL The argument policy does not identify a defined scheduling policy.
Signed-off-by: chao an <anchao@xiaomi.com>