[OT] .net is getting slices

via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 14 17:33:39 PDT 2017


On Friday, 14 July 2017 at 12:50:56 UTC, Kagamin wrote:
> On Friday, 14 July 2017 at 12:25:47 UTC, Petar Kirov 
> [ZombineDev] wrote:
>> core.atomic supports 2 * (void*).sizeof atomicLoad, 
>> atomicStore and cas (compare-and-swap) on platforms that 
>> support it (x86 and x86_64 for sure, and for others you have 
>> to check what libatomic (GCC) and llvm do).
>
> If it's not cross-platform, that's a problem.

In theory yes, in practice probably not. Are you worried that 
your code needs to run on platforms where bytes are 9-bit wide? 
What's more, not all CPUs support atomic loads and stores of 8 
bytes, so .NET's Interlocked API that takes System.Double 
arguments is not cross-platform either.
I personally prefer D's approach where you can check at 
compile-time for has64BitCAS on 32-bit targets and has128BitCAS 
on 64-bit ones and write your algorithms accordingly. 
Design-by-Introspection FTW.


More information about the Digitalmars-d mailing list