Skip to content

Commit 19ff023

Browse files
committed
fixes
1 parent cbb8f21 commit 19ff023

File tree

8 files changed

+22
-24
lines changed

8 files changed

+22
-24
lines changed

NEWS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ Command-line option changes
3131
Multi-threading changes
3232
-----------------------
3333
* If the `JULIA_NUM_THREADS` environment variable is set to `auto`, then the number of threads will be set to the number of CPU threads ([#38952])
34-
35-
* Intrinsics for atomic pointer operations are now defined for certain byte sizes.
34+
* Intrinsics for atomic pointer operations are now defined for certain byte sizes. ([#37847])
3635
* Support for declaring and using individual fields of a mutable struct as
37-
atomic now available.
36+
atomic now available. ([#37847])
3837

3938

4039
Build system changes

base/Base.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ getproperty(x, f::Symbol, order::Symbol) = (@_inline_meta; getfield(x, f, order)
5555
setproperty!(x, f::Symbol, v, order::Symbol) = (@_inline_meta; setfield!(x, f, convert(fieldtype(typeof(x), f), v), order))
5656

5757
swapproperty!(x, f::Symbol, v, order::Symbol=:notatomic) =
58-
Core.swapfield!(x, f, convert(fieldtype(typeof(x), f), v), order)
58+
(@_inline_meta; Core.swapfield!(x, f, convert(fieldtype(typeof(x), f), v), order))
5959
modifyproperty!(x, f::Symbol, op, v, order::Symbol=:notatomic) =
60-
Core.modifyfield!(x, f, op, v, order)
60+
(@_inline_meta; Core.modifyfield!(x, f, op, v, order))
6161
cmpswapproperty!(x, f::Symbol, expected, desired, success_order::Symbol=:notatomic, fail_order::Symbol=success_order) =
62-
Core.cmpswapfield!(x, f, expected, convert(fieldtype(typeof(x), f), desired), success_order, fail_order)
62+
(@_inline_meta; Core.cmpswapfield!(x, f, expected, convert(fieldtype(typeof(x), f), desired), success_order, fail_order))
6363

6464

6565
include("coreio.jl")

base/condition.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@noinline function concurrency_violation()
66
# can be useful for debugging
77
#try; error(); catch; ccall(:jlbacktrace, Cvoid, ()); end
8-
throw(ConcurrencyViolationError("concurrency violation detected"))
8+
throw(ConcurrencyViolationError("lock must be held"))
99
end
1010

1111
"""

base/docs/basedocs.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,7 +2693,7 @@ See also [`setfield!`](@ref Core.setfield!),
26932693
Base.setproperty!
26942694

26952695
"""
2696-
swapproperty!(x, f::Symbol, v, order::Symbol=:notatomic)
2696+
swapproperty!(x, f::Symbol, v, order::Symbol=:not_atomic)
26972697
26982698
The syntax `@atomic a.b, _ = c, a.b` returns `(c, swapproperty!(a, :b, c, :sequentially_consistent))`,
26992699
where there must be one getfield expression common to both sides.
@@ -2704,7 +2704,7 @@ and [`setproperty!`](@ref Base.setproperty!).
27042704
Base.swapproperty!
27052705

27062706
"""
2707-
modifyproperty!(x, f::Symbol, op, v, order::Symbol=:notatomic)
2707+
modifyproperty!(x, f::Symbol, op, v, order::Symbol=:not_atomic)
27082708
27092709
The syntax `@atomic a().b = max(a().b, c)` returns `modifyproperty!(a(), :b,
27102710
max, c, :sequentially_consistent))`, where the first argument must be a
@@ -2716,7 +2716,7 @@ and [`setproperty!`](@ref Base.setproperty!).
27162716
Base.modifyproperty!
27172717

27182718
"""
2719-
cmpswapproperty!(x, f::Symbol, expected, desired, success_order::Symbol=:notatomic, fail_order::Symbol=success_order)
2719+
cmpswapproperty!(x, f::Symbol, expected, desired, success_order::Symbol=:not_atomic, fail_order::Symbol=success_order)
27202720
27212721
Perform a compare-and-swap operation on `x.f` from `expected` to `desired`, per
27222722
egal (there is no convenient `@atomic` syntax for this).

base/expr.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ julia> z
485485
486486
The following forms are also planned, but not yet implemented:
487487
```julia
488-
# @atomic +!(a.x, 1) # increment field x of a
489488
# @atomic a.x = +(a.x, 1) # increment field x of a
490489
# @atomic a.x = +(_, 1) # increment field x of a
491490
```

src/builtins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ enum jl_memory_order jl_get_atomic_order(jl_sym_t *order, char loading, char sto
824824
enum jl_memory_order jl_get_atomic_order_checked(jl_sym_t *order, char loading, char storing)
825825
{
826826
enum jl_memory_order mo = jl_get_atomic_order(order, loading, storing);
827-
if (mo < 0) // notatomic or invalid
827+
if (mo < 0) // invalid
828828
jl_atomic_error("invalid atomic ordering");
829829
return mo;
830830
}

src/runtime_intrinsics.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ JL_DLLEXPORT jl_value_t *jl_atomic_pointerref(jl_value_t *p, jl_value_t *order)
9090
jl_error("pointerref: invalid pointer");
9191
size_t nb = jl_datatype_size(ety);
9292
if ((nb & (nb - 1)) != 0 || nb > MAX_POINTERATOMIC_SIZE)
93-
jl_error("pointerref: invalid atomic operation");
93+
jl_error("pointerref: invalid pointer for atomic operation");
9494
return jl_atomic_new_bits(ety, pp);
9595
}
9696
}
@@ -112,7 +112,7 @@ JL_DLLEXPORT jl_value_t *jl_atomic_pointerset(jl_value_t *p, jl_value_t *x, jl_v
112112
jl_type_error("pointerset", ety, x);
113113
size_t nb = jl_datatype_size(ety);
114114
if ((nb & (nb - 1)) != 0 || nb > MAX_POINTERATOMIC_SIZE)
115-
jl_error("pointerset: invalid atomic operation");
115+
jl_error("pointerset: invalid pointer for atomic operation");
116116
jl_atomic_store_bits(pp, x, nb);
117117
}
118118
return p;
@@ -136,7 +136,7 @@ JL_DLLEXPORT jl_value_t *jl_atomic_pointerswap(jl_value_t *p, jl_value_t *x, jl_
136136
jl_type_error("pointerswap", ety, x);
137137
size_t nb = jl_datatype_size(ety);
138138
if ((nb & (nb - 1)) != 0 || nb > MAX_POINTERATOMIC_SIZE)
139-
jl_error("pointerswap: invalid atomic operation");
139+
jl_error("pointerswap: invalid pointer for atomic operation");
140140
y = jl_atomic_swap_bits(ety, pp, x, nb);
141141
}
142142
return y;
@@ -211,7 +211,7 @@ JL_DLLEXPORT jl_value_t *jl_atomic_pointercmpswap(jl_value_t *p, jl_value_t *exp
211211
jl_type_error("pointercmpswap", ety, x);
212212
size_t nb = jl_datatype_size(ety);
213213
if ((nb & (nb - 1)) != 0 || nb > MAX_POINTERATOMIC_SIZE)
214-
jl_error("pointercmpswap: invalid atomic operation");
214+
jl_error("pointercmpswap: invalid pointer for atomic operation");
215215
return jl_atomic_cmpswap_bits((jl_datatype_t*)ety, pp, expected, x, nb);
216216
}
217217
}

test/intrinsics.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ for TT in (Int8, Int16, Int32, Int64, Int128, Int256, Int512, Complex{Int32}, Co
183183
@test_throws TypeError Core.Intrinsics.atomic_pointercmpswap(p, T(100), S(2), :sequentially_consistent, :sequentially_consistent)
184184
end
185185
@test Core.Intrinsics.pointerref(p, 1, 1) === T(10) === r[]
186-
if sizeof(r) > 2 * sizeof(Int)
187-
@test_throws ErrorException("pointerref: invalid atomic operation") Core.Intrinsics.atomic_pointerref(p, :sequentially_consistent)
188-
@test_throws ErrorException("pointerset: invalid atomic operation") Core.Intrinsics.atomic_pointerset(p, T(1), :sequentially_consistent)
189-
@test_throws ErrorException("pointerswap: invalid atomic operation") Core.Intrinsics.atomic_pointerswap(p, T(100), :sequentially_consistent)
190-
@test_throws ErrorException("pointerref: invalid atomic operation") Core.Intrinsics.atomic_pointermodify(p, add, T(1), :sequentially_consistent)
191-
@test_throws ErrorException("pointerref: invalid atomic operation") Core.Intrinsics.atomic_pointermodify(p, swap, S(1), :sequentially_consistent)
192-
@test_throws ErrorException("pointercmpswap: invalid atomic operation") Core.Intrinsics.atomic_pointercmpswap(p, T(100), T(2), :sequentially_consistent, :sequentially_consistent)
193-
@test_throws ErrorException("pointercmpswap: invalid atomic operation") Core.Intrinsics.atomic_pointercmpswap(p, S(100), T(2), :sequentially_consistent, :sequentially_consistent)
186+
if sizeof(r) > 8
187+
@test_throws ErrorException("pointerref: invalid pointer for atomic operation") Core.Intrinsics.atomic_pointerref(p, :sequentially_consistent)
188+
@test_throws ErrorException("pointerset: invalid pointer for atomic operation") Core.Intrinsics.atomic_pointerset(p, T(1), :sequentially_consistent)
189+
@test_throws ErrorException("pointerswap: invalid pointer for atomic operation") Core.Intrinsics.atomic_pointerswap(p, T(100), :sequentially_consistent)
190+
@test_throws ErrorException("pointerref: invalid pointer for atomic operation") Core.Intrinsics.atomic_pointermodify(p, add, T(1), :sequentially_consistent)
191+
@test_throws ErrorException("pointerref: invalid pointer for atomic operation") Core.Intrinsics.atomic_pointermodify(p, swap, S(1), :sequentially_consistent)
192+
@test_throws ErrorException("pointercmpswap: invalid pointer for atomic operation") Core.Intrinsics.atomic_pointercmpswap(p, T(100), T(2), :sequentially_consistent, :sequentially_consistent)
193+
@test_throws ErrorException("pointercmpswap: invalid pointer for atomic operation") Core.Intrinsics.atomic_pointercmpswap(p, S(100), T(2), :sequentially_consistent, :sequentially_consistent)
194194
@test Core.Intrinsics.pointerref(p, 1, 1) === T(10) === r[]
195195
else
196196
TT !== Any && @test_throws TypeError Core.Intrinsics.atomic_pointermodify(p, swap, S(1), :sequentially_consistent)

0 commit comments

Comments
 (0)