From 726024dfe0359adb3fda713590a0f00bb7c2fa7c Mon Sep 17 00:00:00 2001 From: siemargl Date: Fri, 7 Oct 2016 09:23:37 +0000 Subject: [PATCH] fix startup, gcc5.4 ready git-svn-id: svn://kolibrios.org@6574 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../develop/ktcc/trunk/libc/start/start.asm | 1 + programs/develop/ktcc/trunk/libctest/float2.c | 42 +++++++++++++++++++ programs/develop/ktcc/trunk/readme.txt | 3 ++ .../develop/ktcc/trunk/source/Makefile.kos32 | 10 ++++- programs/develop/ktcc/trunk/source/libtcc.c | 7 +++- 5 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 programs/develop/ktcc/trunk/libctest/float2.c diff --git a/programs/develop/ktcc/trunk/libc/start/start.asm b/programs/develop/ktcc/trunk/libc/start/start.asm index 200b7e58ac..9fdfb991f2 100644 --- a/programs/develop/ktcc/trunk/libc/start/start.asm +++ b/programs/develop/ktcc/trunk/libc/start/start.asm @@ -33,6 +33,7 @@ start: ; or al, [params+buf_len-1] ; jnz .crash ; check if path written by OS + mov [argc], 0 mov eax, [hparams] test eax, eax jz .without_path diff --git a/programs/develop/ktcc/trunk/libctest/float2.c b/programs/develop/ktcc/trunk/libctest/float2.c new file mode 100644 index 0000000000..11e42ab0f7 --- /dev/null +++ b/programs/develop/ktcc/trunk/libctest/float2.c @@ -0,0 +1,42 @@ +#include +#include + +main() +{ + int i; + for (i = 0; i < 10; i++) + { + printf("------------------------------------------------------\n"); + printf ( "remainder of 5.3 / 2 is %f\n", remainder (5.3,2) ); + printf ( "remainder of 18.5 / 4.2 is %f\n", remainder (18.5,4.2) ); +//remainder of 5.3 / 2 is -0.700000 +//remainder of 18.5 / 4.2 is 1.700000 + + printf ( "fmod of 5.3 / 2 is %f\n", fmod (5.3,2) ); + printf ( "fmod of 18.5 / 4.2 is %f\n", fmod (18.5,4.2) ); +// fmod of 5.3 / 2 is 1.300000 +// fmod of 18.5 / 4.2 is 1.700000 + + double param, fractpart, intpart, result; + int n; + + param = 3.14159265; + fractpart = modf (param , &intpart); + printf ("%f = %f + %f \n", param, intpart, fractpart); +//3.141593 = 3.000000 + 0.141593 + + param = 0.95; + n = 4; + result = ldexp (param , n); + printf ("%f * 2^%d = %f\n", param, n, result); +//0.950000 * 2^4 = 15.200000 + + param = 8.0; + result = frexp (param , &n); + printf ("%f = %f * 2^%d\n", param, result, n); +//8.000000 = 0.500000 * 2^4 + param = 50; + result = frexp (param , &n); + printf ("%f = %f * 2^%d\n", param, result, n); + } +} \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/readme.txt b/programs/develop/ktcc/trunk/readme.txt index ef31932c12..9df678ff0e 100644 --- a/programs/develop/ktcc/trunk/readme.txt +++ b/programs/develop/ktcc/trunk/readme.txt @@ -2,3 +2,6 @@ see source/readme.* source/changelog source/tcc-doc.info or .texi + +building Kolibri version +>make -f Makefile.kos32 diff --git a/programs/develop/ktcc/trunk/source/Makefile.kos32 b/programs/develop/ktcc/trunk/source/Makefile.kos32 index 030e485fa4..02bfcd62bb 100644 --- a/programs/develop/ktcc/trunk/source/Makefile.kos32 +++ b/programs/develop/ktcc/trunk/source/Makefile.kos32 @@ -3,7 +3,12 @@ LD = kos32-ld SDK_DIR:= $(abspath ../../../sdk) -LDFLAGS = -static -nostdlib -T $(SDK_DIR)/sources/newlib/static.lds +#gcc 4.8 +#LDFLAGS = -static -nostdlib -T $(SDK_DIR)/sources/newlib/static.lds + + +LDFLAGS = -static -S -nostdlib -T $(SDK_DIR)/lib/app-dynamic.lds \ + --image-base 0 CFLAGS = -c -fno-ident -O2 -fomit-frame-pointer -U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 @@ -20,7 +25,8 @@ OBJECTS = $(patsubst %.c, %.o, $(SOURCES)) default: tcc tcc: $(OBJECTS) - $(LD) $(LDFLAGS) $(LIBPATH) -o tcc $(OBJECTS) -lgcc_eh -lc -lgcc -lc +#gcc4.8 $(LD) $(LDFLAGS) $(LIBPATH) -o tcc $(OBJECTS) -lgcc_eh -lc -lgcc -lc + $(LD) $(LDFLAGS) $(LIBPATH) -o tcc $(OBJECTS) -lgcc -ldll -lc.dll kos32-objcopy tcc -O binary %.o : %.c $(SOURCES) diff --git a/programs/develop/ktcc/trunk/source/libtcc.c b/programs/develop/ktcc/trunk/source/libtcc.c index aaddd9dbc1..efd7798c99 100644 --- a/programs/develop/ktcc/trunk/source/libtcc.c +++ b/programs/develop/ktcc/trunk/source/libtcc.c @@ -777,8 +777,13 @@ static void error1(TCCState *s1, int is_warning, const char *fmt, va_list ap) /* default case: stderr */ if (s1->ppfp) /* print a newline during tcc -E */ fprintf(s1->ppfp, "\n"), fflush(s1->ppfp); +#ifndef TCC_TARGET_MEOS fprintf(stderr, "%s\n", buf); fflush(stderr); /* print error/warning now (win32) */ +#else + fprintf(stdout, "%s\n", buf); + fflush(stdout); /* print error/warning now (win32) */ +#endif } else { s1->error_func(s1->error_opaque, buf); } @@ -2483,7 +2488,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time) tt = 0.001; if (total_bytes < 1) total_bytes = 1; - fprintf(stderr, "%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n", + fprintf(stdout, "%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n", tok_ident - TOK_IDENT, total_lines, total_bytes, tt, (int)(total_lines / tt), total_bytes / tt / 1000000.0);