Browse Source

Add _starpu_crc32_be_n

Samuel Thibault 13 years ago
parent
commit
86ee68889e
2 changed files with 21 additions and 2 deletions
  1. 14 1
      src/common/hash.c
  2. 7 1
      src/common/hash.h

+ 14 - 1
src/common/hash.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009-2011  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -33,6 +33,19 @@ static inline uint32_t __attribute__ ((pure)) _starpu_crc32_be_8(uint8_t inputby
 	return crc;
 }
 
+uint32_t _starpu_crc32_be_n(void *input, size_t n, uint32_t inputcrc)
+{
+	uint8_t *p = (uint8_t *)input;
+	size_t i;
+
+	uint32_t crc = inputcrc;
+
+	for (i = 0; i < n; i++)
+		crc = _starpu_crc32_be_8(p[i], crc);
+
+	return crc;
+}
+
 uint32_t _starpu_crc32_be(uint32_t input, uint32_t inputcrc)
 {
 	uint8_t *p = (uint8_t *)&input;

+ 7 - 1
src/common/hash.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -19,6 +19,12 @@
 #define __HASH_H__
 
 #include <stdint.h>
+#include <stddef.h>
+
+/* Compute the CRC of a byte buffer seeded by the inputcrc "current state".
+ * The return value should be considered as the new "current state" for future
+ * CRC computation. */
+uint32_t _starpu_crc32_be_n(void *input, size_t n, uint32_t inputcrc);
 
 /* Compute the CRC of a 32bit number seeded by the inputcrc "current state".
  * The return value should be considered as the new "current state" for future