LCOV - code coverage report
Current view: top level - raid - intz.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 58 58 100.0 %
Date: 2017-11-06 22:14:04 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2013 Andrea Mazzoleni
       3             :  *
       4             :  * This program is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * This program is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  */
      14             : 
      15             : #include "internal.h"
      16             : #include "gf.h"
      17             : 
      18             : /*
      19             :  * GENz (triple parity with powers of 2^-1) 32bit C implementation
      20             :  */
      21          31 : void raid_genz_int32(int nd, size_t size, void **vv)
      22             : {
      23          31 :         uint8_t **v = (uint8_t**)vv;
      24             :         uint8_t *p;
      25             :         uint8_t *q;
      26             :         uint8_t *r;
      27             :         int d, l;
      28             :         size_t i;
      29             : 
      30             :         uint32_t d0, r0, q0, p0;
      31             :         uint32_t d1, r1, q1, p1;
      32             : 
      33          31 :         l = nd - 1;
      34          31 :         p = v[nd];
      35          31 :         q = v[nd + 1];
      36          31 :         r = v[nd + 2];
      37             : 
      38      983103 :         for (i = 0; i < size; i += 8) {
      39      983072 :                 r0 = q0 = p0 = v_32(v[l][i]);
      40      983072 :                 r1 = q1 = p1 = v_32(v[l][i + 4]);
      41     7865344 :                 for (d = l - 1; d >= 0; --d) {
      42     6882272 :                         d0 = v_32(v[d][i]);
      43     6882272 :                         d1 = v_32(v[d][i + 4]);
      44             : 
      45     6882272 :                         p0 ^= d0;
      46     6882272 :                         p1 ^= d1;
      47             : 
      48     6882272 :                         q0 = x2_32(q0);
      49     6882272 :                         q1 = x2_32(q1);
      50             : 
      51     6882272 :                         q0 ^= d0;
      52     6882272 :                         q1 ^= d1;
      53             : 
      54     6882272 :                         r0 = d2_32(r0);
      55     6882272 :                         r1 = d2_32(r1);
      56             : 
      57     6882272 :                         r0 ^= d0;
      58     6882272 :                         r1 ^= d1;
      59             :                 }
      60      983072 :                 v_32(p[i]) = p0;
      61      983072 :                 v_32(p[i + 4]) = p1;
      62      983072 :                 v_32(q[i]) = q0;
      63      983072 :                 v_32(q[i + 4]) = q1;
      64      983072 :                 v_32(r[i]) = r0;
      65      983072 :                 v_32(r[i + 4]) = r1;
      66             :         }
      67          31 : }
      68             : 
      69             : /*
      70             :  * GENz (triple parity with powers of 2^-1) 64bit C implementation
      71             :  */
      72          59 : void raid_genz_int64(int nd, size_t size, void **vv)
      73             : {
      74          59 :         uint8_t **v = (uint8_t**)vv;
      75             :         uint8_t *p;
      76             :         uint8_t *q;
      77             :         uint8_t *r;
      78             :         int d, l;
      79             :         size_t i;
      80             : 
      81             :         uint64_t d0, r0, q0, p0;
      82             :         uint64_t d1, r1, q1, p1;
      83             : 
      84          59 :         l = nd - 1;
      85          59 :         p = v[nd];
      86          59 :         q = v[nd + 1];
      87          59 :         r = v[nd + 2];
      88             : 
      89      950347 :         for (i = 0; i < size; i += 16) {
      90      950288 :                 r0 = q0 = p0 = v_64(v[l][i]);
      91      950288 :                 r1 = q1 = p1 = v_64(v[l][i + 8]);
      92     7602688 :                 for (d = l - 1; d >= 0; --d) {
      93     6652400 :                         d0 = v_64(v[d][i]);
      94     6652400 :                         d1 = v_64(v[d][i + 8]);
      95             : 
      96     6652400 :                         p0 ^= d0;
      97     6652400 :                         p1 ^= d1;
      98             : 
      99     6652400 :                         q0 = x2_64(q0);
     100     6652400 :                         q1 = x2_64(q1);
     101             : 
     102     6652400 :                         q0 ^= d0;
     103     6652400 :                         q1 ^= d1;
     104             : 
     105     6652400 :                         r0 = d2_64(r0);
     106     6652400 :                         r1 = d2_64(r1);
     107             : 
     108     6652400 :                         r0 ^= d0;
     109     6652400 :                         r1 ^= d1;
     110             :                 }
     111      950288 :                 v_64(p[i]) = p0;
     112      950288 :                 v_64(p[i + 8]) = p1;
     113      950288 :                 v_64(q[i]) = q0;
     114      950288 :                 v_64(q[i + 8]) = q1;
     115      950288 :                 v_64(r[i]) = r0;
     116      950288 :                 v_64(r[i + 8]) = r1;
     117             :         }
     118          59 : }
     119             : 

Generated by: LCOV version 1.13