mirror of
https://github.com/apache/nuttx.git
synced 2026-10-09 23:35:47 +00:00
Since the alignment of the signal context is affected by XCPTCONTEXT_SIZE in
different Kconfig, sometimes the stack pointer is not aligned to 8 bytes, this
is not what the software and compiler expect, for example, if va_list() obtains
wide data of type long long, the offset will be wrong, So in this commit, we set
stack-aligned the base offset so that the correct offset will be set during context
restoration.
1. test code:
| void signal_handler(int signo, siginfo_t *info, void *context) {
| long long ttt = 1024000;
| printf("%lld\n", ttt);
| }
|
| struct itimerspec its = { .it_value.tv_sec = 1,
| .it_value.tv_nsec = 0,
| .it_interval.tv_sec = 1,
| .it_interval.tv_nsec = 0
| };
|
| int main(int argc, FAR char *argv[])
| {
| struct sigevent evp;
| timer_t timer_id;
|
| memset(&evp, 0, sizeof(evp));
| evp.sigev_notify = SIGEV_SIGNAL | SIGEV_THREAD_ID;
| evp.sigev_signo = SIGALRM;
| evp.sigev_notify_thread_id = gettid();
|
| timer_create(CLOCK_REALTIME, &evp, &timer_id);
|
|
| struct sigaction sa;
| memset(&sa, 0, sizeof(sa));
| sa.sa_sigaction = signal_handler;
| sa.sa_flags = SA_SIGINFO;
| sigemptyset(&sa.sa_mask);
|
| sigaction(SIGALRM, &sa, NULL);
|
| timer_settime(timer_id, 0, &its, NULL);
|
| while (1)
| sleep(1);
|
| return 0;
| }
2. before this change:
| NuttShell (NSH) NuttX-12.10.0
| nsh> hello
| 4398046527890440
| 4398046527890472
| 4398046527890504
| 4398046527890536
3. after this change:
| NuttShell (NSH) NuttX-12.10.0
| nsh> hello
| 1024000
| 1024000
| 1024000
| 1024000
Signed-off-by: chao an <anchao.archer@bytedance.com>
|
||
|---|---|---|
| .. | ||
| arm_busfault.c | ||
| arm_cache.c | ||
| arm_cpuinfo.c | ||
| arm_dbgmonitor.c | ||
| arm_doirq.c | ||
| arm_dumpnvic.c | ||
| arm_exception.S | ||
| arm_fpucmp.c | ||
| arm_fpuconfig.c | ||
| arm_gen_nonsecfault.c | ||
| arm_hardfault.c | ||
| arm_initialstate.c | ||
| arm_itm.c | ||
| arm_itm_syslog.c | ||
| arm_memfault.c | ||
| arm_mpu.c | ||
| arm_perf.c | ||
| arm_ramvec_attach.c | ||
| arm_ramvec_initialize.c | ||
| arm_sau.c | ||
| arm_saveusercontext.S | ||
| arm_schedulesigaction.c | ||
| arm_secure_irq.c | ||
| arm_securefault.c | ||
| arm_sigdeliver.c | ||
| arm_stackcheck.c | ||
| arm_svcall.c | ||
| arm_systemreset.c | ||
| arm_systick.c | ||
| arm_tcbinfo.c | ||
| arm_trigger_irq.c | ||
| arm_usagefault.c | ||
| arm_vectors.c | ||
| CMakeLists.txt | ||
| dwt.h | ||
| etm.h | ||
| exc_return.h | ||
| fpb.h | ||
| itm.h | ||
| itm_syslog.h | ||
| Kconfig | ||
| Make.defs | ||
| mpu.h | ||
| nvic.h | ||
| pmu.h | ||
| psr.h | ||
| ram_vectors.h | ||
| sau.h | ||
| systick.h | ||
| Toolchain.defs | ||
| tpi.h | ||