errno: implement _get_errno() in common code
We really should have more faith in the compiler, it generates code to implement this exactly like the arch-specific assembly versions, and on ARM is actually 4 bytes shorter. FUNC_NO_FP used to disable the usual C preamble to update the frame/stack pointers, which is how the sizes are still the same or less. It's debatable how useful the occasional use of FUNC_NO_FP is in practice since it hinders debugging and in a production build frame pointers should be globally disabled, but we can address that later. Change-Id: I6c4b64ab3e3a9b6f91d52fa8c92e6e79a986fc77 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
2450a56ae5
commit
68b3b6135e
8 changed files with 5 additions and 98 deletions
|
@ -13,7 +13,6 @@ obj-y += prep_c.o \
|
||||||
vector_table.o
|
vector_table.o
|
||||||
|
|
||||||
obj-$(CONFIG_IRQ_OFFLOAD) += irq_offload.o
|
obj-$(CONFIG_IRQ_OFFLOAD) += irq_offload.o
|
||||||
obj-$(CONFIG_ERRNO) += errno.o
|
|
||||||
|
|
||||||
ifneq ($(CONFIG_ATOMIC_OPERATIONS_C),y)
|
ifneq ($(CONFIG_ATOMIC_OPERATIONS_C),y)
|
||||||
obj-y += atomic.o
|
obj-y += atomic.o
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2015 Wind River Systems, Inc.
|
|
||||||
*
|
|
||||||
* Licensed 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
*
|
|
||||||
* @brief Per-thread errno accessor function
|
|
||||||
*
|
|
||||||
* Allow accessing the errno for the current thread without involving the
|
|
||||||
* context switching.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _ASMLANGUAGE
|
|
||||||
|
|
||||||
#include <nano_private.h>
|
|
||||||
#include <offsets.h>
|
|
||||||
|
|
||||||
GTEXT(_nanokernel)
|
|
||||||
GTEXT(_get_errno)
|
|
||||||
|
|
||||||
SECTION_FUNC(TEXT, _get_errno)
|
|
||||||
|
|
||||||
mov_s r0, _nanokernel
|
|
||||||
ld_s r0, [r0, __tNANO_current_OFFSET]
|
|
||||||
add_s r0, r0, __tTCS_errno_var_OFFSET
|
|
||||||
j_s.nd [blink]
|
|
||||||
nop_s
|
|
|
@ -7,6 +7,5 @@ obj-y = vector_table.o reset.o \
|
||||||
nmi_on_reset.o prep_c.o scs.o scb.o nmi.o \
|
nmi_on_reset.o prep_c.o scs.o scb.o nmi.o \
|
||||||
exc_manage.o exc_wrapper.o
|
exc_manage.o exc_wrapper.o
|
||||||
|
|
||||||
obj-$(CONFIG_ERRNO) += errno.o
|
|
||||||
obj-$(CONFIG_IRQ_VECTOR_TABLE_SOC) += irq_vector_table.o
|
obj-$(CONFIG_IRQ_VECTOR_TABLE_SOC) += irq_vector_table.o
|
||||||
obj-$(CONFIG_SW_ISR_TABLE) += sw_isr_table.o
|
obj-$(CONFIG_SW_ISR_TABLE) += sw_isr_table.o
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2015 Wind River Systems, Inc.
|
|
||||||
*
|
|
||||||
* Licensed 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
*
|
|
||||||
* @brief Per-thread errno accessor function
|
|
||||||
*
|
|
||||||
* Allow accessing the errno for the current thread without involving the
|
|
||||||
* context switching.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _ASMLANGUAGE
|
|
||||||
|
|
||||||
#include <nano_private.h>
|
|
||||||
#include <offsets.h> /* nanokernel structure offset definitions */
|
|
||||||
|
|
||||||
_ASM_FILE_PROLOGUE
|
|
||||||
|
|
||||||
GTEXT(_nanokernel)
|
|
||||||
GTEXT(_get_errno)
|
|
||||||
|
|
||||||
SECTION_FUNC(TEXT, _get_errno)
|
|
||||||
|
|
||||||
ldr r0, =_nanokernel
|
|
||||||
ldr r0, [r0, #__tNANO_current_OFFSET]
|
|
||||||
adds.n r0, #__tTCS_errno_var_OFFSET
|
|
||||||
bx lr
|
|
|
@ -25,7 +25,6 @@ obj-y += fatal.o cpuhalt.o \
|
||||||
obj-$(CONFIG_IRQ_OFFLOAD) += irq_offload.o
|
obj-$(CONFIG_IRQ_OFFLOAD) += irq_offload.o
|
||||||
obj-$(CONFIG_FP_SHARING) += float.o
|
obj-$(CONFIG_FP_SHARING) += float.o
|
||||||
obj-$(CONFIG_MICROKERNEL) += strtask.o
|
obj-$(CONFIG_MICROKERNEL) += strtask.o
|
||||||
obj-$(CONFIG_ERRNO) += errno.o
|
|
||||||
obj-$(CONFIG_GDT_DYNAMIC) += gdt.o
|
obj-$(CONFIG_GDT_DYNAMIC) += gdt.o
|
||||||
obj-$(CONFIG_REBOOT_RST_CNT) += reboot_rst_cnt.o
|
obj-$(CONFIG_REBOOT_RST_CNT) += reboot_rst_cnt.o
|
||||||
|
|
||||||
|
|
|
@ -18,3 +18,4 @@ obj-$(CONFIG_KERNEL_EVENT_LOGGER) += event_logger.o
|
||||||
obj-$(CONFIG_KERNEL_EVENT_LOGGER) += kernel_event_logger.o
|
obj-$(CONFIG_KERNEL_EVENT_LOGGER) += kernel_event_logger.o
|
||||||
obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
|
obj-$(CONFIG_RING_BUFFER) += ring_buffer.o
|
||||||
obj-$(CONFIG_ATOMIC_OPERATIONS_C) += atomic_c.o
|
obj-$(CONFIG_ATOMIC_OPERATIONS_C) += atomic_c.o
|
||||||
|
obj-$(CONFIG_ERRNO) += errno.o
|
||||||
|
|
|
@ -22,17 +22,9 @@
|
||||||
* context switching.
|
* context switching.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _ASMLANGUAGE
|
|
||||||
|
|
||||||
#include <nano_private.h>
|
#include <nano_private.h>
|
||||||
#include <arch/x86/asm.h>
|
|
||||||
#include <offsets.h>
|
|
||||||
|
|
||||||
GTEXT(_nanokernel)
|
FUNC_NO_FP int *_get_errno(void)
|
||||||
GTEXT(_get_errno)
|
{
|
||||||
|
return &_nanokernel.current->errno_var;
|
||||||
SECTION_FUNC(TEXT, _get_errno)
|
}
|
||||||
|
|
||||||
movl _nanokernel + __tNANO_current_OFFSET, %eax
|
|
||||||
addl $__tTCS_errno_var_OFFSET, %eax
|
|
||||||
ret
|
|
|
@ -57,10 +57,6 @@ GEN_OFFSET_SYM(tTCS, preempReg); /* start of prempt register set */
|
||||||
GEN_OFFSET_SYM(tTCS, next_thread);
|
GEN_OFFSET_SYM(tTCS, next_thread);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ERRNO
|
|
||||||
GEN_OFFSET_SYM(tTCS, errno_var);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* size of the entire struct tcs structure */
|
/* size of the entire struct tcs structure */
|
||||||
|
|
||||||
GEN_ABSOLUTE_SYM(__tTCS_SIZEOF, sizeof(tTCS));
|
GEN_ABSOLUTE_SYM(__tTCS_SIZEOF, sizeof(tTCS));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue