diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 542a0567470..1f65cdff48a 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -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: $<" diff --git a/arch/sim/src/sim/CMakeLists.txt b/arch/sim/src/sim/CMakeLists.txt index 3b3da83e189..2c90e3fad47 100644 --- a/arch/sim/src/sim/CMakeLists.txt +++ b/arch/sim/src/sim/CMakeLists.txt @@ -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 diff --git a/arch/sim/src/sim/posix/sim_errno.c b/arch/sim/src/sim/posix/sim_errno.c new file mode 100644 index 00000000000..77066082a17 --- /dev/null +++ b/arch/sim/src/sim/posix/sim_errno.c @@ -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 + +/**************************************************************************** + * 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; +} diff --git a/arch/sim/src/sim/sim_internal.h b/arch/sim/src/sim/sim_internal.h index b3675bb79b7..da1f8d5d942 100644 --- a/arch/sim/src/sim/sim_internal.h +++ b/arch/sim/src/sim/sim_internal.h @@ -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); diff --git a/arch/sim/src/sim/win/sim_errno.c b/arch/sim/src/sim/win/sim_errno.c new file mode 100644 index 00000000000..b416b5d14e1 --- /dev/null +++ b/arch/sim/src/sim/win/sim_errno.c @@ -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 + +/**************************************************************************** + * 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; +}