Skip to content

Commit

Permalink
fix alignment for atomics on PPC
Browse files Browse the repository at this point in the history
Following the 64-bit PowerPC ELF ABI specification all types should be
aligned to their own size.
  • Loading branch information
vchuravy committed Dec 2, 2016
1 parent fe47ed4 commit b5b5b74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion base/atomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ function alignment{T}(::Type{T})
# types, with the following exceptions: On 32- and 64-bit x86 platforms
# and on 64-bit SPARC platforms, atomic types of size 1, 2, 4, 8 or 16 -byte
# have the alignment that matches the size.
if Sys.ARCH === :x86_64 || Sys.ARCH === :i686
#
# Note for PPC:
# The OpenPower ABI for Linux Supplement -- 64-Bit ELF V2 ABI Specification
# defines that the alignments of types is sizeof(T).
if Sys.ARCH === :x86_64 || Sys.ARCH === :i686 ||
Sys.ARCH === :ppc64le || Sys.ARCH === Sys.ARCH === :powerpc64le
return sizeof(T)
end
return WORD_SIZE ÷ 8
Expand Down
3 changes: 2 additions & 1 deletion test/threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ let atomic_types = [Int8, Int16, Int32, Int64, Int128,
Float16, Float32, Float64]
# Temporarily omit 128-bit types on 32bit x86
# 128-bit atomics do not exist on AArch32.
# And we don't support them yet on power.
# And we don't support them yet on power, because they are lowered
# to `__sync_lock_test_and_set_16`.
if Sys.ARCH === :i686 || startswith(string(Sys.ARCH), "arm") ||
Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le
filter!(T -> sizeof(T)<=8, atomic_types)
Expand Down

0 comments on commit b5b5b74

Please sign in to comment.