Thread overview | |||||
---|---|---|---|---|---|
|
August 22, 2019 What is the __udivdi3 __umoddi3 function? | ||||
---|---|---|---|---|
| ||||
Hi I writing a OS in D, compile with -betterC -c, but when call a variable template function where has __udivdi3 __umoddi3 undefined symbol, can not link with ld, how to resolve it. see code below println('it is ok'); println('it is occur -_udivdi3 symbol', 33); void println(A...)(A a) { char[20] numStr = void; import std.traits; foreach(v ; a) { alias UV = Unqual!(typeof(v)); static if (is(UV == char)) putc(v); else static if (is(UV == char*)) puts(v); else static if (is(typeof(v) == string)) puts(v.ptr); else static if (is(UV == bool)) puts(v ? "true":"false"); else static if (is(UV == byte) || is(UV == ubyte) || is(UV == short) || is(UV == ushort) || is(UV == int) || is(UV == uint) || is(UV == long) || is(UV == ulong)) { ulong n = cast(ulong)v; bool isNeg = false; if (v < 0) { isNeg = true; if (n != 1UL<<63) n = -v; } int i=0; while(n !=0 ) { numStr[i++] = (n%10) + '0'; n/=10; } if (isNeg) putc('-'); while (--i >= 0) putc(numStr[i]); } else static assert(false); } } |
August 22, 2019 Re: What is the __udivdi3 __umoddi3 function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to lili | Hi there,
On 22 Aug 2019, at 21:20, lili via digitalmars-d-ldc wrote:
> I writing a OS in D, compile with -betterC -c, but when call a variable template function
> where has __udivdi3 __umoddi3 undefined symbol, can not link with ld, how to resolve it.
> see code below
These are software implementations of integer arithmetic where the desired operation is not natively available on the target CPU (e.g. 64 bit integer division on a 32 bit target).
You can find an implementation in the compiler-rt project (or libgcc), which you can link into your kernel as needed. You might be able to get around this by not using 64 bit integers in your code if 32 bits suffice.
— David
|
August 23, 2019 Re: What is the __udivdi3 __umoddi3 function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Thursday, 22 August 2019 at 20:39:32 UTC, David Nadlinger wrote:
> Hi there,
>
> On 22 Aug 2019, at 21:20, lili via digitalmars-d-ldc wrote:
>> I writing a OS in D, compile with -betterC -c, but when call a variable template function
>> where has __udivdi3 __umoddi3 undefined symbol, can not link with ld, how to resolve it.
>> see code below
>
> These are software implementations of integer arithmetic where the desired operation is not natively available on the target CPU (e.g. 64 bit integer division on a 32 bit target).
>
> You can find an implementation in the compiler-rt project (or libgcc), which you can link into your kernel as needed. You might be able to get around this by not using 64 bit integers in your code if 32 bits suffice.
>
> — David
Thanks a lot.
|
Copyright © 1999-2021 by the D Language Foundation