From 71e59d26a0d5a85e3f99017b1356422dbdd034d7 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 25 Feb 2018 17:29:42 +0000 Subject: [PATCH] 6809: build libm (sort of) There are some outstanding problems to fix - We only build for float, but the C type promotion rules at this point then mess us up and turn the float into a double for varargs (blame the C spec) - Several things use __NaN but that breaks on 6809 really and now we've got SDCC fixed we can probably switch to using 0/0 etc as we did before. --- Library/include/6809/stdint.h | 2 ++ Library/include/math.h | 2 ++ Library/libs/Makefile.6809 | 26 ++++++++++++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Library/include/6809/stdint.h b/Library/include/6809/stdint.h index cd86d211..f7667e8b 100644 --- a/Library/include/6809/stdint.h +++ b/Library/include/6809/stdint.h @@ -16,4 +16,6 @@ typedef uint16_t uintptr_t; #define __SIZE_T_DEFINED #define NO_64BIT +#define double float + #endif diff --git a/Library/include/math.h b/Library/include/math.h index 2e4aad6d..5d250546 100644 --- a/Library/include/math.h +++ b/Library/include/math.h @@ -1,6 +1,8 @@ #ifndef _MATH_H #define _MATH_H +#include + /* Large elements of this are drawn from MUSL */ extern int signgam; diff --git a/Library/libs/Makefile.6809 b/Library/libs/Makefile.6809 index 6739c8cf..05a33570 100644 --- a/Library/libs/Makefile.6809 +++ b/Library/libs/Makefile.6809 @@ -67,14 +67,27 @@ SRC_CT += termcap.c tgetent.c SRC_CURS = $(shell find curses -name '*.c') -SRC_LM = vfscanf.c vfprintf.c -OBJ_LM = vfscanf-libm.o vfprintf-libm.o +SRC_LM += acosf.c acoshf.c asinf.c asinhf.c atan2f.c atanf.c atanhf.c +SRC_LM += cbrtf.c ceilf.c copysignf.c erff.c expf.c expm1f.c +SRC_LM += fabsf.c fdimf.c floorf.c fmaxf.c fminf.c fmodf.c frexpf.c +SRC_LM += hypotf.c ilogbf.c j0f.c j1f.c jnf.c +SRC_LM += ldexpf.c lgammaf.c lgammaf_r.c logf.c log2f.c log10f.c logbf.c +SRC_LM += lrintf.c lroundf.c +SRC_LM += modff.c nearbyintf.c nextafterf.c powf.c +SRC_LM += remainderf.c remquof.c rintf.c roundf.c +SRC_LM += scalbnf.c scalbinf.c +SRC_LM += sinf.c sincosf.c sinhf.c +SRC_LM += sqrtf.c tgammaf.c +SRC_LM += vfscanf_m.c vfprintf_m.c +SRC_LM += __expo2f.c __float_bits.c __fpclassifyf.c __log1pf.c __signgam.c + OBJ_C = $(SRC_C:.c=.o) OBJ_CURS = $(SRC_CURS:.c=.o) OBJ_CT = $(SRC_CT:.c=.o) +OBJ_LM = $(SRC_LM:.c=.o) OBJ_HARD = $(SRC_HARD:.c=.o) -OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD) +OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD) $(OBJ_LM) all: syslib$(PLATFORM).lib liberror.txt $(OBJ_CRT0) curses$(PLATFORM).lib termcap$(PLATFORM).lib m$(PLATFORM).lib @@ -136,11 +149,8 @@ $(OBJ_CT):%.o: %.c $(OBJ_CURS):%.o: %.c $(CC) $(CC_OPT) $(@:.o=.c) -o $@ -vfscanf-libm.o: vfscanf.c - $(CC) $(CC_OPT) -DBUILD_LIBM $< -o $@ - -vfprintf-libm.o: vfprintf.c - $(CC) $(CC_OPT) -DBUILD_LIBM $< -o $@ +$(OBJ_LM):%.o: %.c + $(CC) $(CC_OPT) -DBUILD_LIBM $(@:.o=.c) -o $@ $(OBJ_HARD):%.o: %.c $(CC) $(CC_NOOPT) $(@:.o=.c) -- 2.34.1