@@ -14,7 +14,8 @@ use core::ops::{Deref, DerefMut};
14
14
/// Cache lines are assumed to be N bytes long, depending on the architecture:
15
15
///
16
16
/// * On x86-64, aarch64, and powerpc64, N = 128.
17
- /// * On arm, mips, mips64, and riscv64, N = 32.
17
+ /// * On arm, mips, mips64, riscv32, riscv64, sparc, and hexagon, N = 32.
18
+ /// * On m68k, N = 16.
18
19
/// * On s390x, N = 256.
19
20
/// * On all others, N = 64.
20
21
///
@@ -83,33 +84,47 @@ use core::ops::{Deref, DerefMut};
83
84
) ,
84
85
repr( align( 128 ) )
85
86
) ]
86
- // arm, mips, mips64, and riscv64 have 32-byte cache line size.
87
+ // arm, mips, mips64, riscv64, sparc, and hexagon have 32-byte cache line size.
87
88
//
88
89
// Sources:
89
90
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_arm.go#L7
90
91
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips.go#L7
91
92
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mipsle.go#L7
92
93
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips64x.go#L9
93
94
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_riscv64.go#L7
95
+ // - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L17
96
+ // - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/hexagon/include/asm/cache.h#L12
97
+ //
98
+ // riscv32 is assumed not to exceed the cache line size of riscv64.
94
99
#[ cfg_attr(
95
100
any(
96
101
target_arch = "arm" ,
97
102
target_arch = "mips" ,
98
103
target_arch = "mips64" ,
104
+ target_arch = "riscv32" ,
99
105
target_arch = "riscv64" ,
106
+ target_arch = "sparc" ,
107
+ target_arch = "hexagon" ,
100
108
) ,
101
109
repr( align( 32 ) )
102
110
) ]
111
+ // m68k has 16-byte cache line size.
112
+ //
113
+ // Sources:
114
+ // - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/m68k/include/asm/cache.h#L9
115
+ #[ cfg_attr( target_arch = "m68k" , repr( align( 16 ) ) ) ]
103
116
// s390x has 256-byte cache line size.
104
117
//
105
118
// Sources:
106
119
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_s390x.go#L7
120
+ // - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/s390/include/asm/cache.h#L13
107
121
#[ cfg_attr( target_arch = "s390x" , repr( align( 256 ) ) ) ]
108
- // x86 and wasm have 64-byte cache line size.
122
+ // x86, wasm, and sparc64 have 64-byte cache line size.
109
123
//
110
124
// Sources:
111
125
// - https://github.com/golang/go/blob/dda2991c2ea0c5914714469c4defc2562a907230/src/internal/cpu/cpu_x86.go#L9
112
126
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_wasm.go#L7
127
+ // - https://github.com/torvalds/linux/blob/3516bd729358a2a9b090c1905bd2a3fa926e24c6/arch/sparc/include/asm/cache.h#L19
113
128
//
114
129
// All others are assumed to have 64-byte cache line size.
115
130
#[ cfg_attr(
@@ -120,7 +135,11 @@ use core::ops::{Deref, DerefMut};
120
135
target_arch = "arm" ,
121
136
target_arch = "mips" ,
122
137
target_arch = "mips64" ,
138
+ target_arch = "riscv32" ,
123
139
target_arch = "riscv64" ,
140
+ target_arch = "sparc" ,
141
+ target_arch = "hexagon" ,
142
+ target_arch = "m68k" ,
124
143
target_arch = "s390x" ,
125
144
) ) ,
126
145
repr( align( 64 ) )
0 commit comments