diff --git a/libs/libm/newlib/CMakeLists.txt b/libs/libm/newlib/CMakeLists.txt index a2c68937157..7fdba758948 100644 --- a/libs/libm/newlib/CMakeLists.txt +++ b/libs/libm/newlib/CMakeLists.txt @@ -93,6 +93,12 @@ if(CONFIG_LIBM_NEWLIB) set(CSRCS ${COMMON_CSRCS} ${COMPLEX_CSRCS} ${ARCH_CSRCS}) + # aggresive optimisation can replace occurrences of sinl() and cosl() with + # sincosl(), but sincosl() is missing in newlib which causes error. So let's + # use custom implementation here. + + list(APPEND CSRCS ${CMAKE_CURRENT_LIST_DIR}/sincosl.c) + if(CONFIG_LIBM_NEWLIB_HW_FP) file(GLOB_RECURSE MATHFP_CSRCS ${NEWLIB_DIR}/newlib/libm/mathfp/*.c) list(APPEND CSRCS ${MATHFP_CSRCS}) diff --git a/libs/libm/newlib/Make.defs b/libs/libm/newlib/Make.defs index db8d4f11696..91540687235 100644 --- a/libs/libm/newlib/Make.defs +++ b/libs/libm/newlib/Make.defs @@ -89,6 +89,13 @@ VPATH += :newlib/newlib/newlib/libm/fenv CFLAGS += ${INCDIR_PREFIX}newlib/newlib/newlib/libc/machine/shared_x86/sys endif +# aggresive optimisation can replace occurrences of sinl() and cosl() with +# sincosl(), but sincosl() is missing in newlib which causes error. So let's +# use custom implementation here. + +CSRCS += newlib/sincosl.c +VPATH += :newlib + ifeq ($(CONFIG_LIBM_NEWLIB_HW_FP),y) CSRCS += $(wildcard newlib/newlib/newlib/libm/mathfp/*.c) VPATH += :newlib/newlib/newlib/libm/mathfp diff --git a/libs/libm/newlib/sincosl.c b/libs/libm/newlib/sincosl.c new file mode 100644 index 00000000000..3ff68362653 --- /dev/null +++ b/libs/libm/newlib/sincosl.c @@ -0,0 +1,35 @@ +/**************************************************************************** + * libs/libm/newlib/sincosl.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 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void sincosl(long double x, long double *s, long double *c) +{ + *s = sinl(x); + *c = cosl(x); +}