inline asm return values

2018-03-25 Thread Dave Jones via Digitalmars-d-learn
Given this... int mulDiv64(int a, int b, int c) { asm { movEAX,a; imul b; idiv c; } } which computes a*b/c, with the intermediate value in 64 bit. It returns value that is left in EAX. Is this stuff documented somewhere? I mean I found the page on

converting a number into bit array

2018-03-25 Thread Alex via Digitalmars-d-learn
Given this, ´´´ import std.bitmanip; import core.stdc.limits; void main() { BitArray ba; ba.length = size_t.sizeof * CHAR_BIT; // enough length, known at compile time size_t arbitrary; // = random size_t, not known at compile time // ba ???assign??? arbitrary;

Homebuilt dmd fails to link my dub application

2018-03-25 Thread Nordlöw via Digitalmars-d-learn
If my homebuilt dmd fails to build my dub project with message /usr/bin/ld: error: .dub/build/application-unittest-linux.posix-x86_64-dmd_2079-C9019ECA621321CC168B385F53D82831/knetquery.o: requires dynamic R_X86_64_32 reloc against '_D6object9Throwable7__ClassZ' which may overflow at runtime; re

Re: Homebuilt dmd fails to link my dub application

2018-03-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/03/2018 1:05 AM, Nordlöw wrote: If my homebuilt dmd fails to build my dub project with message /usr/bin/ld: error: .dub/build/application-unittest-linux.posix-x86_64-dmd_2079-C9019ECA621321CC168B385F53D82831/knetquery.o: requires dynamic R_X86_64_32 reloc against '_D6object9Throwable7__

Re: inline asm return values

2018-03-25 Thread kinke via Digitalmars-d-learn
On Sunday, 25 March 2018 at 10:58:37 UTC, Dave Jones wrote: Is this stuff documented somewhere? See https://dlang.org/spec/abi.html#function_calling_conventions. It defines the D calling convention for Win32 (int return value in EAX) and states that it matches the C calling convention on all

Re: inline asm return values

2018-03-25 Thread Dave Jones via Digitalmars-d-learn
On Sunday, 25 March 2018 at 12:23:03 UTC, kinke wrote: On Sunday, 25 March 2018 at 10:58:37 UTC, Dave Jones wrote: Is this stuff documented somewhere? See https://dlang.org/spec/abi.html#function_calling_conventions. It defines the D calling convention for Win32 (int return value in EAX) an

Re: converting a number into bit array

2018-03-25 Thread Alex via Digitalmars-d-learn
On Sunday, 25 March 2018 at 11:32:56 UTC, Alex wrote: how to convert a number to a BitArray as fast as possible, given that the BitArray is already allocated to the needed length? Is bit checking the way to go, or is there a way to cast one to the other somehow? Via bit checking I would end w

Re: dmd download sig file, how do I use it

2018-03-25 Thread Ali via Digitalmars-d-learn
On Sunday, 25 March 2018 at 04:01:28 UTC, Seb wrote: gpg --verify --keyring ~/dlang/d-keyring.gpg --no-default-keyring dmd.2.079.0.linux.tar.xz.sig dmd.2.079.0.linux.tar.xz Thanks, I guess this kinda works I am now getting gpg: Signature made Fri 02 Mar 2018 01:47:57 PM EST gpg:

Help with specific template function

2018-03-25 Thread Vladimirs Nordholm via Digitalmars-d-learn
Hello Dlang community! I need help in creating a template function which would look like the following pseudo-code: void foo(, , , ...); // would be used as `void foo(x, y, arg1, arg2, ..., argN)` // valid examples: foo(5.332, 1, "a string", 123, "42"); foo(3, 44, false)

Re: Homebuilt dmd fails to link my dub application

2018-03-25 Thread Seb via Digitalmars-d-learn
On Sunday, 25 March 2018 at 12:05:32 UTC, Nordlöw wrote: If my homebuilt dmd fails to build my dub project with message /usr/bin/ld: error: .dub/build/application-unittest-linux.posix-x86_64-dmd_2079-C9019ECA621321CC168B385F53D82831/knetquery.o: requires dynamic R_X86_64_32 reloc against '_D6ob

Re: dmd download sig file, how do I use it

2018-03-25 Thread Seb via Digitalmars-d-learn
On Sunday, 25 March 2018 at 14:13:41 UTC, Ali wrote: (Note: the individual keys in the keyring are currently expired and we are working on rolling out a new keyring, but that doesn't affect yverifying the existing signatures.) while you are at it, also add a sha1 or a sh256 checksum, i think

Re: Help with specific template function

2018-03-25 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Sunday, 25 March 2018 at 18:24:37 UTC, Vladimirs Nordholm wrote: The underlying problems are: * How do I ensure the two first arguments (used as coordinates) are types of numbers (all kinds: ints, floats, reals, etc.) * At least one argument is passed after the coordinates I found a soluti

Re: Homebuilt dmd fails to link my dub application

2018-03-25 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 25 March 2018 at 18:43:09 UTC, Seb wrote: Are you on a 32-bit system? (For 64-bit -fPIC is the default since 2.072.2 - though DMD's build scripts were only updated a few releases later) No, I have my own build script for dmd, though because I can't get Digger to work either.

Re: Homebuilt dmd fails to link my dub application

2018-03-25 Thread Seb via Digitalmars-d-learn
On Sunday, 25 March 2018 at 20:26:22 UTC, Nordlöw wrote: On Sunday, 25 March 2018 at 18:43:09 UTC, Seb wrote: Are you on a 32-bit system? (For 64-bit -fPIC is the default since 2.072.2 - though DMD's build scripts were only updated a few releases later) No, I have my own build script for dmd,

The first example in the Learning D book, wont compile

2018-03-25 Thread Ali via Digitalmars-d-learn
Hi The first example in the Learning D book import core.thread; import std.stdio; void main() { import std.range: iota, range; write("Greeting in, "); foreach(num; iota(1, 4).range) { writef("%s...", num); stdout.flush(); Thread.sleep(1.seconds); } wr

Re: The first example in the Learning D book, wont compile

2018-03-25 Thread Ali via Digitalmars-d-learn
On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote: Hi The first example in the Learning D book import core.thread; import std.stdio; void main() { import std.range: iota, range; write("Greeting in, "); foreach(num; iota(1, 4).range) { writef("%s...", num); stdout.

Re: The first example in the Learning D book, wont compile

2018-03-25 Thread Seb via Digitalmars-d-learn
On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote: Hi The first example in the Learning D book import core.thread; import std.stdio; void main() { import std.range: iota, range; write("Greeting in, "); foreach(num; iota(1, 4).range) { writef("%s...", num); stdout.

Re: The first example in the Learning D book, wont compile

2018-03-25 Thread Ali via Digitalmars-d-learn
On Sunday, 25 March 2018 at 20:52:29 UTC, Ali wrote: On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote: I now see my typo, should be retro, not range We need better IDEs, this would have been easily highlighted by a good ide

Optional type - how to correctly reset a wrapped immutable T

2018-03-25 Thread aliak via Digitalmars-d-learn
Hi, I have this optional type I'm working on and I've run in to a little snag when it comes to wrapping an immutable. Basically what I want is for an Optional!(immutable T) to still be settable to "some" value or "no" value because the Optional wrapper itself is mutable. Optional!(immutable i

Re: Help with specific template function

2018-03-25 Thread aliak via Digitalmars-d-learn
On Sunday, 25 March 2018 at 19:06:14 UTC, Vladimirs Nordholm wrote: On Sunday, 25 March 2018 at 18:24:37 UTC, Vladimirs Nordholm wrote: The underlying problems are: * How do I ensure the two first arguments (used as coordinates) are types of numbers (all kinds: ints, floats, reals, etc.) * At

Aggressive conditional inlining with ldc only, not dmd

2018-03-25 Thread Nordlöw via Digitalmars-d-learn
Is there a way to make ldc do more aggressive inlining other than pragma(inline, true) ? Reason for asking is that https://github.com/nordlow/phobos-next/blob/master/src/open_hashmap_or_hashset.d achieves much better performance when I qualify some inner loop functions with pragma(

Re: Aggressive conditional inlining with ldc only, not dmd

2018-03-25 Thread kinke via Digitalmars-d-learn
On Sunday, 25 March 2018 at 22:09:43 UTC, Nordlöw wrote: And I haven't found a way to conditionally qualify these inner loop functions with `pragma(inline, true)` for the ldc case only. From https://dlang.org/spec/pragma.html#inline: 'If inside a function, it affects the function it is enclos

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-25 Thread Simen Kjærås via Digitalmars-d-learn
On Sunday, 25 March 2018 at 21:26:57 UTC, aliak wrote: struct Optional(T) { Unqual!T value; opAssign(T t) { value = cast(Unqual!T)(t); } } Consider this case: Optional!(immutable int) a = some(3); immutable int* p = &a.value; a = some(5); Clearly the above code shouldn't compile - y

Re: Aggressive conditional inlining with ldc only, not dmd

2018-03-25 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 25 March 2018 at 22:30:50 UTC, kinke wrote: void foo() { version(LDC) pragma(inline, true); // affects foo() ... } Wonderful, thanks!

Re: Help with specific template function

2018-03-25 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Sunday, 25 March 2018 at 21:31:16 UTC, aliak wrote: On Sunday, 25 March 2018 at 19:06:14 UTC, Vladimirs Nordholm wrote: On Sunday, 25 March 2018 at 18:24:37 UTC, Vladimirs Nordholm wrote: The underlying problems are: * How do I ensure the two first arguments (used as coordinates) are types

Re: Help with specific template function

2018-03-25 Thread rumbu via Digitalmars-d-learn
On Monday, 26 March 2018 at 06:40:34 UTC, Vladimirs Nordholm wrote: However I do not understand how to use that with my arguments. Eg. I would expect to do something like: void foo(X, Y, Args...)(X x, Y y, Args args) if(isNumeric!(x) && isNumeric!(y) && args.length >= 1) {

Re: Help with specific template function

2018-03-25 Thread arturg via Digitalmars-d-learn
On Monday, 26 March 2018 at 06:40:34 UTC, Vladimirs Nordholm wrote: How would I resolve this issue? use the type not the variables: isNumeric!X && isNumeric!Y