
D front-end changes: - Backported built-in function handling from upstream. - Added new intrinsic `byteswap(ushort)`. Druntime changes: - Update intrinsic modules core.bitop, core.checkedint, core.simd, core.vararg, and core.volatile. - Backport platform-specific fixes for runtime modules core.cpuid, core.internal.traits, and rt.lifetime. - Backport openbsd fixes for core.stdc.stdio. - Backport solaris fixes for core.sys.posix.locale, and core.thread.osthread (PR98910). gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 46133f761. * d-builtins.cc (d_build_builtins_module): Set builtins as BUILTINgcc. (maybe_set_builtin_1): Likewise. * d-frontend.cc (eval_builtin): Adjust condition for early return. * intrinsics.cc (maybe_set_intrinsic): Set intrinsics as BUILTINgcc. (maybe_expand_intrinsic): Add case for INTRINSIC_BSWAP16. * intrinsics.def (INTRINSIC_BT): Update signature. (INTRINSIC_BT64): Likewise. (INTRINSIC_BSWAP16): New intrinsic. (INTRINSIC_VLOAD8): Update module. (INTRINSIC_VLOAD16): Likewise. (INTRINSIC_VLOAD32): Likewise. (INTRINSIC_VLOAD64): Likewise. (INTRINSIC_VSTORE8): Likewise. (INTRINSIC_VSTORE16): Likewise. (INTRINSIC_VSTORE32): Likewise. (INTRINSIC_VSTORE64): Likewise. (INTRINSIC_ADDS): Update signature. (INTRINSIC_ADDSL): Likewise. (INTRINSIC_ADDU): Likewise. (INTRINSIC_ADDUL): Likewise. (INTRINSIC_SUBS): Likewise. (INTRINSIC_SUBSL): Likewise. (INTRINSIC_SUBU): Likewise. (INTRINSIC_SUBUL): Likewise. (INTRINSIC_MULS): Likewise. (INTRINSIC_MULSL): Likewise. (INTRINSIC_MULU): Likewise. (INTRINSIC_MULUI): Likewise. (INTRINSIC_MULUL): Likewise. (INTRINSIC_NEGS): Likewise. (INTRINSIC_NEGSL): Likewise. libphobos/ChangeLog: PR d/98910 * libdruntime/MERGE: Merge upstream druntime 0fd4364c. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/volatile.d. * libdruntime/Makefile.in: Regenerate. * testsuite/libphobos.allocations/tls_gc_integration.d: Update test. gcc/testsuite/ChangeLog: * gdc.dg/intrinsics.d: Update test.
67 lines
2.6 KiB
D
67 lines
2.6 KiB
D
/**
|
|
* This module declares intrinsics for volatile operations.
|
|
*
|
|
* Copyright: Copyright © 2019, The D Language Foundation
|
|
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
|
|
* Authors: Walter Bright, Ernesto Castellotti
|
|
* Source: $(DRUNTIMESRC core/volatile.d)
|
|
*/
|
|
|
|
module core.volatile;
|
|
|
|
nothrow:
|
|
@safe:
|
|
@nogc:
|
|
|
|
/*************************************
|
|
* Read/write value from/to the memory location indicated by ptr.
|
|
*
|
|
* These functions are recognized by the compiler, and calls to them are guaranteed
|
|
* to not be removed (as dead assignment elimination or presumed to have no effect)
|
|
* or reordered in the same thread.
|
|
*
|
|
* These reordering guarantees are only made with regards to other
|
|
* operations done through these functions; the compiler is free to reorder regular
|
|
* loads/stores with regards to loads/stores done through these functions.
|
|
*
|
|
* This is useful when dealing with memory-mapped I/O (MMIO) where a store can
|
|
* have an effect other than just writing a value, or where sequential loads
|
|
* with no intervening stores can retrieve
|
|
* different values from the same location due to external stores to the location.
|
|
*
|
|
* These functions will, when possible, do the load/store as a single operation. In
|
|
* general, this is possible when the size of the operation is less than or equal to
|
|
* $(D (void*).sizeof), although some targets may support larger operations. If the
|
|
* load/store cannot be done as a single operation, multiple smaller operations will be used.
|
|
*
|
|
* These are not to be conflated with atomic operations. They do not guarantee any
|
|
* atomicity. This may be provided by coincidence as a result of the instructions
|
|
* used on the target, but this should not be relied on for portable programs.
|
|
* Further, no memory fences are implied by these functions.
|
|
* They should not be used for communication between threads.
|
|
* They may be used to guarantee a write or read cycle occurs at a specified address.
|
|
*/
|
|
|
|
ubyte volatileLoad(ubyte * ptr);
|
|
ushort volatileLoad(ushort* ptr); /// ditto
|
|
uint volatileLoad(uint * ptr); /// ditto
|
|
ulong volatileLoad(ulong * ptr); /// ditto
|
|
|
|
void volatileStore(ubyte * ptr, ubyte value); /// ditto
|
|
void volatileStore(ushort* ptr, ushort value); /// ditto
|
|
void volatileStore(uint * ptr, uint value); /// ditto
|
|
void volatileStore(ulong * ptr, ulong value); /// ditto
|
|
|
|
@system unittest
|
|
{
|
|
alias TT(T...) = T;
|
|
|
|
foreach (T; TT!(ubyte, ushort, uint, ulong))
|
|
{
|
|
T u;
|
|
T* p = &u;
|
|
volatileStore(p, 1);
|
|
T r = volatileLoad(p);
|
|
assert(r == u);
|
|
}
|
|
}
|