mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:34:07 +08:00
arch/sim: add host_errno_get/set for sim to backup/restore in "irq"
Avoid the errno changed after interrupt in sim and make return value mistake when according to errno. Move host_errno_convert from macro to sim_errno.c. Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
@@ -118,7 +118,7 @@ ifeq ($(CONFIG_FS_LARGEFILE),y)
|
||||
endif
|
||||
|
||||
HOSTSRCS = sim_hostirq.c sim_hostmemory.c sim_hostmisc.c sim_hosttime.c sim_hostuart.c
|
||||
HOSTSRCS += sim_hostfs.c
|
||||
HOSTSRCS += sim_hostfs.c sim_errno.c
|
||||
|
||||
hostfs.h: $(TOPDIR)/include/nuttx/fs/hostfs.h
|
||||
@echo "CP: $<"
|
||||
|
||||
@@ -284,6 +284,8 @@ endif()
|
||||
list(APPEND HOSTSRCS sim_hostfs.c)
|
||||
list(APPEND HOST_DEFINITIONS CONFIG_NAME_MAX=${CONFIG_NAME_MAX})
|
||||
|
||||
list(APPEND HOSTSRCS sim_errno.c)
|
||||
|
||||
configure_file(${NUTTX_DIR}/include/nuttx/fs/hostfs.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/hostfs.h COPYONLY)
|
||||
configure_file(${CMAKE_BINARY_DIR}/include/nuttx/config.h
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
* arch/sim/src/sim/posix/sim_errno.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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 <errno.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int host_errno_convert(int errcode)
|
||||
{
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int host_errno_get(void)
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
|
||||
void host_errno_set(int errcode)
|
||||
{
|
||||
errno = errcode;
|
||||
}
|
||||
@@ -107,12 +107,6 @@
|
||||
#define sim_savestate(regs) sim_copyfullstate(regs, up_current_regs())
|
||||
#define sim_restorestate(regs) up_set_current_regs(regs)
|
||||
|
||||
/* Provide a common interface, which should have different conversions
|
||||
* on different platforms.
|
||||
*/
|
||||
|
||||
#define host_errno_convert(errcode) (errcode)
|
||||
|
||||
#define sim_saveusercontext(saveregs, ret) \
|
||||
do \
|
||||
{ \
|
||||
@@ -215,6 +209,12 @@ void sim_copyfullstate(xcpt_reg_t *dest, xcpt_reg_t *src);
|
||||
void *sim_doirq(int irq, void *regs);
|
||||
void sim_unlock(void);
|
||||
|
||||
/* sim_errno.c */
|
||||
|
||||
int host_errno_convert(int errcode);
|
||||
int host_errno_get(void);
|
||||
void host_errno_set(int errcode);
|
||||
|
||||
/* sim_hostmisc.c ***********************************************************/
|
||||
|
||||
void host_abort(int status);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
* arch/sim/src/sim/win/sim_errno.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* 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 <errno.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int host_errno_convert(int errcode)
|
||||
{
|
||||
return errcode;
|
||||
}
|
||||
|
||||
int host_errno_get(void)
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
|
||||
void host_errno_set(int errcode)
|
||||
{
|
||||
errno = errcode;
|
||||
}
|
||||
Reference in New Issue
Block a user