From db7f1a2652203376a694d6dbc3cfed5969f8fdfa Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Fri, 20 Jan 2017 11:58:11 +1100 Subject: [PATCH] Add modf() so that printf() works with floating point formats --- lib/libstdc/linux/gen/Makefile | 4 ++-- lib/libstdc/linux/gen/modf.c | 7 +++++++ test/Makefile | 12 ++++++++++++ test/hello.c | 2 +- test/n.sh | 5 ----- 5 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 lib/libstdc/linux/gen/modf.c create mode 100644 test/Makefile delete mode 100755 test/n.sh diff --git a/lib/libstdc/linux/gen/Makefile b/lib/libstdc/linux/gen/Makefile index 080aab3..cc25be1 100644 --- a/lib/libstdc/linux/gen/Makefile +++ b/lib/libstdc/linux/gen/Makefile @@ -8,8 +8,8 @@ CC=gcc -g -I${ROOT}/cross/include -Dx_vax -Wall -Wno-char-subscripts -Wno-deprec # @(#)Makefile 5.4 (Berkeley) 9/5/85 # -SRCS= abort.c -OBJS= abort.o +SRCS= abort.c modf.c +OBJS= abort.o modf.o TAGSFILE=tags .c.o: diff --git a/lib/libstdc/linux/gen/modf.c b/lib/libstdc/linux/gen/modf.c new file mode 100644 index 0000000..564ab52 --- /dev/null +++ b/lib/libstdc/linux/gen/modf.c @@ -0,0 +1,7 @@ +#include + +#include + +double modf(v, p) double v; double *p; { + return nox_modf(v, p); +} diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..1f8091a --- /dev/null +++ b/test/Makefile @@ -0,0 +1,12 @@ +ROOT=.. +CC=gcc -g -I${ROOT}/cross/include -L${ROOT}/cross/lib -Dx_vax -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result + +.c.o: + ${ROOT}/xify/xify.sh <$< >$*.temp.c + ${CC} -o $@ -c $*.temp.c + +hello: hello.o + ${CC} -o $@ ${ROOT}/cross/lib/crt0.o hello.o -lx_c + +clean: + rm -f hello *.temp.c *.o diff --git a/test/hello.c b/test/hello.c index 3b433f9..418cfea 100644 --- a/test/hello.c +++ b/test/hello.c @@ -1,6 +1,6 @@ #include int main() { - printf("hello, world\n"); + printf("hello, %s %.*s %5.2f\n", "world", 2, "fun", 3.14159); return 0; } diff --git a/test/n.sh b/test/n.sh deleted file mode 100755 index dac9453..0000000 --- a/test/n.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -ROOT=.. -$ROOT/xify/xify.sh hello.temp.c -gcc -g -I$ROOT/cross/include -Dx_vax -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result -o hello.o -c hello.temp.c -gcc -g -L$ROOT/cross/lib -o hello $ROOT/cross/lib/crt0.o hello.o -lx_c -- 2.34.1