Re: memcpy in D

2013-07-01 Thread Ali Çehreli
On 07/01/2013 03:23 PM, Tyro[17] wrote: > So just to confirm my understanding: Because the address at memory is > casted to ushort* in defining base, every iteration of the foreach loop > advances the pointer two bytes into the array? Yes. The incerement operator on a pointer advances the pointe

Re: memcpy in D

2013-07-01 Thread Tyro[17]
I'd just like to say thanks for your suggestions and quite complete solutions. I particularly liked the alternate implementation presented by Marco. I must admit that I did not understand what was happening at first. So just to confirm my understanding: Because the address at memory is casted

Re: memcpy in D

2013-06-30 Thread Marco Leise
... or alternatively: // Simple integers can be compile-time literals (i.e. C's #define) enum ADDRESS_BUS_SIZE = 20; // 2^20 address bus // In D it is more ideomatic to put the array length first. // For example this wouldn't work: byte x, *y, memory[1 << ADDRESS_BUS_SIZE]; byte[1 << ADDRESS_BUS_S

Re: memcpy in D

2013-06-30 Thread Marco Leise
Am Sun, 30 Jun 2013 07:07:23 -0400 schrieb "Tyro[17]" : > What is the equivalent of memcpy > > module memcopy; > > immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus > byte memory[1 << ADDRESS_BUS_SIZE]; > > void main() > { > ushort val = 12345; > > for (int i = 0x12340; i < 0x12

Re: memcpy in D

2013-06-30 Thread Steven Schveighoffer
On Sun, 30 Jun 2013 07:40:31 -0400, monarch_dodra wrote: On Sunday, 30 June 2013 at 11:07:24 UTC, Tyro[17] wrote: What is the equivalent of memcpy module memcopy; immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus byte memory[1 << ADDRESS_BUS_SIZE]; void main() { ushort val = 12

Re: memcpy in D

2013-06-30 Thread monarch_dodra
On Sunday, 30 June 2013 at 11:47:49 UTC, David wrote: Doing it this way has the advantage of being CTFE-able, and (potentially) faster, as everything I ever read about D's memcpy is that it is slow. On Windows? Doesn't memcpy use libc memcpy on Linux? I honestly have no idea, I'm just repea

Re: memcpy in D

2013-06-30 Thread Dmitry Olshansky
30-Jun-2013 15:47, David пишет: Doing it this way has the advantage of being CTFE-able, and (potentially) faster, as everything I ever read about D's memcpy is that it is slow. On Windows? Doesn't memcpy use libc memcpy on Linux? Yup on Linux is pretty darn fast just as is with C/C++. It's th

Re: memcpy in D

2013-06-30 Thread David
> Doing it this way has the advantage of being CTFE-able, and > (potentially) faster, as everything I ever read about D's memcpy is that > it is slow. On Windows? Doesn't memcpy use libc memcpy on Linux?

Re: memcpy in D

2013-06-30 Thread monarch_dodra
On Sunday, 30 June 2013 at 11:07:24 UTC, Tyro[17] wrote: What is the equivalent of memcpy module memcopy; immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus byte memory[1 << ADDRESS_BUS_SIZE]; void main() { ushort val = 12345; for (int i = 0x12340; i < 0x1234A; i+= 2) {

memcpy in D

2013-06-30 Thread Tyro[17]
What is the equivalent of memcpy module memcopy; immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus byte memory[1 << ADDRESS_BUS_SIZE]; void main() { ushort val = 12345; for (int i = 0x12340; i < 0x1234A; i+= 2) { memcpy (&memory[i], &val, sizeof val); // D wa