summaryrefslogtreecommitdiff
path: root/neozip/arch/power/power_features.c
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
commit7fb132859fda54aa96bc9dd46d302b343eeb5a02 (patch)
treeb43ae77d7451fb470a260c03349a1caf2846c5e5 /neozip/arch/power/power_features.c
parentb1e34e861b5d732afe828d58aad2c638135061fd (diff)
parentc2712b8a345191f6ed79558c089777df94590087 (diff)
downloadProject-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.tar.gz
Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.zip
Add 'neozip/' from commit 'c2712b8a345191f6ed79558c089777df94590087'
git-subtree-dir: neozip git-subtree-mainline: b1e34e861b5d732afe828d58aad2c638135061fd git-subtree-split: c2712b8a345191f6ed79558c089777df94590087
Diffstat (limited to 'neozip/arch/power/power_features.c')
-rw-r--r--neozip/arch/power/power_features.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/neozip/arch/power/power_features.c b/neozip/arch/power/power_features.c
new file mode 100644
index 0000000000..148f30a974
--- /dev/null
+++ b/neozip/arch/power/power_features.c
@@ -0,0 +1,54 @@
+/* power_features.c - POWER feature check
+ * Copyright (C) 2020 Matheus Castanho <msc@linux.ibm.com>, IBM
+ * Copyright (C) 2021-2024 Mika T. Lindqvist <postmaster@raasu.org>
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#if defined(PPC_FEATURES) || defined(POWER_FEATURES)
+
+#include "zbuild.h"
+#include "power_features.h"
+
+#ifdef HAVE_SYS_AUXV_H
+# include <sys/auxv.h>
+#endif
+#ifdef POWER_NEED_AUXVEC_H
+# include <linux/auxvec.h>
+#endif
+#ifdef __FreeBSD__
+# include <machine/cpu.h>
+#endif
+
+void Z_INTERNAL power_check_features(struct power_cpu_features *features) {
+#ifdef PPC_FEATURES
+ unsigned long hwcap;
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+#else
+ hwcap = getauxval(AT_HWCAP);
+#endif
+
+ if (hwcap & PPC_FEATURE_HAS_ALTIVEC)
+ features->has_altivec = 1;
+#endif
+
+#ifdef POWER_FEATURES
+ unsigned long hwcap2;
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+ elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
+#else
+ hwcap2 = getauxval(AT_HWCAP2);
+#endif
+
+#ifdef POWER8_VSX
+ if (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+ features->has_arch_2_07 = 1;
+#endif
+#ifdef POWER9
+ if (hwcap2 & PPC_FEATURE2_ARCH_3_00)
+ features->has_arch_3_00 = 1;
+#endif
+#endif
+}
+
+#endif