diff --git a/test_programs/GNUmakefile.68k b/test_programs/GNUmakefile.68k index 3c09e40..419c5a7 100644 --- a/test_programs/GNUmakefile.68k +++ b/test_programs/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.9 2005-08-27 12:52:26 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.10 2006-01-02 13:11:39 obarthel Exp $ # # :ts=8 # @@ -48,12 +48,13 @@ LIBS = -lm -lc -lgcc all: test fgets_test iotest sscanf_test printf_test sprintf_test \ stack_size_test translate_test strtok_test uname simple \ - fstat_stdout_test simple_sprintf date_test sscanf_64 + fstat_stdout_test simple_sprintf date_test sscanf_64 factorial clean: $(DELETE) #?.o #?.map test fgets_test iotest sscanf_test printf_test \ sprintf_test stack_size_test translate_test strtok_test uname \ - simple fstat_stdout_test simple_sprintf date_test sscanf_64 + simple fstat_stdout_test simple_sprintf date_test sscanf_64 \ + factorial ############################################################################## @@ -117,6 +118,10 @@ sscanf_64 : sscanf_64.o @echo "Linking $@" $(CC) $(CFLAGS) -o $@ sscanf_64.o $(LIBS) -Wl,--cref,-M,-Map=$@.map +factorial : factorial.o + @echo "Linking $@" + $(CC) $(CFLAGS) -o $@ factorial.o $(LIBS) -Wl,--cref,-M,-Map=$@.map + ############################################################################## mkid: diff --git a/test_programs/GNUmakefile.os4 b/test_programs/GNUmakefile.os4 index 8cb4e50..34534e3 100644 --- a/test_programs/GNUmakefile.os4 +++ b/test_programs/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.10 2005-08-27 12:52:26 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.11 2006-01-02 13:11:39 obarthel Exp $ # # :ts=8 # @@ -40,13 +40,14 @@ LIBS = -lm -lc -ldebug -lgcc all: test fgets_test iotest sscanf_test printf_test sprintf_test \ stack_size_test translate_test strtok_test uname simple \ - fstat_stdout_test simple_sprintf date_test sscanf_64 + fstat_stdout_test simple_sprintf date_test sscanf_64 \ + factorial clean: $(DELETE) *.o *.map test fgets_test iotest sscanf_test printf_test \ sprintf_test stack_size_test translate_test strtok_test \ uname simple fstat_stdout_test simple_sprintf date_test \ - sscanf_64 + sscanf_64 factorial ############################################################################## @@ -109,3 +110,7 @@ simple_sprintf : simple_sprintf.o sscanf_64 : sscanf_64.o @echo "Linking $@" $(CC) -nostdlib $(CFLAGS) -o $@ sscanf_64.o -lc -lgcc -Wl,--cref,-M,-Map=$@.map + +factorial : factorial.o + @echo "Linking $@" + $(CC) -nostdlib $(CFLAGS) -o $@ factorial.o -lc -lgcc -Wl,--cref,-M,-Map=$@.map diff --git a/test_programs/factorial.c b/test_programs/factorial.c new file mode 100644 index 0000000..1751f45 --- /dev/null +++ b/test_programs/factorial.c @@ -0,0 +1,25 @@ +#include + +/* +gcc -std=c99 -mcrt=clib2 -o factorial factorial.c -lm +output is: +16! = 20922789888 <- Wrong + +gcc -std=c99 -mcrt=newlib -o factorial factorial.c +output is: +16! = 20922789888000 <- Correct +*/ + +int +main(void) +{ + double result = 1.0; + int i; + + for ( i = 2; i < 17; ++i ) + result = result * i; + + printf("16! = %.14g\n", result); + + return 0; +} diff --git a/test_programs/smakefile b/test_programs/smakefile index 06a7cf0..b5c7802 100644 --- a/test_programs/smakefile +++ b/test_programs/smakefile @@ -1,5 +1,5 @@ # -# $Id: smakefile,v 1.8 2005-08-26 12:21:51 obarthel Exp $ +# $Id: smakefile,v 1.9 2006-01-02 13:11:39 obarthel Exp $ # # :ts=8 # @@ -67,14 +67,14 @@ all: \ setup \ test fgets_test iotest sscanf_test printf_test sprintf_test \ stack_size_test translate_test strtok_test uname simple \ - fstat_stdout_test simple_sprintf date_test \ + fstat_stdout_test simple_sprintf date_test factorial \ cleanup clean: -delete \#?.o \#?.map \ test fgets_test iotest sscanf_test printf_test sprintf_test \ stack_size_test translate_test strtok_test uname simple \ - simple_sprintf date_test + simple_sprintf date_test factorial ############################################################################## @@ -158,6 +158,11 @@ simple_sprintf: simple_sprintf.o @slink simple_sprintf.o to $@ lib $(LIB)c.lib addsym \ map $@.map,fhx fwidth 32 pwidth 32 swidth 32 +factorial: factorial.o + @echo "Linking $@" + @slink $(LIB)startup.o factorial.o to $@ lib $(LIB)c.lib addsym \ + map $@.map,fhx fwidth 32 pwidth 32 swidth 32 + ############################################################################## mkid: