www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - core.atomic for ldc.

reply vitamin <vit vit.vit> writes:
Exists for LDC library like core.atomic?
Jan 31 2021
next sibling parent vitamin <vit vit.vit> writes:
On Sunday, 31 January 2021 at 12:51:57 UTC, vitamin wrote:
 Exists for LDC library like core.atomic?
It look like that dub compile with ldc but use dmd runtime and module core.internal.atomic has version only for dmd and gdc. How to make ldc use ldc runtime?
Jan 31 2021
prev sibling parent reply rikki cattermole <rikki cattermole.co.nz> writes:
The only difference between dmd, ldc and gdc (in effect) is the backend.
While druntime and Phobos will be patched for other platform targets, 
over all its the same library.

The same goes for core.atomic. You should not need to know that it has 
been patched. If you can call it and it gives you the right results, you 
can assume it worked.

Oh and $ dub build --compiler=ldc2
Jan 31 2021
parent reply vitamin <vit vit.vit> writes:
On Monday, 1 February 2021 at 05:23:52 UTC, rikki cattermole 
wrote:
 The only difference between dmd, ldc and gdc (in effect) is the 
 backend.
 While druntime and Phobos will be patched for other platform 
 targets, over all its the same library.

 The same goes for core.atomic. You should not need to know that 
 it has been patched. If you can call it and it gives you the 
 right results, you can assume it worked.

 Oh and $ dub build --compiler=ldc2
problem is when I build with ldc then id doesn't work and with dmd it does: try compile this with ldc: https://run.dlang.io/is/gngLFu error on webite run.dlang.io is same as I have.
Jan 31 2021
parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 1 February 2021 at 06:12:59 UTC, vitamin wrote:
 On Monday, 1 February 2021 at 05:23:52 UTC, rikki cattermole 
 wrote:
 The only difference between dmd, ldc and gdc (in effect) is 
 the backend.
 While druntime and Phobos will be patched for other platform 
 targets, over all its the same library.

 The same goes for core.atomic. You should not need to know 
 that it has been patched. If you can call it and it gives you 
 the right results, you can assume it worked.

 Oh and $ dub build --compiler=ldc2
problem is when I build with ldc then id doesn't work and with dmd it does: try compile this with ldc: https://run.dlang.io/is/gngLFu error on webite run.dlang.io is same as I have.
LDC has all LLVM intrinsics so try --- import ldc.intrinsics; ldc.intrinsics.llvm_atomic_rmw_add(...); ---
Jan 31 2021
parent reply vitamin <vit vit.vit> writes:
On Monday, 1 February 2021 at 06:38:16 UTC, Basile B. wrote:
 On Monday, 1 February 2021 at 06:12:59 UTC, vitamin wrote:
 On Monday, 1 February 2021 at 05:23:52 UTC, rikki cattermole 
 wrote:
 The only difference between dmd, ldc and gdc (in effect) is 
 the backend.
 While druntime and Phobos will be patched for other platform 
 targets, over all its the same library.

 The same goes for core.atomic. You should not need to know 
 that it has been patched. If you can call it and it gives you 
 the right results, you can assume it worked.

 Oh and $ dub build --compiler=ldc2
problem is when I build with ldc then id doesn't work and with dmd it does: try compile this with ldc: https://run.dlang.io/is/gngLFu error on webite run.dlang.io is same as I have.
LDC has all LLVM intrinsics so try --- import ldc.intrinsics; ldc.intrinsics.llvm_atomic_rmw_add(...); ---
It look like atomicFetchAdd a atomicFetchSub was added to ldc 8 days ago and my distro has old version. I replace core.internal.atomic with this https://raw.githubusercontent.com/ldc-developers/druntime/ldc/src/co e/internal/atomic.d and now everything works.
Jan 31 2021
parent rm <rymrg memail.com> writes:
 It look like atomicFetchAdd a atomicFetchSub was added to ldc 8 days ago 
 and my distro has old version. I replace core.internal.atomic with this 
 https://raw.githubusercontent.com/ldc-developers/druntime/ldc/src/co
e/internal/atomic.d 
 and now everything works.
It's not even in the latest stable version. Should be available in next release. Also, please note that I haven't had the time to check if anything else was missing. If you do spot something else that is missing, please let me know.
Feb 03 2021