Skip to content

Commit 748775b

Browse files
authored
Add/improve docs for memorynew, pointerref, pointerset, getfield (#58290)
Just the docs changes from #57295.
1 parent ccef01a commit 748775b

File tree

4 files changed

+77
-17
lines changed

4 files changed

+77
-17
lines changed

base/docs/basedocs.jl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,14 +2470,19 @@ julia> Tuple(Real[1, 2, pi]) # takes a collection
24702470
tuple
24712471

24722472
"""
2473-
getfield(value, name::Symbol, [order::Symbol])
2474-
getfield(value, i::Int, [order::Symbol])
2475-
2476-
Extract a field from a composite `value` by name or position. Optionally, an
2477-
ordering can be defined for the operation. If the field was declared `@atomic`,
2478-
the specification is strongly recommended to be compatible with the stores to
2479-
that location. Otherwise, if not declared as `@atomic`, this parameter must be
2480-
`:not_atomic` if specified.
2473+
getfield(value, name::Symbol, [boundscheck::Bool=true], [order::Symbol])
2474+
getfield(value, i::Int, [boundscheck::Bool=true], [order::Symbol])
2475+
2476+
Extract a field from a composite `value` by name or position.
2477+
2478+
Optionally, an ordering can be defined for the operation. If the field was
2479+
declared `@atomic`, the specification is strongly recommended to be compatible
2480+
with the stores to that location. Otherwise, if not declared as `@atomic`, this
2481+
parameter must be `:not_atomic` if specified.
2482+
2483+
The bounds check may be disabled, in which case the behavior of this function is
2484+
undefined if `i` is out of bounds.
2485+
24812486
See also [`getproperty`](@ref Base.getproperty) and [`fieldnames`](@ref).
24822487
24832488
# Examples

base/docs/intrinsicsdocs.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ The `Core.Intrinsics` module holds the `Core.IntrinsicFunction` objects.
2222
"""
2323
Core.Intrinsics
2424

25+
"""
26+
Core.memorynew(::Type{T} where T <: GenericMemory, n::Int)
27+
28+
Construct an uninitialized [`GenericMemory`](@ref) of length `n`.
29+
30+
See also [`Memory`](@ref Core.Memory), [`Memory{T}(undef, n)`](@ref Core.Memory(::UndefInitializer, ::Int)).
31+
"""
32+
Core.memorynew
33+
2534
"""
2635
Core.memoryrefnew(::GenericMemory)
2736
Core.memoryrefnew(::GenericMemoryRef, index::Int, [boundscheck::Bool])
@@ -129,6 +138,35 @@ See also [`setpropertyonce!`](@ref Base.replaceproperty!) and [`Core.memoryrefse
129138
"""
130139
Core.memoryrefsetonce!
131140

141+
142+
"""
143+
Core.Intrinsics.pointerref(p::Ptr{T}, i::Int, align::Int)
144+
145+
Load a value of type `T` from the address of the `i`th element (1-indexed)
146+
starting at `p`. This is equivalent to the C expression `p[i-1]`.
147+
148+
The alignment must be a power of two, or 0, indicating the default alignment
149+
for `T`. If `p[i-1]` is out of bounds, invalid, or is not aligned, the behavior
150+
is undefined. An alignment of 1 is always safe.
151+
152+
See also [`unsafe_load`](@ref).
153+
"""
154+
Core.Intrinsics.pointerref
155+
156+
"""
157+
Core.Intrinsics.pointerset(p::Ptr{T}, x::T, i::Int, align::Int)
158+
159+
Store a value of type `T` to the address of the `i`th element (1-indexed)
160+
starting at `p`. This is equivalent to the C expression `p[i-1] = x`.
161+
162+
The alignment must be a power of two, or `0`, indicating the default alignment
163+
for `T`. If `p[i-1]` is out of bounds, invalid, or is not aligned, the behavior
164+
is undefined. An alignment of 1 is always safe.
165+
166+
See also [`unsafe_store!`](@ref).
167+
"""
168+
Core.Intrinsics.pointerset
169+
132170
"""
133171
Core.Intrinsics.atomic_pointerref(pointer::Ptr{T}, order::Symbol) --> T
134172

doc/src/base/arrays.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Base.StridedMatrix
3232
Base.StridedVecOrMat
3333
Base.GenericMemory
3434
Base.Memory
35+
Base.Memory(::UndefInitializer, ::Int)
3536
Base.memoryref
3637
Base.Slices
3738
Base.RowSlices

doc/src/devdocs/builtins.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
# [Core.Builtins](@id lib-builtins)
22

3-
## Builtin Function APIs
3+
The following builtin functions are considered unstable, but provide the basic
4+
definitions for what defines the abilities and behaviors of a Julia
5+
program. They are typically accessed through a higher level generic API.
46

5-
The following Builtin function APIs are considered unstable, but provide the basic
6-
definitions for what defines the abilities and behaviors of a Julia program. They are
7-
typically accessed through a higher level generic API.
7+
## Raw access to memory
88

99
```@docs
10+
Core.Intrinsics.pointerref
11+
Core.Intrinsics.pointerset
12+
Core.Intrinsics.atomic_pointerref
13+
Core.Intrinsics.atomic_pointerset
14+
Core.Intrinsics.atomic_pointerswap
15+
Core.Intrinsics.atomic_pointermodify
16+
Core.Intrinsics.atomic_pointerreplace
17+
```
18+
19+
## Managed memory
20+
21+
```@docs
22+
Core.memorynew
1023
Core.memoryrefnew
1124
Core.memoryrefoffset
1225
Core.memoryrefget
@@ -16,12 +29,15 @@ Core.memoryrefswap!
1629
Core.memoryrefmodify!
1730
Core.memoryrefreplace!
1831
Core.memoryrefsetonce!
19-
Core.Intrinsics.atomic_pointerref
20-
Core.Intrinsics.atomic_pointerset
21-
Core.Intrinsics.atomic_pointerswap
22-
Core.Intrinsics.atomic_pointermodify
23-
Core.Intrinsics.atomic_pointerreplace
32+
```
33+
34+
## Module bindings
35+
2436
Core.get_binding_type
37+
38+
## Other
39+
40+
```@docs
2541
Core.IntrinsicFunction
2642
Core.Intrinsics
2743
Core.IR

0 commit comments

Comments
 (0)