Re: Global thread-local free-list allocator

2023-03-16 Thread Witold via Digitalmars-d-learn
On Thursday, 16 March 2023 at 20:53:28 UTC, Witold wrote: It crashes at `new_.value`, as `new_` is `null` It looks like this: ```d alias VariableAllocator = ThreadLocal!(FreeList!(Mallocator, Variable.sizeof, unbounded)); ``` should be this instead: ```d alias VariableAllocator = ThreadL

Any ways to get addr2line working with DMD? works fine with GDC

2023-03-16 Thread ryuukk_ via Digitalmars-d-learn
Hello, I'm trying to catch segfaults, after reading lot of ressources online, i came up with this: ```D import core.stdc.signal: SIGSEGV, SIGFPE, SIGILL, SIGABRT, signal; import core.stdc.stdlib: free; import core.stdc.string: strlen; import core.sys.posix.unistd: STDERR_FILENO, readlink; impo

Re: read/peek and automatically advance index in buffer

2023-03-16 Thread jwatson-CO-edu via Digitalmars-d-learn
On Thursday, 16 March 2023 at 18:58:18 UTC, ag0aep6g wrote: On Thursday, 16 March 2023 at 18:39:00 UTC, jwatson-CO-edu wrote: ```d int rtnVal = buffer.peek(int,Endian.bigEndian)(&marker); // Error: found `,` when expecting `.` following int ``` You just forgot the exclamation mark there. "th

Global thread-local free-list allocator

2023-03-16 Thread Witold via Digitalmars-d-learn
I ported a classic DeltaBlue benchmark to D, and for allocations I use a mix of malloc/free (for structs with some trailing inline arrays), and new for some other structs and arrays. After running it, it felt kind of slow (I did not compare it to any other language yet, so no idea if it is act

Re: read/peek and automatically advance index in buffer

2023-03-16 Thread ag0aep6g via Digitalmars-d-learn
On Thursday, 16 March 2023 at 18:39:00 UTC, jwatson-CO-edu wrote: ```d int rtnVal = buffer.peek(int,Endian.bigEndian)(&marker); // Error: found `,` when expecting `.` following int ``` You just forgot the exclamation mark there.

read/peek and automatically advance index in buffer

2023-03-16 Thread jwatson-CO-edu via Digitalmars-d-learn
I read a file into a `ubyte` buffer as shown: ```d \\ ... buffer = cast(ubyte[]) read( fName ); // Read the entire file as bytestring marker = 0; // Current index to read from, managed manually, :( \\ ... ``` The data file contains numbers of varying size, and I want to read them sequentially

Re: Is comparison of shared data thread-safe?

2023-03-16 Thread Nick Treleaven via Digitalmars-d-learn
On Thursday, 16 March 2023 at 12:32:34 UTC, Nick Treleaven wrote: With -preview=nosharedaccess, I get: int y = 2; shared int x = y; // OK assert(x == 2); // no error y = x; // error This also does not error: ```d bool b = x == 3; ``` Filed: https://issues.dlang.org/show_bug.cg

Is comparison of shared data thread-safe?

2023-03-16 Thread Nick Treleaven via Digitalmars-d-learn
With -preview=nosharedaccess, I get: int y = 2; shared int x = y; // OK assert(x == 2); // no error y = x; // error So for the assignment to y, reading x is an error and atomicLoad should be used instead. But is it an oversight that reading x in the assert is not an error? I

Re: evenChunks on a string - hasLength constraint fails?

2023-03-16 Thread amarillion via Digitalmars-d-learn
On Tuesday, 14 March 2023 at 18:41:50 UTC, Paul Backus wrote: On Tuesday, 14 March 2023 at 08:21:00 UTC, amarillion wrote: I'm trying to understand why this doesn't work. I don't really understand the error. If I interpret this correctly, it's missing a length attribute on a string, but shouldn