From 82ddf447d5d9afb1a993950c1d4f04373351463a Mon Sep 17 00:00:00 2001 From: turbocat Date: Tue, 2 Nov 2021 21:29:04 +0000 Subject: [PATCH] libc.obj: Fixed div, ldiv, lldiv ( problem with the compatibility of returned structures in functions between tcc and gcc) thanks to Boppan). git-svn-id: svn://kolibrios.org@9233 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../develop/ktcc/trunk/bin/lib/libc.obj.a | Bin 84280 -> 83244 bytes .../ktcc/trunk/libc.obj/include/stdlib.h | 34 ++++++++++++++---- .../develop/ktcc/trunk/libc.obj/source/libc.c | 3 -- .../ktcc/trunk/libc.obj/source/stdlib/div.c | 6 ---- .../ktcc/trunk/libc.obj/source/stdlib/ldiv.c | 6 ---- .../ktcc/trunk/libc.obj/source/stdlib/lldiv.c | 6 ---- .../ktcc/trunk/libc.obj/source/symbols.txt | 3 -- 7 files changed, 28 insertions(+), 30 deletions(-) delete mode 100644 programs/develop/ktcc/trunk/libc.obj/source/stdlib/div.c delete mode 100644 programs/develop/ktcc/trunk/libc.obj/source/stdlib/ldiv.c delete mode 100644 programs/develop/ktcc/trunk/libc.obj/source/stdlib/lldiv.c diff --git a/programs/develop/ktcc/trunk/bin/lib/libc.obj.a b/programs/develop/ktcc/trunk/bin/lib/libc.obj.a index 331333aff10e2335a7e369e463deec7c24f39653..5c7878caed882b408979b7cc72a2c325324ba866 100644 GIT binary patch delta 718 zcmW;HVMr5T5XSNUiOVsDEE_Up$P|&Wh78eMW~jKR$jHdZXvT;k62l}UMvb;&$PkI4 zQX(cJB#b1ajT#{$A|WwCL_$JBLPA19LSlqSM=$(%?$h1#W=9OOLxyBywBF{LBzVT5b`t7RaAF3$ z8E9ODrfq13D6Lj#^T3%VIO~J+?Qp>l7klAS2rlcvE4tun7Ov&s`WD>C!%YhW%y7#N z!7Au+La(~5b4c~++^_DsVLCwST8&c!FWGR48UXa5Z6B9RyBFVqiPS3dXR=f+T%|{ zB5)5(O_1mYv(}_$u&9()Nb^9tvicz-0Ja{;RCbl693jY7IVv{{PPM%c@&{p81PX?s za14s3pm+vKR-x2_k8%f8ltEP;RM*2n7u4#~LmhC~3rBU~F&%I`1}Em>)C#yvaK;V| zHfVH$y8zDSLzC9?s#*IBs#W`o%2NdGCD5UJE?0uL2CnG7&N?4lI|5zxaQ!6sUC`YC z0d+(FLQfO)YM4+f-10zJL*4emoldyh1%2wiANtjR8dMJg5K%)07&gI(8AdJeNW+d< z;fdC9J4`rW(w75IoiL?opJ~#VdQk+^CGfHgX4Gr#XSKdnbCvK;&DX&DI#^I2^aB>_ z;Zp-Fx#3F_EH}e94ZWg%cwkk7|MbEyKl~2Bn)(w$e1wsNe#9_{Y>XhLVI*-BF^?fh zqAw@^DMMzA}g6wJkL_SoSa$b+}!X>lZuwTMRmY;P-)Wf(~j+-4>k8i$yyJuNv1+ cNMwCRTO|B{Mqcpd$LAwMpFNMiI;7P87ww?Po&W#< diff --git a/programs/develop/ktcc/trunk/libc.obj/include/stdlib.h b/programs/develop/ktcc/trunk/libc.obj/include/stdlib.h index 532474e39f..e39f5a9910 100644 --- a/programs/develop/ktcc/trunk/libc.obj/include/stdlib.h +++ b/programs/develop/ktcc/trunk/libc.obj/include/stdlib.h @@ -20,13 +20,35 @@ extern int _FUNC(abs)(int); extern long _FUNC(labs)(long); extern long long _FUNC(llabs)(long long); -typedef struct { int quot, rem; } div_t; -typedef struct { long quot, rem; } ldiv_t; -typedef struct { long long quot, rem; } lldiv_t; +typedef struct { + int quot; + int rem; +} div_t; -extern div_t _FUNC(div)(int, int); -extern ldiv_t _FUNC(ldiv)(long, long); -extern lldiv_t _FUNC(lldiv)(long long, long long); +typedef struct { + long quot; + long rem; +} ldiv_t; + +typedef struct { + long long quot; + long long rem; +} lldiv_t; + +static inline +div_t div(int num, int den) { + return (div_t){ num/den, num%den }; +} + +static inline +ldiv_t ldiv(long num, long den) { + return (ldiv_t){ num/den, num%den }; +} + +static inline +lldiv_t lldiv(long long num, long long den) { + return (lldiv_t){ num/den, num%den }; +} extern void* _FUNC(malloc)(size_t size); extern void* _FUNC(calloc)(size_t num, size_t size); diff --git a/programs/develop/ktcc/trunk/libc.obj/source/libc.c b/programs/develop/ktcc/trunk/libc.obj/source/libc.c index 16bb0c8806..b1799af8fc 100644 --- a/programs/develop/ktcc/trunk/libc.obj/source/libc.c +++ b/programs/develop/ktcc/trunk/libc.obj/source/libc.c @@ -82,7 +82,6 @@ #include "string/memmove.c" #include "stdlib/calloc.c" -#include "stdlib/lldiv.c" #include "stdlib/malloc.c" #include "stdlib/atoll.c" #include "stdlib/free.c" @@ -91,9 +90,7 @@ #include "stdlib/atoi.c" #include "stdlib/labs.c" #include "stdlib/realloc.c" -#include "stdlib/ldiv.c" #include "stdlib/abs.c" -#include "stdlib/div.c" #include "stdlib/atol.c" #include "stdlib/itoa.c" #include "stdlib/strtol.c" diff --git a/programs/develop/ktcc/trunk/libc.obj/source/stdlib/div.c b/programs/develop/ktcc/trunk/libc.obj/source/stdlib/div.c deleted file mode 100644 index 99bce10157..0000000000 --- a/programs/develop/ktcc/trunk/libc.obj/source/stdlib/div.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -div_t div(int num, int den) -{ - return (div_t){ num/den, num%den }; -} \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/libc.obj/source/stdlib/ldiv.c b/programs/develop/ktcc/trunk/libc.obj/source/stdlib/ldiv.c deleted file mode 100644 index e19a084ea2..0000000000 --- a/programs/develop/ktcc/trunk/libc.obj/source/stdlib/ldiv.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -ldiv_t ldiv(long num, long den) -{ - return (ldiv_t){ num/den, num%den }; -} \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/libc.obj/source/stdlib/lldiv.c b/programs/develop/ktcc/trunk/libc.obj/source/stdlib/lldiv.c deleted file mode 100644 index 7d589145c5..0000000000 --- a/programs/develop/ktcc/trunk/libc.obj/source/stdlib/lldiv.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -lldiv_t lldiv(long long num, long long den) -{ - return (lldiv_t){ num/den, num%den }; -} \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/libc.obj/source/symbols.txt b/programs/develop/ktcc/trunk/libc.obj/source/symbols.txt index 8da25ec0f6..8245b893dc 100644 --- a/programs/develop/ktcc/trunk/libc.obj/source/symbols.txt +++ b/programs/develop/ktcc/trunk/libc.obj/source/symbols.txt @@ -49,14 +49,11 @@ atol atoll atof calloc -div exit free itoa labs -ldiv llabs -lldiv malloc realloc strtol