Bug 1566126 - clang-format, a=bustage
authorMartin Thomson <mt@lowentropy.net>
Wed, 06 Nov 2019 20:55:41 +1100
changeset 15376 6125200fbc889fbb68447ff3fae644441842c55e
parent 15375 3d7e509d6d20ecd607a28fa6ce42e4ffd9c51443
child 15377 b39c8eeabe6a7b51cafbff1b1730ceec5aefbbc2
push id3569
push usermartin.thomson@gmail.com
push dateWed, 06 Nov 2019 10:24:00 +0000
reviewersbustage
bugs1566126
Bug 1566126 - clang-format, a=bustage
lib/freebl/blinit.c
lib/freebl/gcm-ppc.c
--- a/lib/freebl/blinit.c
+++ b/lib/freebl/blinit.c
@@ -356,17 +356,17 @@ ppc_crypto_support()
 }
 
 #if defined(__powerpc__)
 
 #include <sys/auxv.h>
 
 // Defines from cputable.h in Linux kernel - PPC, letting us build on older kernels
 #ifndef PPC_FEATURE2_VEC_CRYPTO
-#define PPC_FEATURE2_VEC_CRYPTO         0x02000000
+#define PPC_FEATURE2_VEC_CRYPTO 0x02000000
 #endif
 
 static void
 CheckPPCSupport()
 {
     char *disable_hw_crypto = PR_GetEnvSecure("NSS_DISABLE_PPC_GHASH");
 
     long hwcaps = getauxval(AT_HWCAP2);
--- a/lib/freebl/gcm-ppc.c
+++ b/lib/freebl/gcm-ppc.c
@@ -8,99 +8,102 @@
 #include "gcm.h"
 #include "secerr.h"
 
 #if defined(USE_PPC_CRYPTO)
 
 SECStatus
 gcm_HashWrite_hw(gcmHashContext *ghash, unsigned char *outbuf)
 {
-    vec_xst_be((vec_u8) ghash->x, 0, outbuf);
+    vec_xst_be((vec_u8)ghash->x, 0, outbuf);
     return SECSuccess;
 }
 
-static vec_u64 vpmsumd(const vec_u64 a, const vec_u64 b)
+static vec_u64
+vpmsumd(const vec_u64 a, const vec_u64 b)
 {
 #if defined(__clang__)
     /* Clang uses a different name */
     return __builtin_altivec_crypto_vpmsumd(a, b);
 #elif (__GNUC__ >= 10) || (__GNUC__ == 9 && __GNUC_MINOR__ >= 3) || \
-      (__GNUC__ == 8 && __GNUC_MINOR__ >= 4) || \
-      (__GNUC__ == 7 && __GNUC_MINOR__ >= 5)
-   /* GCC versions not affected by https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91275 */
-   return __builtin_crypto_vpmsumd(a, b);
+    (__GNUC__ == 8 && __GNUC_MINOR__ >= 4) ||                       \
+    (__GNUC__ == 7 && __GNUC_MINOR__ >= 5)
+    /* GCC versions not affected by https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91275 */
+    return __builtin_crypto_vpmsumd(a, b);
 #else
-   /* GCC versions where this builtin is buggy */
-   vec_u64 vr;
-   __asm("vpmsumd %0, %1, %2" : "=v"(vr) : "v"(a), "v"(b));
-   return vr;
+    /* GCC versions where this builtin is buggy */
+    vec_u64 vr;
+    __asm("vpmsumd %0, %1, %2"
+          : "=v"(vr)
+          : "v"(a), "v"(b));
+    return vr;
 #endif
 }
 
 SECStatus
 gcm_HashMult_hw(gcmHashContext *ghash, const unsigned char *buf,
                 unsigned int count)
 {
     const vec_u8 leftshift = vec_splat_u8(1);
-    const vec_u64 onebit = (vec_u64) {1, 0};
+    const vec_u64 onebit = (vec_u64){ 1, 0 };
     const unsigned long long pd = 0xc2LLU << 56;
 
     vec_u64 ci, v, r0, r1;
     vec_u64 hibit;
     unsigned i;
 
     ci = ghash->x;
 
     for (i = 0; i < count; i++, buf += 16) {
         /* clang needs the following cast away from const; maybe a bug in 7.0.0 */
-        v = (vec_u64) vec_xl_be(0, (unsigned char *) buf);
+        v = (vec_u64)vec_xl_be(0, (unsigned char *)buf);
         ci ^= v;
 
         /* Do binary mult ghash->X = C * ghash->H (Karatsuba). */
-        r0 = vpmsumd((vec_u64) {ci[0], 0}, (vec_u64) {ghash->h[0], 0});
-        r1 = vpmsumd((vec_u64) {ci[1], 0}, (vec_u64) {ghash->h[1], 0});
-        v = (vec_u64) {ci[0] ^ ci[1], ghash->h[0] ^ ghash->h[1]};
-        v = vpmsumd((vec_u64) {v[0], 0}, (vec_u64) {v[1], 0});
+        r0 = vpmsumd((vec_u64){ ci[0], 0 }, (vec_u64){ ghash->h[0], 0 });
+        r1 = vpmsumd((vec_u64){ ci[1], 0 }, (vec_u64){ ghash->h[1], 0 });
+        v = (vec_u64){ ci[0] ^ ci[1], ghash->h[0] ^ ghash->h[1] };
+        v = vpmsumd((vec_u64){ v[0], 0 }, (vec_u64){ v[1], 0 });
         v ^= r0;
         v ^= r1;
-        r0 ^= (vec_u64) {0, v[0]};
-        r1 ^= (vec_u64) {v[1], 0};
+        r0 ^= (vec_u64){ 0, v[0] };
+        r1 ^= (vec_u64){ v[1], 0 };
 
         /* Shift one (multiply by x) as gcm spec is stupid. */
-        hibit = (vec_u64) vec_splat((vec_u8) r0, 15);
-        hibit = (vec_u64) vec_rl((vec_u8) hibit, leftshift);
+        hibit = (vec_u64)vec_splat((vec_u8)r0, 15);
+        hibit = (vec_u64)vec_rl((vec_u8)hibit, leftshift);
         hibit &= onebit;
         r0 = vec_sll(r0, leftshift);
         r1 = vec_sll(r1, leftshift);
         r1 |= hibit;
 
         /* Reduce */
-        v = vpmsumd((vec_u64) {r0[0], 0}, (vec_u64) {pd, 0});
-        r0 ^= (vec_u64) {0, v[0]};
-        r1 ^= (vec_u64) {v[1], 0};
-        v = vpmsumd((vec_u64) {r0[1], 0}, (vec_u64) {pd, 0});
+        v = vpmsumd((vec_u64){ r0[0], 0 }, (vec_u64){ pd, 0 });
+        r0 ^= (vec_u64){ 0, v[0] };
+        r1 ^= (vec_u64){ v[1], 0 };
+        v = vpmsumd((vec_u64){ r0[1], 0 }, (vec_u64){ pd, 0 });
         r1 ^= v;
         ci = r0 ^ r1;
     }
 
     ghash->x = ci;
 
     return SECSuccess;
 }
 
 SECStatus
 gcm_HashInit_hw(gcmHashContext *ghash)
 {
-    ghash->x = (vec_u64) vec_splat_u32(0);
-    ghash->h = (vec_u64) {ghash->h_low, ghash->h_high};
+    ghash->x = (vec_u64)vec_splat_u32(0);
+    ghash->h = (vec_u64){ ghash->h_low, ghash->h_high };
     ghash->ghash_mul = gcm_HashMult_hw;
     ghash->hw = PR_TRUE;
     return SECSuccess;
 }
 
 SECStatus
 gcm_HashZeroX_hw(gcmHashContext *ghash)
 {
-    ghash->x = (vec_u64) vec_splat_u32(0);
+    ghash->x = (vec_u64)vec_splat_u32(0);
     return SECSuccess;
 }
 
 #endif /* defined(USE_PPC_CRYPTO) */