newlib: fix compilation for sincosl

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.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
This commit is contained in:
p-szafonimateusz 2024-02-22 13:09:09 +01:00 committed by Xiang Xiao
parent 5288e063ec
commit e967be059a
3 changed files with 48 additions and 0 deletions

View File

@ -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})

View File

@ -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

View File

@ -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 <math.h>
/****************************************************************************
* Public Functions
****************************************************************************/
void sincosl(long double x, long double *s, long double *c)
{
*s = sinl(x);
*c = cosl(x);
}