diff --git a/src/aal/aal.h b/src/aal/aal.h index bf22af8..ce5e6c1 100644 --- a/src/aal/aal.h +++ b/src/aal/aal.h @@ -19,6 +19,10 @@ # define PLATFORM_IS_ARM #endif +#if defined(__powerpc__) || defined(__powerpc64__) +# define PLATFORM_IS_POWERPC +#endif + namespace snmalloc { /** @@ -47,6 +51,7 @@ namespace snmalloc enum AalName : int { ARM, + PowerPC, X86, X86_SGX, }; @@ -140,6 +145,8 @@ namespace snmalloc # include "aal_x86_sgx.h" #elif defined(PLATFORM_IS_ARM) # include "aal_arm.h" +#elif defined(PLATFORM_IS_POWERPC) +# include "aal_powerpc.h" #endif namespace snmalloc diff --git a/src/aal/aal_powerpc.h b/src/aal/aal_powerpc.h new file mode 100644 index 0000000..60b9f12 --- /dev/null +++ b/src/aal/aal_powerpc.h @@ -0,0 +1,37 @@ +#pragma once + +#if defined(__powerpc64__) +# define SNMALLOC_VA_BITS_64 +#else +# define SNMALLOC_VA_BITS_32 +#endif + +namespace snmalloc +{ + /** + * ARM-specific architecture abstraction layer. + */ + class AAL_PowerPC + { + public: + /** + * Bitmap of AalFeature flags + */ + static constexpr uint64_t aal_features = IntegerPointers; + + static constexpr enum AalName aal_name = PowerPC; + + static constexpr size_t smallest_page_size = 0x1000; + + /** + * On pipelined processors, notify the core that we are in a spin loop and + * that speculative execution past this point may not be a performance gain. + */ + static inline void pause() + { + __asm__ volatile("or 27,27,27"); // "yield" + } + }; + + using AAL_Arch = AAL_PowerPC; +} // namespace snmalloc diff --git a/src/pal/pal_linux.h b/src/pal/pal_linux.h index 3ed63a3..a645c16 100644 --- a/src/pal/pal_linux.h +++ b/src/pal/pal_linux.h @@ -25,7 +25,8 @@ namespace snmalloc */ static constexpr uint64_t pal_features = PALPOSIX::pal_features; - static constexpr size_t page_size = 0x1000; + static constexpr size_t page_size = + Aal::aal_name == PowerPC ? 0x10000 : 0x1000; /** * OS specific function for zeroing memory.