diff --git a/TODO b/TODO index 5daf8438fe9..0965b445f91 100644 --- a/TODO +++ b/TODO @@ -177,9 +177,9 @@ o Task/Scheduler (sched/) Description: In NuttX, the errno value is unique for each thread. But for bug-for-bug compatibility, the same errno should be shared by the task and each thread that it creates. It is *very* easy - to make this change: Just move the pterrno field from - struct tcb_s to struct task_group_s. However, I am still not - sure if this should be done or not. + to make this change: Just move the tls_errno field from + struct tls_info_s to struct task_group_s. However, I am still + not sure if this should be done or not. NOTE: glibc behaves this way unless __thread is defined then, in that case, it behaves like NuttX (using TLS to save the thread local errno). @@ -1029,7 +1029,7 @@ o Kernel/Protected Build would not be an issue in the more general case. Update: - One solution might be to used CONFIG_TLS, add the PID to struct + One solution might be to use TLS, add the PID to struct tls_info_s. Then the PID could be obtained without a system call. TLS is not very useful in the FLAT build, however. TLS works by putting per-thread data at the bottom of an aligned stack. The diff --git a/arch/Kconfig b/arch/Kconfig index 3c2000e6ccb..d157c4d6637 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -10,7 +10,6 @@ choice config ARCH_ARM bool "ARM" select ARCH_HAVE_INTERRUPTSTACK - select ARCH_HAVE_TLS select ARCH_HAVE_VFORK select ARCH_HAVE_STACKCHECK select ARCH_HAVE_CUSTOMOPT @@ -68,7 +67,6 @@ config ARCH_SIM bool "Simulation" select ARCH_HAVE_MULTICPU select ARCH_HAVE_RTC_SUBSECONDS - select ARCH_HAVE_TLS select ARCH_HAVE_TICKLESS select ARCH_HAVE_POWEROFF select ARCH_HAVE_TESTSET diff --git a/arch/arm/include/tls.h b/arch/arm/include/tls.h index 49c5045415a..c6d86fd2242 100644 --- a/arch/arm/include/tls.h +++ b/arch/arm/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -92,5 +90,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_ARM_INCLUDE_TLS_H */ diff --git a/arch/arm/src/arm/arm_sigdeliver.c b/arch/arm/src/arm/arm_sigdeliver.c index 6d50b06dc85..af9d47e25c3 100644 --- a/arch/arm/src/arm/arm_sigdeliver.c +++ b/arch/arm/src/arm/arm_sigdeliver.c @@ -1,36 +1,20 @@ /**************************************************************************** * arch/arm/src/arm/arm_sigdeliver.c * - * Copyright (C) 2007-2010, 2015, 2018-2019 Gregory Nutt. All rights - * reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -77,7 +61,7 @@ void arm_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -108,7 +92,7 @@ void arm_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/arm/src/armv6-m/arm_sigdeliver.c b/arch/arm/src/armv6-m/arm_sigdeliver.c index 0d010ea460f..4fc1fc5f3fd 100644 --- a/arch/arm/src/armv6-m/arm_sigdeliver.c +++ b/arch/arm/src/armv6-m/arm_sigdeliver.c @@ -81,7 +81,7 @@ void arm_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -112,7 +112,7 @@ void arm_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/arm/src/armv7-a/arm_sigdeliver.c b/arch/arm/src/armv7-a/arm_sigdeliver.c index b0c240ed722..8ceef66fd04 100644 --- a/arch/arm/src/armv7-a/arm_sigdeliver.c +++ b/arch/arm/src/armv7-a/arm_sigdeliver.c @@ -1,36 +1,20 @@ /**************************************************************************** * arch/arm/src/armv7-a/arm_sigdeliver.c * - * Copyright (C) 2013, 2015-2016, 2018-2019 Gregory Nutt. All rights - * reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -77,7 +61,7 @@ void arm_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); #ifdef CONFIG_SMP /* In the SMP case, we must terminate the critical section while the signal @@ -159,7 +143,7 @@ void arm_sigdeliver(void) /* Restore the saved errno value */ - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/arm/src/armv7-m/arm_sigdeliver.c b/arch/arm/src/armv7-m/arm_sigdeliver.c index 3fae5e80dce..d62743dae54 100644 --- a/arch/arm/src/armv7-m/arm_sigdeliver.c +++ b/arch/arm/src/armv7-m/arm_sigdeliver.c @@ -61,7 +61,7 @@ void arm_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); #ifdef CONFIG_SMP /* In the SMP case, we must terminate the critical section while the signal @@ -147,7 +147,7 @@ void arm_sigdeliver(void) /* Restore the saved errno value */ - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/arm/src/armv7-r/arm_sigdeliver.c b/arch/arm/src/armv7-r/arm_sigdeliver.c index 46ef7c6f35b..e361ca3cef7 100644 --- a/arch/arm/src/armv7-r/arm_sigdeliver.c +++ b/arch/arm/src/armv7-r/arm_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/arm/src/armv7-r/arm_sigdeliver.c * - * Copyright (C) 2015, 2018-2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -76,7 +61,7 @@ void arm_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -107,7 +92,7 @@ void arm_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/arm/src/armv8-m/arm_sigdeliver.c b/arch/arm/src/armv8-m/arm_sigdeliver.c index d0a764fec4a..88b7f71712d 100755 --- a/arch/arm/src/armv8-m/arm_sigdeliver.c +++ b/arch/arm/src/armv8-m/arm_sigdeliver.c @@ -61,7 +61,7 @@ void arm_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); #ifdef CONFIG_SMP /* In the SMP case, we must terminate the critical section while the signal @@ -147,7 +147,7 @@ void arm_sigdeliver(void) /* Restore the saved errno value */ - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/arm/src/common/arm_checkstack.c b/arch/arm/src/common/arm_checkstack.c index 5ac36fd06e2..ebdab95e914 100644 --- a/arch/arm/src/common/arm_checkstack.c +++ b/arch/arm/src/common/arm_checkstack.c @@ -108,6 +108,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) UNUSED(int_stack); start = alloc & ~3; #endif + end = (alloc + size + 3) & ~3; /* Get the adjusted size based on the top and bottom of the stack */ diff --git a/arch/arm/src/common/arm_createstack.c b/arch/arm/src/common/arm_createstack.c index 62195ddbc8c..94a5855154b 100644 --- a/arch/arm/src/common/arm_createstack.c +++ b/arch/arm/src/common/arm_createstack.c @@ -102,7 +102,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -117,7 +116,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -190,7 +188,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) if (tcb->stack_alloc_ptr) { -#if defined(CONFIG_TLS) && defined(CONFIG_STACK_COLORATION) +#if defined(CONFIG_STACK_COLORATION) uintptr_t stack_base; #endif size_t top_of_stack; @@ -224,7 +222,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); @@ -242,17 +239,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) arm_stack_color((FAR void *)stack_base, stack_size); #endif /* CONFIG_STACK_COLORATION */ -#else /* CONFIG_TLS */ -#ifdef CONFIG_STACK_COLORATION - /* If stack debug is enabled, then fill the stack with a - * recognizable value that we can use later to test for high - * water marks. - */ - - arm_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size); - -#endif /* CONFIG_STACK_COLORATION */ -#endif /* CONFIG_TLS */ board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/arm/src/common/arm_usestack.c b/arch/arm/src/common/arm_usestack.c index 7aee3e83102..9605ffa38f8 100644 --- a/arch/arm/src/common/arm_usestack.c +++ b/arch/arm/src/common/arm_usestack.c @@ -137,24 +137,18 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif #ifdef CONFIG_STACK_COLORATION /* If stack debug is enabled, then fill the stack with a recognizable * value that we can use later to test for high water marks. */ -#ifdef CONFIG_TLS arm_stack_color((FAR void *)((uintptr_t)tcb->stack_alloc_ptr + sizeof(struct tls_info_s)), tcb->adj_stack_size - sizeof(struct tls_info_s)); -#else - arm_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size); -#endif #endif return OK; diff --git a/arch/avr/include/tls.h b/arch/avr/include/tls.h index 06ed9f3fad7..b308f779251 100644 --- a/arch/avr/include/tls.h +++ b/arch/avr/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -74,5 +72,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_AVR_INCLUDE_TLS_H */ diff --git a/arch/avr/src/avr/up_createstack.c b/arch/avr/src/avr/up_createstack.c index 859cb422e49..b29e1860e4b 100644 --- a/arch/avr/src/avr/up_createstack.c +++ b/arch/avr/src/avr/up_createstack.c @@ -101,7 +101,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -116,7 +115,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -139,6 +137,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. * If TLS is enabled, then we must allocate aligned stacks. */ + #ifdef CONFIG_TLS_ALIGNED #ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ @@ -212,11 +211,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (FAR void *)top_of_stack; tcb->adj_stack_size = stack_size; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif #if defined(ARCH_HAVE_LEDS) board_autoled_on(LED_STACKCREATED); diff --git a/arch/avr/src/avr/up_sigdeliver.c b/arch/avr/src/avr/up_sigdeliver.c index 9a14f11c1ae..713bbb52d61 100644 --- a/arch/avr/src/avr/up_sigdeliver.c +++ b/arch/avr/src/avr/up_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/avr/src/avr/up_sigdeliver.c * - * Copyright (C) 2011, 2015, 2018-2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -72,10 +57,11 @@ void up_sigdeliver(void) uint8_t regs[XCPTCONTEXT_REGS]; /* Save the errno. This must be preserved throughout the signal handling - * so that the user code final gets the correct errno value (probably EINTR). + * so that the user code final gets the correct errno value (probably + * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -106,7 +92,7 @@ void up_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is @@ -130,17 +116,18 @@ void up_sigdeliver(void) * unusual case that must be handled by up_fullcontextresore. This case is * unusual in two ways: * - * 1. It is not a context switch between threads. Rather, up_fullcontextrestore - * must behave more it more like a longjmp within the same task, using - * he same stack. + * 1. It is not a context switch between threads. Rather, + * up_fullcontextrestore must behave more it more like a longjmp + * within the same task, using the same stack. * 2. In this case, up_fullcontextrestore is called with r12 pointing to * a register save area on the stack to be destroyed. This is * dangerous because there is the very real possibility that the new - * stack pointer might overlap with the register save area and hat stack - * usage in up_fullcontextrestore might corrupt the register save data - * before the state is restored. At present, there does not appear to - * be any stack overlap problems. If there were, then adding 3 words - * to the size of register save structure size will protect its contents. + * stack pointer might overlap with the register save area and that + * stack usage in up_fullcontextrestore might corrupt the register + * save data before the state is restored. At present, there does + * not appear to be any stack overlap problems. If there were, then + * adding 3 words to the size of register save structure size will + * protect its contents. */ board_autoled_off(LED_SIGNAL); diff --git a/arch/avr/src/avr/up_usestack.c b/arch/avr/src/avr/up_usestack.c index 03d741d6098..c55279b35f9 100644 --- a/arch/avr/src/avr/up_usestack.c +++ b/arch/avr/src/avr/up_usestack.c @@ -135,11 +135,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (FAR void *)top_of_stack; tcb->adj_stack_size = stack_size; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/avr/src/avr32/up_createstack.c b/arch/avr/src/avr32/up_createstack.c index 8c6aba82d89..e5f6b041bfa 100644 --- a/arch/avr/src/avr32/up_createstack.c +++ b/arch/avr/src/avr32/up_createstack.c @@ -106,7 +106,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -121,7 +120,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -226,11 +224,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (FAR void *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/avr/src/avr32/up_sigdeliver.c b/arch/avr/src/avr32/up_sigdeliver.c index b024e3e7fcf..f6681dbded2 100644 --- a/arch/avr/src/avr32/up_sigdeliver.c +++ b/arch/avr/src/avr32/up_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/avr/src/avr32/up_sigdeliver.c * - * Copyright (C) 2010, 2015, 2018-2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -70,16 +55,17 @@ void up_sigdeliver(void) { struct tcb_s *rtcb = this_task(); #if 0 - uint32_t regs[XCPTCONTEXT_REGS+3]; /* Why +3? See below */ + uint32_t regs[XCPTCONTEXT_REGS + 3]; /* Why +3? See below */ #else uint32_t regs[XCPTCONTEXT_REGS]; #endif /* Save the errno. This must be preserved throughout the signal handling - * so that the user code final gets the correct errno value (probably EINTR). + * so that the user code final gets the correct errno value (probably + * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -110,7 +96,7 @@ void up_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is @@ -130,17 +116,18 @@ void up_sigdeliver(void) * unusual case that must be handled by up_fullcontextresore. This case is * unusual in two ways: * - * 1. It is not a context switch between threads. Rather, up_fullcontextrestore - * must behave more it more like a longjmp within the same task, using - * he same stack. + * 1. It is not a context switch between threads. Rather, + * up_fullcontextrestore must behave more it more like a longjmp + * within the same task, using the same stack. * 2. In this case, up_fullcontextrestore is called with r12 pointing to * a register save area on the stack to be destroyed. This is * dangerous because there is the very real possibility that the new - * stack pointer might overlap with the register save area and hat stack - * usage in up_fullcontextrestore might corrupt the register save data - * before the state is restored. At present, there does not appear to - * be any stack overlap problems. If there were, then adding 3 words - * to the size of register save structure size will protect its contents. + * stack pointer might overlap with the register save area and that + * stack usage in up_fullcontextrestore might corrupt the register + * save data before the state is restored. At present, there does + * not appear to be any stack overlap problems. If there were, then + * adding 3 words to the size of register save structure size will + * protect its contents. */ board_autoled_off(LED_SIGNAL); diff --git a/arch/avr/src/avr32/up_usestack.c b/arch/avr/src/avr32/up_usestack.c index 8a4986cf1f9..7e33fe33663 100644 --- a/arch/avr/src/avr32/up_usestack.c +++ b/arch/avr/src/avr32/up_usestack.c @@ -144,11 +144,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (FAR void *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/hc/include/tls.h b/arch/hc/include/tls.h index a8a5bf6f012..a390f0b8c4a 100644 --- a/arch/hc/include/tls.h +++ b/arch/hc/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -89,5 +87,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_HC_INCLUDE_TLS_H */ diff --git a/arch/hc/src/common/up_createstack.c b/arch/hc/src/common/up_createstack.c index 5496859d053..8af9b4af394 100644 --- a/arch/hc/src/common/up_createstack.c +++ b/arch/hc/src/common/up_createstack.c @@ -103,7 +103,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -118,7 +117,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -225,11 +223,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/hc/src/common/up_usestack.c b/arch/hc/src/common/up_usestack.c index d3d58368d59..551aa7fade3 100644 --- a/arch/hc/src/common/up_usestack.c +++ b/arch/hc/src/common/up_usestack.c @@ -135,11 +135,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/mips/include/tls.h b/arch/mips/include/tls.h index bd88d26efe2..d29c0a06cd7 100644 --- a/arch/mips/include/tls.h +++ b/arch/mips/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -89,5 +87,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_MIPS_INCLUDE_TLS_H */ diff --git a/arch/mips/src/common/mips_createstack.c b/arch/mips/src/common/mips_createstack.c index bc57aba1f01..cfc6f9be1e8 100644 --- a/arch/mips/src/common/mips_createstack.c +++ b/arch/mips/src/common/mips_createstack.c @@ -124,7 +124,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -139,7 +138,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -252,11 +250,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/mips/src/common/mips_usestack.c b/arch/mips/src/common/mips_usestack.c index dc52292c29f..246783c182a 100644 --- a/arch/mips/src/common/mips_usestack.c +++ b/arch/mips/src/common/mips_usestack.c @@ -161,11 +161,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/mips/src/mips32/mips_sigdeliver.c b/arch/mips/src/mips32/mips_sigdeliver.c index 12437367d4c..ddf74779c64 100644 --- a/arch/mips/src/mips32/mips_sigdeliver.c +++ b/arch/mips/src/mips32/mips_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/mips/src/mips32/mips_sigdeliver.c * - * Copyright (C) 2011, 2015, 2018-2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -77,7 +62,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -110,7 +95,7 @@ void up_sigdeliver(void) regs[REG_EPC], regs[REG_STATUS]); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/misoc/include/tls.h b/arch/misoc/include/tls.h index 4b093eab724..3fc95a143f4 100644 --- a/arch/misoc/include/tls.h +++ b/arch/misoc/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -87,5 +85,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_MISOC_INCLUDE_TLS_H */ diff --git a/arch/misoc/src/lm32/lm32_createstack.c b/arch/misoc/src/lm32/lm32_createstack.c index 6071440fba6..f4bb62a7cf3 100644 --- a/arch/misoc/src/lm32/lm32_createstack.c +++ b/arch/misoc/src/lm32/lm32_createstack.c @@ -124,7 +124,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -139,7 +138,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -245,11 +243,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (FAR uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/misoc/src/lm32/lm32_sigdeliver.c b/arch/misoc/src/lm32/lm32_sigdeliver.c index f32bdbf2c11..7912a9c2542 100644 --- a/arch/misoc/src/lm32/lm32_sigdeliver.c +++ b/arch/misoc/src/lm32/lm32_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/misoc/src/lm32/lm32_sigdeliver.c * - * Copyright (C) 2016, 2018-2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -76,7 +61,7 @@ void lm32_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -105,10 +90,11 @@ void lm32_sigdeliver(void) * errno that is needed by the user logic (it is probably EINTR). */ - sinfo("Resuming EPC: %08x INT_CTX: %08x\n", regs[REG_EPC], regs[REG_INT_CTX]); + sinfo("Resuming EPC: %08x INT_CTX: %08x\n", + regs[REG_EPC], regs[REG_INT_CTX]); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/misoc/src/minerva/minerva_createstack.c b/arch/misoc/src/minerva/minerva_createstack.c index b493de14650..702c48377f2 100644 --- a/arch/misoc/src/minerva/minerva_createstack.c +++ b/arch/misoc/src/minerva/minerva_createstack.c @@ -116,7 +116,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -131,7 +130,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -238,11 +236,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (FAR uint32_t *) top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/misoc/src/minerva/minerva_sigdeliver.c b/arch/misoc/src/minerva/minerva_sigdeliver.c index 37c68fb8a3a..acf8f28a182 100644 --- a/arch/misoc/src/minerva/minerva_sigdeliver.c +++ b/arch/misoc/src/minerva/minerva_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/misoc/src/minerva/minerva_sigdeliver.c * - * Copyright (C) 2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -73,11 +58,12 @@ void minerva_sigdeliver(void) uint32_t regs[XCPTCONTEXT_REGS]; sig_deliver_t sigdeliver; - /* Save the errno. This must be preserved throughout the signal handling so - * that the user code final gets the correct errno value (probably EINTR). + /* Save the errno. This must be preserved throughout the signal handling + * so that the user code final gets the correct errno value (probably + * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -111,16 +97,16 @@ void minerva_sigdeliver(void) sigdeliver(rtcb); - /* Output any debug messages BEFORE restoring errno (because they may alter - * errno), then disable interrupts again and restore the original errno that - * is needed by the user logic (it is probably EINTR). + /* Output any debug messages BEFORE restoring errno (because they may + * alter errno), then disable interrupts again and restore the original + * errno that is needed by the user logic (it is probably EINTR). */ sinfo("Resuming EPC: %08x INT_CTX: %08x\n", regs[REG_CSR_MEPC], regs[REG_CSR_MSTATUS]); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Then restore the correct state for this thread of execution. */ diff --git a/arch/or1k/include/tls.h b/arch/or1k/include/tls.h index 1b8fd221682..85759e20c0f 100644 --- a/arch/or1k/include/tls.h +++ b/arch/or1k/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -91,5 +89,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_OR1K_INCLUDE_TLS_H */ diff --git a/arch/or1k/src/common/up_checkstack.c b/arch/or1k/src/common/up_checkstack.c index 506ec5e51ce..e6f4cd93269 100644 --- a/arch/or1k/src/common/up_checkstack.c +++ b/arch/or1k/src/common/up_checkstack.c @@ -97,7 +97,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) /* Get aligned addresses of the top and bottom of the stack */ -#ifdef CONFIG_TLS +#ifdef CONFIG_TLS_ALIGNED if (!int_stack) { /* Skip over the TLS data structure at the bottom of the stack */ @@ -113,6 +113,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) UNUSED(int_stack); start = alloc & ~3; #endif + end = (alloc + size + 3) & ~3; /* Get the adjusted size based on the top and bottom of the stack */ diff --git a/arch/or1k/src/common/up_createstack.c b/arch/or1k/src/common/up_createstack.c index ffa8d804a72..5ad1c92aba4 100644 --- a/arch/or1k/src/common/up_createstack.c +++ b/arch/or1k/src/common/up_createstack.c @@ -117,7 +117,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -132,7 +131,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -205,7 +203,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) if (tcb->stack_alloc_ptr) { -#if defined(CONFIG_TLS) && defined(CONFIG_STACK_COLORATION) +#if defined(CONFIG_STACK_COLORATION) uintptr_t stack_base; #endif size_t top_of_stack; @@ -220,7 +218,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); @@ -238,17 +235,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) up_stack_color((FAR void *)stack_base, stack_size); #endif /* CONFIG_STACK_COLORATION */ -#else /* CONFIG_TLS */ -#ifdef CONFIG_STACK_COLORATION - /* If stack debug is enabled, then fill the stack with a - * recognizable value that we can use later to test for high - * water marks. - */ - - up_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size); - -#endif /* CONFIG_STACK_COLORATION */ -#endif /* CONFIG_TLS */ board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/renesas/include/tls.h b/arch/renesas/include/tls.h index 8998cd8f696..97fd18ec3db 100644 --- a/arch/renesas/include/tls.h +++ b/arch/renesas/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -74,5 +72,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_RENESAS_INCLUDE_TLS_H */ diff --git a/arch/renesas/src/common/up_createstack.c b/arch/renesas/src/common/up_createstack.c index 88e672046c6..4b39bece57a 100644 --- a/arch/renesas/src/common/up_createstack.c +++ b/arch/renesas/src/common/up_createstack.c @@ -103,7 +103,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -118,7 +117,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -225,11 +223,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/renesas/src/common/up_usestack.c b/arch/renesas/src/common/up_usestack.c index f7525e8c186..8ada7ba8693 100644 --- a/arch/renesas/src/common/up_usestack.c +++ b/arch/renesas/src/common/up_usestack.c @@ -134,11 +134,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/renesas/src/m16c/m16c_sigdeliver.c b/arch/renesas/src/m16c/m16c_sigdeliver.c index 1616f0bae87..6b2ba268528 100644 --- a/arch/renesas/src/m16c/m16c_sigdeliver.c +++ b/arch/renesas/src/m16c/m16c_sigdeliver.c @@ -1,36 +1,20 @@ /**************************************************************************** * arch/renesas/src/m16c/m16c_sigdeliver.c * - * Copyright (C) 2009-2010, 2015, 2018-2019 Gregory Nutt. All rights - * reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -76,7 +60,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -107,7 +91,7 @@ void up_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/renesas/src/rx65n/rx65n_sigdeliver.c b/arch/renesas/src/rx65n/rx65n_sigdeliver.c index 862f97bb2ac..2b288dc72d9 100644 --- a/arch/renesas/src/rx65n/rx65n_sigdeliver.c +++ b/arch/renesas/src/rx65n/rx65n_sigdeliver.c @@ -77,7 +77,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -119,7 +119,7 @@ void up_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Then restore the correct state for this thread of * execution. diff --git a/arch/renesas/src/sh1/sh1_sigdeliver.c b/arch/renesas/src/sh1/sh1_sigdeliver.c index fdb6483b893..4b5fa6be221 100644 --- a/arch/renesas/src/sh1/sh1_sigdeliver.c +++ b/arch/renesas/src/sh1/sh1_sigdeliver.c @@ -1,36 +1,20 @@ /**************************************************************************** * arch/renesas/src/common/up_sigdeliver.c * - * Copyright (C) 2008-2010, 2015, 2018-2019 Gregory Nutt. All rights - * reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -76,7 +60,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -107,7 +91,7 @@ void up_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/risc-v/include/tls.h b/arch/risc-v/include/tls.h index 70afee99a57..a999b081483 100644 --- a/arch/risc-v/include/tls.h +++ b/arch/risc-v/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -74,5 +72,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_RISCV_INCLUDE_TLS_H */ diff --git a/arch/risc-v/src/common/riscv_checkstack.c b/arch/risc-v/src/common/riscv_checkstack.c index 3c87d674dc2..a8f28fa8db8 100644 --- a/arch/risc-v/src/common/riscv_checkstack.c +++ b/arch/risc-v/src/common/riscv_checkstack.c @@ -91,7 +91,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) /* Get aligned addresses of the top and bottom of the stack */ -#ifdef CONFIG_TLS +#ifdef CONFIG_TLS_ALIGNED if (!int_stack) { /* Skip over the TLS data structure at the bottom of the stack */ @@ -107,6 +107,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack) UNUSED(int_stack); start = alloc & ~3; #endif + end = (alloc + size + 3) & ~3; /* Get the adjusted size based on the top and bottom of the stack */ diff --git a/arch/risc-v/src/common/riscv_createstack.c b/arch/risc-v/src/common/riscv_createstack.c index 472e097cf5a..318f7985328 100644 --- a/arch/risc-v/src/common/riscv_createstack.c +++ b/arch/risc-v/src/common/riscv_createstack.c @@ -124,7 +124,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -139,7 +138,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -212,7 +210,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) if (tcb->stack_alloc_ptr) { -#if defined(CONFIG_TLS) && defined(CONFIG_STACK_COLORATION) +#if defined(CONFIG_STACK_COLORATION) uintptr_t stack_base; #endif size_t top_of_stack; @@ -240,7 +238,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (FAR uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); @@ -255,19 +252,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) sizeof(struct tls_info_s); stack_size = tcb->adj_stack_size - sizeof(struct tls_info_s); - riscv_stack_color((FAR void *)stack_base, stack_size); + up_stack_color((FAR void *)stack_base, stack_size); #endif /* CONFIG_STACK_COLORATION */ -#else /* CONFIG_TLS */ -#ifdef CONFIG_STACK_COLORATION - /* If stack debug is enabled, then fill the stack with a - * recognizable value that we can use later to test for high - * water marks. - */ - - up_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size); -#endif /* CONFIG_STACK_COLORATION */ -#endif /* CONFIG_TLS */ board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/risc-v/src/common/riscv_usestack.c b/arch/risc-v/src/common/riscv_usestack.c index 8da809d3356..a6e07d966fc 100644 --- a/arch/risc-v/src/common/riscv_usestack.c +++ b/arch/risc-v/src/common/riscv_usestack.c @@ -155,11 +155,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (uintptr_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/risc-v/src/rv32im/riscv_sigdeliver.c b/arch/risc-v/src/rv32im/riscv_sigdeliver.c index d1276bcacb0..c1b7ece650c 100644 --- a/arch/risc-v/src/rv32im/riscv_sigdeliver.c +++ b/arch/risc-v/src/rv32im/riscv_sigdeliver.c @@ -82,7 +82,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -115,7 +115,7 @@ void up_sigdeliver(void) regs[REG_EPC], regs[REG_INT_CTX]); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/risc-v/src/rv64gc/riscv_sigdeliver.c b/arch/risc-v/src/rv64gc/riscv_sigdeliver.c index 073647e293d..9f21dcc9aae 100644 --- a/arch/risc-v/src/rv64gc/riscv_sigdeliver.c +++ b/arch/risc-v/src/rv64gc/riscv_sigdeliver.c @@ -82,7 +82,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); #ifdef CONFIG_SMP /* In the SMP case, we must terminate the critical section while the signal @@ -162,7 +162,7 @@ void up_sigdeliver(void) /* Restore the saved errno value */ - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/sim/include/tls.h b/arch/sim/include/tls.h index 0576cbd2545..a6210691fff 100644 --- a/arch/sim/include/tls.h +++ b/arch/sim/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -73,5 +71,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_SIM_INCLUDE_TLS_H */ diff --git a/arch/sim/src/sim/up_createstack.c b/arch/sim/src/sim/up_createstack.c index 8a85f930872..c268e05469f 100644 --- a/arch/sim/src/sim/up_createstack.c +++ b/arch/sim/src/sim/up_createstack.c @@ -106,7 +106,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) FAR uint8_t *stack_alloc_ptr; int ret = ERROR; -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -121,7 +120,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Move up to next even word boundary if necessary */ @@ -133,15 +131,15 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) #ifdef CONFIG_TLS_ALIGNED stack_alloc_ptr = (FAR uint8_t *)kumm_memalign(TLS_STACK_ALIGN, adj_stack_size); -#else /* CONFIG_TLS */ +#else stack_alloc_ptr = (FAR uint8_t *)kumm_malloc(adj_stack_size); -#endif /* CONFIG_TLS */ +#endif /* Was the allocation successful? */ if (stack_alloc_ptr) { -#if defined(CONFIG_TLS) && defined(CONFIG_STACK_COLORATION) +#if defined(CONFIG_STACK_COLORATION) uintptr_t stack_base; #endif @@ -160,7 +158,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->stack_alloc_ptr = stack_alloc_ptr; tcb->adj_stack_ptr = (FAR void *)adj_stack_addr; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(stack_alloc_ptr, 0, sizeof(struct tls_info_s)); @@ -177,17 +174,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) up_stack_color((FAR void *)stack_base, stack_size); #endif /* CONFIG_STACK_COLORATION */ -#else /* CONFIG_TLS */ -#ifdef CONFIG_STACK_COLORATION - /* If stack debug is enabled, then fill the stack with a - * recognizable value that we can use later to test for high - * water marks. - */ - - up_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size); - -#endif /* CONFIG_STACK_COLORATION */ -#endif /* CONFIG_TLS */ ret = OK; } diff --git a/arch/sim/src/sim/up_usestack.c b/arch/sim/src/sim/up_usestack.c index 9325568af54..7174e2b945e 100644 --- a/arch/sim/src/sim/up_usestack.c +++ b/arch/sim/src/sim/up_usestack.c @@ -126,11 +126,9 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size) tcb->stack_alloc_ptr = stack; tcb->adj_stack_ptr = (FAR void *)adj_stack_addr; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(stack, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/x86/include/tls.h b/arch/x86/include/tls.h index fbec9a2ef1a..0298349cd1a 100644 --- a/arch/x86/include/tls.h +++ b/arch/x86/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -74,5 +72,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_X86_INCLUDE_TLS_H */ diff --git a/arch/x86/src/i486/up_createstack.c b/arch/x86/src/i486/up_createstack.c index 7e9a3081620..c629a835d8c 100644 --- a/arch/x86/src/i486/up_createstack.c +++ b/arch/x86/src/i486/up_createstack.c @@ -105,7 +105,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -120,7 +119,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -225,11 +223,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/x86/src/i486/up_sigdeliver.c b/arch/x86/src/i486/up_sigdeliver.c index fb6ad54df35..52e3b5d386c 100644 --- a/arch/x86/src/i486/up_sigdeliver.c +++ b/arch/x86/src/i486/up_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/x86/src/i486/up_sigdeliver.c * - * Copyright (C) 2011, 2015, 2018-2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -76,7 +61,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -107,7 +92,7 @@ void up_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/x86/src/i486/up_usestack.c b/arch/x86/src/i486/up_usestack.c index 347d48c9228..77e1e246b2d 100644 --- a/arch/x86/src/i486/up_usestack.c +++ b/arch/x86/src/i486/up_usestack.c @@ -134,11 +134,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/x86_64/include/tls.h b/arch/x86_64/include/tls.h index e9462abb865..51856b9c04b 100644 --- a/arch/x86_64/include/tls.h +++ b/arch/x86_64/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -74,5 +72,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_X86_64_INCLUDE_TLS_H */ diff --git a/arch/x86_64/src/intel64/up_createstack.c b/arch/x86_64/src/intel64/up_createstack.c index 4d23d8fc995..c0941712ddb 100644 --- a/arch/x86_64/src/intel64/up_createstack.c +++ b/arch/x86_64/src/intel64/up_createstack.c @@ -90,7 +90,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -105,7 +104,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -213,11 +211,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (uint64_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/x86_64/src/intel64/up_sigdeliver.c b/arch/x86_64/src/intel64/up_sigdeliver.c index dd7317810f3..4275ce31f06 100644 --- a/arch/x86_64/src/intel64/up_sigdeliver.c +++ b/arch/x86_64/src/intel64/up_sigdeliver.c @@ -81,7 +81,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); /* Save the real return state on the stack ASAP before any chance we went * sleeping and break the register profile. We entered this function with @@ -122,7 +122,7 @@ void up_sigdeliver(void) sinfo("Resuming\n"); (void)up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/x86_64/src/intel64/up_usestack.c b/arch/x86_64/src/intel64/up_usestack.c index dd5720f096a..0525c138170 100644 --- a/arch/x86_64/src/intel64/up_usestack.c +++ b/arch/x86_64/src/intel64/up_usestack.c @@ -122,11 +122,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (uint64_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/xtensa/include/tls.h b/arch/xtensa/include/tls.h index 33735ca9fcf..e351cf87c00 100644 --- a/arch/xtensa/include/tls.h +++ b/arch/xtensa/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -91,5 +89,4 @@ static inline FAR struct tls_info_s *up_tls_info(void) # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_XTENSA_INCLUDE_TLS_H */ diff --git a/arch/xtensa/src/common/xtensa_checkstack.c b/arch/xtensa/src/common/xtensa_checkstack.c index 7136a881a24..cbac16a0d25 100644 --- a/arch/xtensa/src/common/xtensa_checkstack.c +++ b/arch/xtensa/src/common/xtensa_checkstack.c @@ -91,7 +91,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) /* Get aligned addresses of the top and bottom of the stack */ -#ifdef CONFIG_TLS +#ifdef CONFIG_TLS_ALIGNED + /* Skip over the TLS data structure at the bottom of the stack */ DEBUGASSERT((alloc & TLS_STACK_MASK) == 0); @@ -99,6 +100,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size) #else start = alloc & ~3; #endif + end = (alloc + size + 3) & ~3; /* Get the adjusted size based on the top and bottom of the stack */ diff --git a/arch/xtensa/src/common/xtensa_createstack.c b/arch/xtensa/src/common/xtensa_createstack.c index 1166272074a..3f81596946b 100644 --- a/arch/xtensa/src/common/xtensa_createstack.c +++ b/arch/xtensa/src/common/xtensa_createstack.c @@ -121,7 +121,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) uintptr_t cpstart; #endif -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -136,7 +135,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -287,11 +285,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (FAR uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/xtensa/src/common/xtensa_sigdeliver.c b/arch/xtensa/src/common/xtensa_sigdeliver.c index 6a00b96eab8..3bc39984383 100644 --- a/arch/xtensa/src/common/xtensa_sigdeliver.c +++ b/arch/xtensa/src/common/xtensa_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/xtensa/src/common/xtensa_sigdeliver.c * - * Copyright (C) 2016, 2018-2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -75,7 +60,7 @@ void xtensa_sig_deliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); #ifdef CONFIG_SMP /* In the SMP case, we must terminate the critical section while the signal @@ -154,7 +139,7 @@ void xtensa_sig_deliver(void) /* Restore the saved errno value */ - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/xtensa/src/common/xtensa_usestack.c b/arch/xtensa/src/common/xtensa_usestack.c index 71fa7ba3e30..b40f0786d9d 100644 --- a/arch/xtensa/src/common/xtensa_usestack.c +++ b/arch/xtensa/src/common/xtensa_usestack.c @@ -147,11 +147,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/z16/include/tls.h b/arch/z16/include/tls.h index d2a1a16ecd1..be7de1dc9ef 100644 --- a/arch/z16/include/tls.h +++ b/arch/z16/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -70,5 +68,4 @@ # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_Z16_INCLUDE_TLS_H */ diff --git a/arch/z16/src/common/z16_createstack.c b/arch/z16/src/common/z16_createstack.c index e77edec04c4..c34f09ec0a0 100644 --- a/arch/z16/src/common/z16_createstack.c +++ b/arch/z16/src/common/z16_createstack.c @@ -84,7 +84,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -99,7 +98,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -204,11 +202,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/z16/src/common/z16_sigdeliver.c b/arch/z16/src/common/z16_sigdeliver.c index 4ca825470f8..2a91f25897f 100644 --- a/arch/z16/src/common/z16_sigdeliver.c +++ b/arch/z16/src/common/z16_sigdeliver.c @@ -61,7 +61,7 @@ void z16_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -92,7 +92,7 @@ void z16_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/z16/src/common/z16_usestack.c b/arch/z16/src/common/z16_usestack.c index 3ced8aa71fa..9b6d649ee02 100644 --- a/arch/z16/src/common/z16_usestack.c +++ b/arch/z16/src/common/z16_usestack.c @@ -119,11 +119,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_size = top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/z80/include/tls.h b/arch/z80/include/tls.h index 381a103c299..436976dddeb 100644 --- a/arch/z80/include/tls.h +++ b/arch/z80/include/tls.h @@ -30,8 +30,6 @@ #include #include -#ifdef CONFIG_TLS - /**************************************************************************** * Inline Functions ****************************************************************************/ @@ -70,5 +68,4 @@ # define up_tls_info() tls_get_info() #endif -#endif /* CONFIG_TLS */ #endif /* __ARCH_Z80_INCLUDE_TLS_H */ diff --git a/arch/z80/src/common/z80_createstack.c b/arch/z80/src/common/z80_createstack.c index 59ab44d890b..bf70d66011d 100644 --- a/arch/z80/src/common/z80_createstack.c +++ b/arch/z80/src/common/z80_createstack.c @@ -88,7 +88,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { -#ifdef CONFIG_TLS /* Add the size of the TLS information structure */ stack_size += sizeof(struct tls_info_s); @@ -103,7 +102,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) { stack_size = TLS_MAXSTACK; } -#endif #endif /* Is there already a stack allocated of a different size? Because of @@ -209,11 +207,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) tcb->adj_stack_ptr = (FAR uint32_t *)top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif board_autoled_on(LED_STACKCREATED); return OK; diff --git a/arch/z80/src/common/z80_usestack.c b/arch/z80/src/common/z80_usestack.c index 2e746c0d1e0..3168ecfb12d 100644 --- a/arch/z80/src/common/z80_usestack.c +++ b/arch/z80/src/common/z80_usestack.c @@ -118,11 +118,9 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size) tcb->adj_stack_size = top_of_stack; tcb->adj_stack_size = size_of_stack; -#ifdef CONFIG_TLS /* Initialize the TLS data structure */ memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s)); -#endif return OK; } diff --git a/arch/z80/src/ez80/ez80_sigdeliver.c b/arch/z80/src/ez80/ez80_sigdeliver.c index dc553ca698e..4f203a15e88 100644 --- a/arch/z80/src/ez80/ez80_sigdeliver.c +++ b/arch/z80/src/ez80/ez80_sigdeliver.c @@ -62,7 +62,7 @@ void z80_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -93,7 +93,7 @@ void z80_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/z80/src/z180/z180_sigdeliver.c b/arch/z80/src/z180/z180_sigdeliver.c index 678d8c6e33d..529d698d649 100644 --- a/arch/z80/src/z180/z180_sigdeliver.c +++ b/arch/z80/src/z180/z180_sigdeliver.c @@ -1,35 +1,20 @@ /**************************************************************************** * arch/z80/src/z180/z180_sigdeliver.c * - * Copyright (C) 2012, 2015, 2018-2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -74,7 +59,7 @@ void z80_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -105,7 +90,7 @@ void z80_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/z80/src/z8/z8_sigdeliver.c b/arch/z80/src/z8/z8_sigdeliver.c index 9e40e2c3942..1b01f249317 100644 --- a/arch/z80/src/z8/z8_sigdeliver.c +++ b/arch/z80/src/z8/z8_sigdeliver.c @@ -1,36 +1,20 @@ /**************************************************************************** * arch/z80/src/z8/z8_sigdeliver.c * - * Copyright (C) 2008-2010, 2015, 2018-2019 Gregory Nutt. All rights - * reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -94,7 +78,7 @@ void z80_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -125,7 +109,7 @@ void z80_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/arch/z80/src/z80/z80_sigdeliver.c b/arch/z80/src/z80/z80_sigdeliver.c index 3be2b5388b7..d3574c3c05e 100644 --- a/arch/z80/src/z80/z80_sigdeliver.c +++ b/arch/z80/src/z80/z80_sigdeliver.c @@ -1,36 +1,20 @@ /**************************************************************************** * arch/z80/src/z80/z80_sigdeliver.c * - * Copyright (C) 2007-2010, 2015, 2018-2019 Gregory Nutt. All rights - * reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -75,7 +59,7 @@ void z80_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->pterrno; + int saved_errno = get_errno(); board_autoled_on(LED_SIGNAL); @@ -106,7 +90,7 @@ void z80_sigdeliver(void) sinfo("Resuming\n"); up_irq_save(); - rtcb->pterrno = saved_errno; + set_errno(saved_errno); /* Modify the saved return state with the actual saved values in the * TCB. This depends on the fact that nested signal handling is diff --git a/include/errno.h b/include/errno.h index 76a1bc4d6c7..9caf44d60ab 100644 --- a/include/errno.h +++ b/include/errno.h @@ -1,35 +1,20 @@ /**************************************************************************** * include/errno.h * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -46,74 +31,21 @@ * Pre-processor Definitions ****************************************************************************/ -/* How can we access the errno variable? */ - -#ifdef CONFIG_BUILD_FLAT - /* Flat build */ - -# if defined(CONFIG_LIB_SYSCALL) && !defined(__KERNEL__) - /* We still might be using system calls in user code. If so, then - * user code will have no direct access to the errno variable. - */ - -# undef __DIRECT_ERRNO_ACCESS - -# else - /* Flat build with no system calls OR internal kernel logic... There - * is direct access. - */ - -# define __DIRECT_ERRNO_ACCESS 1 -# endif - -#else -# if defined(__KERNEL__) - /* Kernel portion of protected/kernel build. Kernel code has direct - * access - */ - -# define __DIRECT_ERRNO_ACCESS 1 - -# else - /* User portion of protected/kernel build. Application code has only - * indirect access - */ - -# undef __DIRECT_ERRNO_ACCESS -# endif -#endif - -/* Convenience/compatibility definition. - * - * For a flat, all kernel-mode build, the error can be read and written - * from all code using a simple pointer. +/* Convenience/compatibility definition. If the errno is accessed from the + * internal OS code, then the OS code should use the set_errno() and + * get_errno(). Currently, those are just placeholders but would be needed + * in the KERNEL mode build in order to instantiate the process address + * environment as necessary to access the TLS-based errno variable. */ -#ifdef __DIRECT_ERRNO_ACCESS - -# define errno *__errno() -# define set_errno(e) do { errno = (int)(e); } while (0) -# define get_errno() errno - -#else - -/* We doing separate user-/kernel-mode builds, then the errno has to be - * a little differently. In kernel-mode, the TCB errno value can still be - * read and written using a pointer from code executing within the - * kernel. - * - * But in user-mode, the errno can only be read using the name 'errno'. - * The non-standard API set_errno() must explicitly be used from user- - * mode code in order to set the errno value. - * - * The same is true of the case where we have syscalls enabled but this - * is not a kernel build, then we really have no option but to use the - * set_errno() accessor function explicitly, even from OS logic! - */ - -# define errno get_errno() - -#endif /* __DIRECT_ERRNO_ACCESS */ +#define errno *__errno() +#define set_errno(e) \ + do \ + { \ + errno = (int)(e); \ + } \ + while (0) +#define get_errno() errno /* Definitions of error numbers and the string that would be * returned by strerror(). @@ -398,21 +330,10 @@ extern "C" #define EXTERN extern #endif -/* Return a pointer to the thread specific errno. NOTE: When doing a - * kernel-/user-mode build, this function can only be used within the - * kernel-mode space. - * - * In the user-mode space, set_errno() and get_errno() are always available, - * either as macros or via syscalls. - */ +/* Return a pointer to the thread specific errno. */ FAR int *__errno(void); -#ifndef __DIRECT_ERRNO_ACCESS -void set_errno(int errcode); -int get_errno(void); -#endif - #undef EXTERN #if defined(__cplusplus) } diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 4551a10e0f3..53c6566450e 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -1695,14 +1695,12 @@ int up_timer_start(FAR const struct timespec *ts); * ****************************************************************************/ -#ifdef CONFIG_TLS /* struct tls_info_s; * FAR struct tls_info_s *up_tls_info(void); * * The actual declaration or definition is provided in arch/tls.h. The * actual implementation may be a MACRO or and inline function. */ -#endif /**************************************************************************** * Multiple CPU support diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index cc63e7cb3cc..37a40f81676 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -648,6 +648,7 @@ struct tcb_s #ifdef CONFIG_CANCELLATION_POINTS int16_t cpcount; /* Nested cancellation point count */ #endif + int16_t errcode; /* Used to pass error information */ #if CONFIG_RR_INTERVAL > 0 || defined(CONFIG_SCHED_SPORADIC) int32_t timeslice; /* RR timeslice OR Sporadic budget */ @@ -708,10 +709,6 @@ struct tcb_s uint32_t crit_max; /* Max time in critical section */ #endif - /* Library related fields *****************************************************/ - - int pterrno; /* Current per-thread errno */ - /* State save areas ***********************************************************/ /* The form and content of these fields are platform-specific. */ diff --git a/include/nuttx/tls.h b/include/nuttx/tls.h index ba7a0c9e879..7323a67a1a8 100644 --- a/include/nuttx/tls.h +++ b/include/nuttx/tls.h @@ -29,8 +29,6 @@ #include -#ifdef CONFIG_TLS - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -45,13 +43,7 @@ #ifndef CONFIG_TLS_NELEM # warning CONFIG_TLS_NELEM is not defined -# define CONFIG_TLS_NELEM 1 -#endif - -#if CONFIG_TLS_NELEM < 1 -# error CONFIG_TLS_NELEM must be at least one -# undef CONFIG_TLS_NELEM -# define CONFIG_TLS_NELEM 1 +# define CONFIG_TLS_NELEM 0 #endif /* TLS Definitions **********************************************************/ @@ -83,7 +75,10 @@ struct tls_info_s { +#if CONFIG_TLS_NELEM > 0 uintptr_t tl_elem[CONFIG_TLS_NELEM]; /* TLS elements */ +#endif + int tl_errno; /* Per-thread error number */ }; /**************************************************************************** @@ -148,5 +143,4 @@ void tls_set_element(int elem, uintptr_t value); FAR struct tls_info_s *tls_get_info(void); #endif -#endif /* CONFIG_TLS */ #endif /* __INCLUDE_NUTTX_TLS_H */ diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h index 851cae200b9..13ec91927ef 100644 --- a/include/sys/syscall_lookup.h +++ b/include/sys/syscall_lookup.h @@ -26,7 +26,6 @@ SYSCALL_LOOKUP1(_exit, 1) SYSCALL_LOOKUP(exit, 1) -SYSCALL_LOOKUP(get_errno, 0) SYSCALL_LOOKUP(getpid, 0) SYSCALL_LOOKUP(sched_getparam, 2) @@ -46,7 +45,6 @@ SYSCALL_LOOKUP(sched_get_stackinfo, 2) SYSCALL_LOOKUP(sched_setaffinity, 3) #endif -SYSCALL_LOOKUP(set_errno, 1) SYSCALL_LOOKUP(uname, 1) SYSCALL_LOOKUP(sethostname, 2) diff --git a/libs/libc/Makefile b/libs/libc/Makefile index 56a677b97dc..ee26f12cad6 100644 --- a/libs/libc/Makefile +++ b/libs/libc/Makefile @@ -1,35 +1,20 @@ ############################################################################ # libs/libc/Makefile # -# Copyright (C) 2007-2014, 2016-2017, 2019 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: +# http://www.apache.org/licenses/LICENSE-2.0 # -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. # ########################################################################### @@ -49,6 +34,7 @@ include builtin/Make.defs include dirent/Make.defs include dlfcn/Make.defs include endian/Make.defs +include errno/Make.defs include fixedmath/Make.defs include grp/Make.defs include hex2bin/Make.defs diff --git a/libs/libc/README.txt b/libs/libc/README.txt index 5c43c90b2fa..e7c12d90ce5 100644 --- a/libs/libc/README.txt +++ b/libs/libc/README.txt @@ -32,6 +32,7 @@ we have: builtin - Support for builtin applications. Used by nuttx/binfmt and NSH. dlfcn - dlfcn.h endian - endian.h + errno - errno.h hex2bin - hex2bin.h libgen - libgen.h locale - locale.h diff --git a/libs/libc/errno/Make.defs b/libs/libc/errno/Make.defs new file mode 100644 index 00000000000..405fe2c1c7c --- /dev/null +++ b/libs/libc/errno/Make.defs @@ -0,0 +1,26 @@ +############################################################################ +# libs/libc/errno/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +CSRCS += lib_errno.c + +# Include errno build support + +DEPPATH += --dep-path errno +VPATH += :errno diff --git a/libs/libc/errno/lib_errno.c b/libs/libc/errno/lib_errno.c new file mode 100644 index 00000000000..27f67dd0ba8 --- /dev/null +++ b/libs/libc/errno/lib_errno.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * sched/errno/lib_errno.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: __errno + * + * Description: + * Return a pointer to the thread specific errno. + * + * Input Parameters: + * None + * + * Returned Value: + * A pointer to the per-thread errno variable. + * + * Assumptions: + * + ****************************************************************************/ + +FAR int *__errno(void) +{ + /* Get the TLS tls_info_s structure instance for this thread */ + + FAR struct tls_info_s *tlsinfo = up_tls_info(); + + /* And return the return refernce to the error number */ + + return &tlsinfo->tl_errno; +} diff --git a/libs/libc/tls/Kconfig b/libs/libc/tls/Kconfig index 76b53adc764..b14abc4341a 100644 --- a/libs/libc/tls/Kconfig +++ b/libs/libc/tls/Kconfig @@ -3,23 +3,7 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -config ARCH_HAVE_TLS - bool - default n - ---help--- - Selected by the configuration system if the current architecture - supports TLS. - menu "Thread Local Storage (TLS)" - depends on ARCH_HAVE_TLS - -config TLS - bool "Thread Local Storage (TLS)" - default n - ---help--- - Build in support for stack based thread local storage (TLS). - -if TLS config TLS_ALIGNED bool "Require stack alignment" @@ -61,10 +45,12 @@ config TLS_LOG2_MAXSTACK config TLS_NELEM int "Number of TLS elements" - default 1 + default 0 ---help--- The number of unique TLS elements. These can be accessed with the user library functions tls_get_element() and tls_set_element(). -endif # TLS + NOTE that the special value of CONFIG_TLS_NELEM disables these + TLS interfaces. + endmenu # Thread Local Storage (TLS) diff --git a/libs/libc/tls/Make.defs b/libs/libc/tls/Make.defs index e2fbbfb8505..01fd70edcb8 100644 --- a/libs/libc/tls/Make.defs +++ b/libs/libc/tls/Make.defs @@ -18,9 +18,9 @@ # ############################################################################ -ifeq ($(CONFIG_TLS),y) - +ifneq ($(CONFIG_TLS_NELEM),0) CSRCS += tls_setelem.c tls_getelem.c +endif ifneq ($(CONFIG_TLS_ALIGNED),y) CSRCS += tls_getinfo.c @@ -31,4 +31,3 @@ endif DEPPATH += --dep-path tls VPATH += :tls -endif diff --git a/libs/libc/tls/tls_getelem.c b/libs/libc/tls/tls_getelem.c index cfa7cd62b4a..af03e220efe 100644 --- a/libs/libc/tls/tls_getelem.c +++ b/libs/libc/tls/tls_getelem.c @@ -31,7 +31,7 @@ #include #include -#ifdef CONFIG_TLS +#if CONFIG_TLS_NELEM > 0 /**************************************************************************** * Public Functions @@ -75,4 +75,4 @@ uintptr_t tls_get_element(int elem) return ret; } -#endif /* CONFIG_TLS */ +#endif /* CONFIG_TLS_NELEM > 0 */ diff --git a/libs/libc/tls/tls_getinfo.c b/libs/libc/tls/tls_getinfo.c index 72f1833a5b8..79a90705b20 100644 --- a/libs/libc/tls/tls_getinfo.c +++ b/libs/libc/tls/tls_getinfo.c @@ -60,8 +60,6 @@ FAR struct tls_info_s *tls_get_info(void) struct stackinfo_s stackinfo; int ret; - DEBUGASSERT(!up_interrupt_context()); - ret = sched_get_stackinfo(0, &stackinfo); if (ret >= 0) { diff --git a/libs/libc/tls/tls_setelem.c b/libs/libc/tls/tls_setelem.c index 67121c70cc9..6d301b89c65 100644 --- a/libs/libc/tls/tls_setelem.c +++ b/libs/libc/tls/tls_setelem.c @@ -31,7 +31,7 @@ #include #include -#ifdef CONFIG_TLS +#if CONFIG_TLS_NELEM > 0 /**************************************************************************** * Public Functions @@ -71,4 +71,4 @@ void tls_set_element(int elem, uintptr_t value) } } -#endif /* CONFIG_TLS */ +#endif /* CONFIG_TLS_NELEM > 0 */ diff --git a/sched/Makefile b/sched/Makefile index 63d1c519edd..f3543ddd948 100644 --- a/sched/Makefile +++ b/sched/Makefile @@ -1,35 +1,20 @@ ############################################################################ # sched/Makefile # -# Copyright (C) 2007-2014, 2016 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: +# http://www.apache.org/licenses/LICENSE-2.0 # -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. # ############################################################################ @@ -42,7 +27,6 @@ VPATH = DEPPATH = --dep-path . include clock/Make.defs -include errno/Make.defs include environ/Make.defs include group/Make.defs include init/Make.defs diff --git a/sched/errno/Make.defs b/sched/errno/Make.defs deleted file mode 100644 index 6c51ee2feff..00000000000 --- a/sched/errno/Make.defs +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# sched/errno/Make.defs -# -# Copyright (C) 2014 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -CSRCS += errno_errno.c - -ifeq ($(CONFIG_LIB_SYSCALL),y) -CSRCS += errno_get.c errno_set.c -endif - -# Include errno build support - -DEPPATH += --dep-path errno -VPATH += :errno diff --git a/sched/errno/errno_errno.c b/sched/errno/errno_errno.c deleted file mode 100644 index a262b5bfaf2..00000000000 --- a/sched/errno/errno_errno.c +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * sched/errno/errno_errno.c - * - * Copyright (C) 2007, 2008, 2011, 2014 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include -#include -#include "sched/sched.h" - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* This is a 'dummy' errno value to use in context where there is no valid - * errno location to use. For example, when running from an interrupt handler - * or early in initialization when task structures have not yet been - * initialized. - */ - -static int g_irqerrno; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: __errno - * - * Description: - * Return a pointer to the thread specific errno. - * - * Input Parameters: - * None - * - * Returned Value: - * A pointer to the per-thread errno variable. - * - * Assumptions: - * - ****************************************************************************/ - -FAR int *__errno(void) -{ - /* Check if this function was called from an interrupt handler. In that - * case, we have to do things a little differently to prevent the interrupt - * handler from modifying the tasks errno value. - */ - - if (!up_interrupt_context()) - { - /* We were called from the normal tasking context. Verify that the - * task at the head of the ready-to-run list is actually running. It - * may not be running during very brief times during context switching - * logic (see, for example, task_exit.c). - * - * There is also a corner case early in the initialization sequence: - * The ready to run list may not yet be initialized and this_task() - * may be NULL. - */ - - FAR struct tcb_s *rtcb = this_task(); - if (rtcb && rtcb->task_state == TSTATE_TASK_RUNNING) - { - /* Yes.. the task is running normally. Return a reference to the - * thread-private errno in the TCB of the running task. - */ - - return &rtcb->pterrno; - } - } - - /* We were called either from (1) an interrupt handler or (2) from normally - * code but in an unhealthy state. In either event, do not permit access to - * the errno in the TCB of the task at the head of the ready-to-run list. - * Instead, use a separate errno just for interrupt handlers. Of course, - * this would have to change if we ever wanted to support nested interrupts - * or if we really cared about the stability of the errno during those - * "unhealthy states." - */ - - return &g_irqerrno; -} diff --git a/sched/errno/errno_get.c b/sched/errno/errno_get.c deleted file mode 100644 index 2d91497e3da..00000000000 --- a/sched/errno/errno_get.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** - * sched/errno/errno_get.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#undef get_errno - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: get_errno - * - * Description: - * Return the value of the thread specific errno. This function is only - * intended to provide a mechanism for user-mode programs to get the - * thread-specific errno value. It is #define'd to the symbol errno in - * include/errno.h. - * - * Input Parameters: - * None - * - * Returned Value: - * The current value of the thread specific errno. - * - * Assumptions: - * - ****************************************************************************/ - -int get_errno(void) -{ - return *__errno(); -} diff --git a/sched/errno/errno_set.c b/sched/errno/errno_set.c deleted file mode 100644 index 2eada24b92a..00000000000 --- a/sched/errno/errno_set.c +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** - * sched/errno/errno_set.c - * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#undef set_errno - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: set_errno - * - * Description: - * Set the value of the thread specific errno. This function is only - * intended to provide a mechanism for user-mode programs to set the - * thread-specific errno value. - * - * Input Parameters: - * errcode - The thread specific errno will be set to this value. - * - * Returned Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -void set_errno(int errcode) -{ - *__errno() = errcode; -} diff --git a/sched/mqueue/mq_rcvinternal.c b/sched/mqueue/mq_rcvinternal.c index 4808bef21d5..8749a85aeb6 100644 --- a/sched/mqueue/mq_rcvinternal.c +++ b/sched/mqueue/mq_rcvinternal.c @@ -157,20 +157,17 @@ int nxmq_wait_receive(mqd_t mqdes, FAR struct mqueue_msg_s **rcvmsg) if ((mqdes->oflags & O_NONBLOCK) == 0) { - int saved_errno; - /* Yes.. Block and try again */ rtcb = this_task(); rtcb->msgwaitq = msgq; msgq->nwaitnotempty++; - /* "Borrow" the per-task errno to communication wake-up error + /* Initialize the 'errcode" used to communication wake-up error * conditions. */ - saved_errno = rtcb->pterrno; - rtcb->pterrno = OK; + rtcb->errcode = OK; /* Make sure this is not the idle task, descheduling that * isn't going to end well. @@ -185,9 +182,7 @@ int nxmq_wait_receive(mqd_t mqdes, FAR struct mqueue_msg_s **rcvmsg) * errno value (should be either EINTR or ETIMEDOUT). */ - ret = rtcb->pterrno; - rtcb->pterrno = saved_errno; - + ret = rtcb->errcode; if (ret != OK) { return -ret; diff --git a/sched/mqueue/mq_sndinternal.c b/sched/mqueue/mq_sndinternal.c index 0c0e84f7fd9..06c5ff118a6 100644 --- a/sched/mqueue/mq_sndinternal.c +++ b/sched/mqueue/mq_sndinternal.c @@ -260,8 +260,6 @@ int nxmq_wait_send(mqd_t mqdes) while (msgq->nmsgs >= msgq->maxmsgs) { - int saved_errno; - /* Block until the message queue is no longer full. * When we are unblocked, we will try again */ @@ -270,12 +268,11 @@ int nxmq_wait_send(mqd_t mqdes) rtcb->msgwaitq = msgq; msgq->nwaitnotfull++; - /* "Borrow" the per-task errno to communication wake-up error + /* Initialize the errcode used to communication wake-up error * conditions. */ - saved_errno = rtcb->pterrno; - rtcb->pterrno = OK; + rtcb->errcode = OK; /* Make sure this is not the idle task, descheduling that * isn't going to end well. @@ -290,9 +287,7 @@ int nxmq_wait_send(mqd_t mqdes) * per-task errno value (should be EINTR or ETIMEOUT). */ - ret = rtcb->pterrno; - rtcb->pterrno = saved_errno; - + ret = rtcb->errcode; if (ret != OK) { return -ret; diff --git a/sched/mqueue/mq_waitirq.c b/sched/mqueue/mq_waitirq.c index 0fb1103b766..8582cc7ff0b 100644 --- a/sched/mqueue/mq_waitirq.c +++ b/sched/mqueue/mq_waitirq.c @@ -97,9 +97,9 @@ void nxmq_wait_irq(FAR struct tcb_s *wtcb, int errcode) msgq->nwaitnotfull--; } - /* Mark the errno value for the thread. */ + /* Mark the error value for the thread. */ - wtcb->pterrno = errcode; + wtcb->errcode = errcode; /* Restart the task. */ diff --git a/sched/sched/sched_continue.c b/sched/sched/sched_continue.c index 495b0e671c6..ba2ca768cf7 100644 --- a/sched/sched/sched_continue.c +++ b/sched/sched/sched_continue.c @@ -1,35 +1,20 @@ /**************************************************************************** * sched/sched/sched_continue.c * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -71,7 +56,7 @@ void sched_continue(FAR struct tcb_s *tcb) flags = enter_critical_section(); /* Simply restart the thread. If is was blocked before, it will awaken - * with pterrno = EINTR and will appears as if it were awakened by a + * with errcode = EINTR and will appears as if it were awakened by a * signal. If pre-emption is not disabled this action could block this * task here! */ diff --git a/sched/sched/sched_suspend.c b/sched/sched/sched_suspend.c index e38c2cd9f8d..e24b1fc99dd 100644 --- a/sched/sched/sched_suspend.c +++ b/sched/sched/sched_suspend.c @@ -1,35 +1,20 @@ /**************************************************************************** * sched/sched/sched_suspend.c * - * Copyright (C) 2018 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -84,7 +69,7 @@ void sched_suspend(FAR struct tcb_s *tcb) * the block state by a signal. */ - tcb->pterrno = EINTR; + tcb->errcode = EINTR; /* Move the TCB to the g_stoppedtasks list. */ diff --git a/sched/semaphore/sem_wait.c b/sched/semaphore/sem_wait.c index 0150963e515..91811d8fc12 100644 --- a/sched/semaphore/sem_wait.c +++ b/sched/semaphore/sem_wait.c @@ -106,8 +106,6 @@ int nxsem_wait(FAR sem_t *sem) else { - int saved_errno; - /* First, verify that the task is not already waiting on a * semaphore */ @@ -144,8 +142,7 @@ int nxsem_wait(FAR sem_t *sem) * between sem_waitirq() and this functions. */ - saved_errno = rtcb->pterrno; - rtcb->pterrno = OK; + rtcb->errcode = OK; /* Add the TCB to the prioritized semaphore wait queue, after * checking this is not the idle task - descheduling that @@ -185,8 +182,7 @@ int nxsem_wait(FAR sem_t *sem) * thread was restarted. */ - ret = rtcb->pterrno != OK ? -rtcb->pterrno : OK; - rtcb->pterrno = saved_errno; + ret = rtcb->errcode != OK ? -rtcb->errcode : OK; #ifdef CONFIG_PRIORITY_INHERITANCE sched_unlock(); diff --git a/sched/semaphore/sem_waitirq.c b/sched/semaphore/sem_waitirq.c index af29167d11f..2dfaf2e783c 100644 --- a/sched/semaphore/sem_waitirq.c +++ b/sched/semaphore/sem_waitirq.c @@ -1,35 +1,20 @@ /**************************************************************************** * sched/semaphore/sem_waitirq.c * - * Copyright (C) 2007-2010, 2014, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -117,7 +102,7 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode) /* Mark the errno value for the thread. */ - wtcb->pterrno = errcode; + wtcb->errcode = errcode; /* Restart the task. */ diff --git a/sched/signal/sig_deliver.c b/sched/signal/sig_deliver.c index 599c539315a..d8b894e14e1 100644 --- a/sched/signal/sig_deliver.c +++ b/sched/signal/sig_deliver.c @@ -1,36 +1,20 @@ /**************************************************************************** * sched/signal/sig_deliver.c * - * Copyright (C) 2007, 2008, 2012-2013, 2016, 2019 Gregory Nutt. All - * rights reserved. - * Author: Gregory Nutt + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * http://www.apache.org/licenses/LICENSE-2.0 * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. * ****************************************************************************/ @@ -72,7 +56,6 @@ void nxsig_deliver(FAR struct tcb_s *stcb) sigset_t newsigprocmask; sigset_t altsigprocmask; irqstate_t flags; - int saved_errno; /* Loop while there are signals to be delivered */ @@ -116,15 +99,6 @@ void nxsig_deliver(FAR struct tcb_s *stcb) sq_addlast((FAR sq_entry_t *)sigq, &(stcb->sigpostedq)); - /* Save the thread errno. When we finished dispatching the - * signal actions and resume the task, the errno value must - * be unchanged by the operation of the signal handling. In - * particular, the EINTR indication that says that the task - * was reawakened by a signal must be retained. - */ - - saved_errno = stcb->pterrno; - /* Save a copy of the old sigprocmask and install the new * (temporary) sigprocmask. The new sigprocmask is the union * of the current sigprocmask and the sa_mask for the signal being @@ -192,11 +166,9 @@ void nxsig_deliver(FAR struct tcb_s *stcb) flags = enter_critical_section(); stcb->flags &= ~TCB_FLAG_SIGNAL_ACTION; - /* Restore the original errno value and sigprocmask. */ - - stcb->pterrno = saved_errno; - - /* What if the signal handler changed the sigprocmask? Try to retain + /* Restore the original sigprocmask. + * + * What if the signal handler changed the sigprocmask? Try to retain * any such changes here. * * REVISIT: This logic is imperfect. It will fail to detect bits set diff --git a/syscall/syscall.csv b/syscall/syscall.csv index ed9749f76d0..b28559978a7 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -28,7 +28,6 @@ "fstatfs","sys/statfs.h","","int","int","FAR struct statfs *" "fsync","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int" "ftruncate","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int","off_t" -"get_errno","errno.h","!defined(__DIRECT_ERRNO_ACCESS)","int" "getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char *","FAR const char *" "getgid","unistd.h","defined(CONFIG_SCHED_USER_IDENTITY)","gid_t" "getitimer","sys/time.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","int","int","FAR struct itimerval *" @@ -143,7 +142,6 @@ "send","sys/socket.h","defined(CONFIG_NET)","ssize_t","int","FAR const void *","size_t","int" "sendfile","sys/sendfile.h","defined(CONFIG_NET_SENDFILE)","ssize_t","int","int","FAR off_t *","size_t" "sendto","sys/socket.h","defined(CONFIG_NET)","ssize_t","int","FAR const void *","size_t","int","FAR const struct sockaddr *","socklen_t" -"set_errno","errno.h","!defined(__DIRECT_ERRNO_ACCESS)","void","int" "setenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char *","FAR const char *","int" "setgid","unistd.h","defined(CONFIG_SCHED_USER_IDENTITY)","int","gid_t" "sethostname","unistd.h","","int","FAR const char *","size_t" diff --git a/syscall/syscall_funclookup.c b/syscall/syscall_funclookup.c index d5e10fa614f..fea78794b1f 100644 --- a/syscall/syscall_funclookup.c +++ b/syscall/syscall_funclookup.c @@ -95,17 +95,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* Errno access is awkward. We need to generate get_errno() and set_errno() - * interfaces to support the system calls, even though we don't use them - * ourself. - * - * The "normal" pre-processor definitions for these functions is in errno.h - * but we need the internal function prototypes in nuttx/errno.h. - */ - -#undef get_errno -#undef set_errno - /**************************************************************************** * Public Data ****************************************************************************/