예제 #1
0
UINT32 galois_region_add(BYTE *des,BYTE *sou,UINT32 nbytes)
{
	//char res;
	//char r1,r2,target;
	//r1=x;
	//r2=y;
	galois_region_xor(des,sou,des,nbytes);
	//res=target;
	return TRUE;
}
/*
  Multiplies matrix_row by multiple stripes of vector data.
  matrix_row is of length row_len, as is data_ptrs.
  Each data_ptr points to data_size bytes: all the stripes of particular vector-component.
  Puts result in dst.
*/
void row_data_product(int* matrix_row, char** data_ptrs, char* dst, int row_len, int data_size, int w)
{
  //int size = num_stripes * (w/8);
  int size = data_size;
  int k = row_len;

  int init;
  char *dptr, *sptr;
  int i;

  if (w != 1 && w != 8 && w != 16 && w != 32) {
    fprintf(stderr, "ERROR: w is not 1, 8, 16 or 32\n");
    exit(1);
  }

  init = 0;

  dptr = dst;

  /* First copy or xor any data that does not need to be multiplied by a factor */

  for (i = 0; i < k; i++) {
    if (matrix_row[i] == 1) {

      sptr = data_ptrs[i];

      if (init == 0) {
        memcpy(dptr, sptr, size);
        //jerasure_total_memcpy_bytes += size;
        init = 1;
      } else {
        galois_region_xor(sptr, dptr, size);
        //jerasure_total_xor_bytes += size;
      }
    }
  }

  /* Now do the data that needs to be multiplied by a factor */

  for (i = 0; i < k; i++) {
    if (matrix_row[i] != 0 && matrix_row[i] != 1) {

      sptr = data_ptrs[i];

      switch (w) {
        case 8:  galois_w08_region_multiply(sptr, matrix_row[i], size, dptr, init); break;
        case 16: galois_w16_region_multiply(sptr, matrix_row[i], size, dptr, init); break;
        case 32: galois_w32_region_multiply(sptr, matrix_row[i], size, dptr, init); break;
      }
      //jerasure_total_gf_bytes += size;
      init = 1;
    }
  }
}
예제 #3
0
/*
* Class:     eu_vandertil_jerasure_jni_Galois
* Method:    galois_region_xor
* Signature: ([B[B[BI)V
*/
JNIEXPORT void JNICALL Java_eu_vandertil_jerasure_jni_Galois_galois_1region_1xor
	(JNIEnv *env, jclass clazz, jbyteArray jr1, jbyteArray jr2, jbyteArray jr3, jint nbytes)
{
	jbyte* r1 = env->GetByteArrayElements(jr1, NULL);
	jbyte* r2 = env->GetByteArrayElements(jr2, NULL);
	jbyte* r3 = env->GetByteArrayElements(jr3, NULL);

	if(!(r1 == NULL || r2 == NULL || r3 == NULL)) {
		galois_region_xor((char*)r1, (char*)r2, (char*)r3, nbytes);
	}

	env->ReleaseByteArrayElements(jr1, r1, NULL);
	env->ReleaseByteArrayElements(jr2, r2, NULL);
	env->ReleaseByteArrayElements(jr3, r3, NULL);
}