*.c: Check for ARM64 SIMD before using the accelerated code.
[catacomb] / symm / chacha.c
index 2dcb125..f70ee9f 100644 (file)
@@ -78,6 +78,10 @@ extern core__functype chacha_core_x86ish_sse2;
 extern core__functype chacha_core_arm_neon;
 #endif
 
+#if CPUFAM_ARM64
+extern core__functype chacha_core_arm64;
+#endif
+
 static core__functype *pick_core(void)
 {
 #if CPUFAM_X86 || CPUFAM_AMD64
@@ -88,6 +92,10 @@ static core__functype *pick_core(void)
   DISPATCH_PICK_COND(chacha_core, chacha_core_arm_neon,
                     cpu_feature_p(CPUFEAT_ARM_NEON));
 #endif
+#if CPUFAM_ARM64
+  DISPATCH_PICK_COND(chacha_core, chacha_core_arm64,
+                    cpu_feature_p(CPUFEAT_ARM_NEON));
+#endif
   DISPATCH_PICK_FALLBACK(chacha_core, simple_core);
 }
 
@@ -583,7 +591,7 @@ CHACHA_VARS(DEFGCIPHER)
                                                                        \
   const gccipher xchacha##r = {                                                \
     "xchacha" #r, chacha_keysz,                                                \
-    CHACHA_NONCESZ, gxinit_##r                                         \
+    XCHACHA_NONCESZ, gxinit_##r                                                \
   };
 
 CHACHA_VARS(DEFGXCIPHER)