File tree Expand file tree Collapse file tree 5 files changed +72
-3
lines changed Expand file tree Collapse file tree 5 files changed +72
-3
lines changed Original file line number Diff line number Diff line change 2323# define PLATFORM_IS_POWERPC
2424#endif
2525
26+ #if defined(__sparc__)
27+ # define PLATFORM_IS_SPARC
28+ #endif
29+
2630namespace snmalloc
2731{
2832 /* *
@@ -54,6 +58,7 @@ namespace snmalloc
5458 PowerPC,
5559 X86,
5660 X86_SGX,
61+ Sparc,
5762 };
5863
5964 /* *
@@ -147,6 +152,8 @@ namespace snmalloc
147152# include " aal_arm.h"
148153#elif defined(PLATFORM_IS_POWERPC)
149154# include " aal_powerpc.h"
155+ #elif defined(PLATFORM_IS_SPARC)
156+ # include " aal_sparc.h"
150157#endif
151158
152159namespace snmalloc
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #if defined(__arch64__) // More reliable than __sparc64__
4+ # define SNMALLOC_VA_BITS_64
5+ #else
6+ # define SNMALLOC_VA_BITS_32
7+ #endif
8+
9+ namespace snmalloc
10+ {
11+ /* *
12+ * Sparc architecture abstraction layer.
13+ */
14+ class AAL_Sparc
15+ {
16+ public:
17+ /* *
18+ * Bitmap of AalFeature flags
19+ */
20+ static constexpr uint64_t aal_features = IntegerPointers;
21+
22+ static constexpr enum AalName aal_name = Sparc;
23+
24+ #ifdef SNMALLOC_VA_BITS_64
25+ /* *
26+ * Even Ultra-Sparc I supports 8192 and onwards
27+ */
28+ static constexpr size_t smallest_page_size = 0x2000 ;
29+ #else
30+ static constexpr size_t smallest_page_size = 0x1000 ;
31+ #endif
32+
33+ /* *
34+ * On Sparc ideally pause instructions ought to be
35+ * optimised per Sparc processor but here a version
36+ * as least common denominator to avoid numerous ifdef,
37+ * reading Conditions Code Register here
38+ */
39+ static inline void pause ()
40+ {
41+ __asm__ volatile (" rd %%ccr, %%g0" ::: " memory" );
42+ }
43+
44+ static inline void prefetch (void * ptr)
45+ {
46+ #ifdef SNMALLOC_VA_BITS_64
47+ __asm__ volatile (" prefetch [%0], 0" ::" r" (ptr));
48+ #else
49+ UNUSED (ptr);
50+ #endif
51+ }
52+
53+ static inline uint64_t tick ()
54+ {
55+ uint64_t tick;
56+ __asm__ volatile (" rd %%asr4, %0" : " =r" (tick));
57+ return tick;
58+ }
59+ };
60+
61+ using AAL_Arch = AAL_Sparc;
62+ } // namespace snmalloc
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ namespace snmalloc
2626 static constexpr uint64_t pal_features = PALPOSIX::pal_features;
2727
2828 static constexpr size_t page_size =
29- Aal::aal_name == PowerPC ? 0x10000 : 0x1000 ;
29+ Aal::aal_name == PowerPC ? 0x10000 : PALPOSIX::page_size ;
3030
3131 /* *
3232 * OS specific function for zeroing memory.
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ namespace snmalloc
3939 */
4040 static constexpr uint64_t pal_features = 0 ;
4141
42- static constexpr size_t page_size = 0x1000 ;
42+ static constexpr size_t page_size = Aal::smallest_page_size ;
4343
4444 [[noreturn]] static void error (const char * const str)
4545 {
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ namespace snmalloc
9898 */
9999 static constexpr uint64_t pal_features = LazyCommit;
100100
101- static constexpr size_t page_size = 0x1000 ;
101+ static constexpr size_t page_size = Aal::smallest_page_size ;
102102
103103 static void print_stack_trace ()
104104 {
You can’t perform that action at this time.
0 commit comments