Skip to content

Commit f1a4af6

Browse files
committed
plsr: Use different sqrtf depending on ARCH
1 parent b7b9901 commit f1a4af6

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/emlearn_plsr/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ LINK_RUNTIME=1
1515

1616
DIST_DIR := ../../dist/$(ARCH)_$(MPY_ABI_VERSION)
1717

18+
19+
ifeq ($(ARCH),rv32imc)
20+
CFLAGS_MATH := -DUSE_BUILTIN_SQRTF
21+
else
22+
CFLAGS_MATH := -DUSE_IEEE_SQRTF=1
23+
endif
24+
25+
1826
# Name of module
1927
MOD = emlearn_plsr
2028

@@ -32,6 +40,6 @@ $(DIST_DIR):
3240
$(DIST_FILE): $(MOD).mpy $(DIST_DIR)
3341
cp $< $@
3442

35-
CFLAGS += -I$(EMLEARN_DIR) -Wno-unused-function
43+
CFLAGS += -I$(EMLEARN_DIR) -Wno-unused-function $(CFLAGS_MATH)
3644

3745
dist: $(DIST_FILE)

src/emlearn_plsr/plsr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
#include <string.h>
55

66
// NOTE: make sure we do not use sqrtf() wrapper which uses errno, does not work in native module
7+
#if USE_IEEE_SQRTF
8+
#define sqrtf(x) __ieee754_sqrtf(x)
9+
#elif USE_BUILTIN_SQRTF
710
#define sqrtf(x) __builtin_sqrtf(x)
11+
#else
12+
#endif
813

914
#include "eml_plsr.h"
1015

0 commit comments

Comments
 (0)