summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTushar Gohad <tushar.gohad@intel.com>2014-06-22 08:52:51 -0700
committerTushar Gohad <tushar.gohad@intel.com>2014-06-22 21:18:17 -0700
commit303071cf3b800d8f46615c2b62ed6f9683c4e0bd (patch)
tree0407e447dda0364e4b3c9f97df4b36ba0a3259d0
parent48c70fbab431fd79a80f5d48f4205efc6147c5d2 (diff)
downloadpyeclib-303071cf3b800d8f46615c2b62ed6f9683c4e0bd.tar.gz
pyeclib_c: Sync enum defns with ec_iface.py
Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
-rw-r--r--src/c/pyeclib_c/pyeclib_c.c18
-rw-r--r--src/c/pyeclib_c/pyeclib_c.h61
2 files changed, 58 insertions, 21 deletions
diff --git a/src/c/pyeclib_c/pyeclib_c.c b/src/c/pyeclib_c/pyeclib_c.c
index cda98c5..64a0de7 100644
--- a/src/c/pyeclib_c/pyeclib_c.c
+++ b/src/c/pyeclib_c/pyeclib_c.c
@@ -1,4 +1,6 @@
-/* * Copyright (c) 2013, Kevin Greenan (kmgreen2@gmail.com)
+/*
+ * Copyright (c) 2013-2014, Kevin Greenan (kmgreen2@gmail.com)
+ * Copyright (c) 2014, Tushar Gohad (tusharsg@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -165,20 +167,6 @@ static unsigned long convert_list_to_bitmap(int *list)
return bm;
}
-/*
- * Convert the string ECC type to the enum value
- */
-static pyeclib_type_t get_ecc_type(const char *str_type)
-{
- int i;
- for (i=0; i < PYECC_NUM_TYPES; i++) {
- if (strcmp(str_type, pyeclib_type_str[i]) == 0) {
- return i;
- }
- }
- return PYECC_NOT_FOUND;
-}
-
static
void init_fragment_header(char *buf)
{
diff --git a/src/c/pyeclib_c/pyeclib_c.h b/src/c/pyeclib_c/pyeclib_c.h
index 56ee1e3..962a026 100644
--- a/src/c/pyeclib_c/pyeclib_c.h
+++ b/src/c/pyeclib_c/pyeclib_c.h
@@ -1,4 +1,6 @@
-/* * Copyright (c) 2013, Kevin Greenan (kmgreen2@gmail.com)
+/*
+ * Copyright (c) 2013-2014, Kevin Greenan (kmgreen2@gmail.com)
+ * Copyright (c) 2014, Tushar Gohad (tusharsg@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,14 +27,61 @@
#ifndef __PYEC_LIB_C_H_
#define __PYEC_LIB_C_H_
-typedef enum { PYECC_RS_VAND, PYECC_RS_CAUCHY_ORIG, PYECC_XOR_HD_4, PYECC_XOR_HD_3, PYECC_NUM_TYPES, PYECC_NOT_FOUND } pyeclib_type_t;
+/*
+ * Make sure these enum values match those exposed from the Python EC interface
+ * src/python/pyeclib/ec_iface.py
+ */
+typedef enum {
+ PYECC_NOT_FOUND = 0,
+ PYECC_RS_VAND = 1,
+ PYECC_RS_CAUCHY_ORIG = 2,
+ PYECC_XOR_HD_3 = 3,
+ PYECC_XOR_HD_4 = 4,
+ PYECC_NUM_TYPES = 4,
+} pyeclib_type_t;
+
+const char *pyeclib_type_str[] = {
+ "not_found",
+ "rs_vand",
+ "rs_cauchy_orig",
+ "flat_xor_3",
+ "flat_xor_4",
+};
+
+/*
+ * Convert the string ECC type to the enum value
+ * Start lookup at index 1
+ */
+static inline
+pyeclib_type_t get_ecc_type(const char *str_type)
+{
+ int i;
+ for (i = 1; i <= PYECC_NUM_TYPES; i++) {
+ if (strcmp(str_type, pyeclib_type_str[i]) == 0) {
+ return i;
+ }
+ }
+ return PYECC_NOT_FOUND;
+}
-const char *pyeclib_type_str[] = { "rs_vand", "rs_cauchy_orig", "flat_xor_4", "flat_xor_3" };
-const int pyeclib_type_word_size_bytes[] = { sizeof(long), sizeof(long), sizeof(long), sizeof(long) };
+const int pyeclib_type_word_size_bytes[] = {
+ 0,
+ sizeof(long), /* rs_vand */
+ sizeof(long), /* rs_cauchy_orig */
+ sizeof(long), /* flat_xor_3 */
+ sizeof(long) /* flat_xor_4 */
+};
-// Unconditionally enforce alignment for now... This is needed for the SIMD extentions.
+// Unconditionally enforce alignment for now.
+// This is needed for the SIMD extentions.
// TODO (kmg): Parse cpuinfo and determine if it is necessary...
-const int pyeclib_type_needs_addr_align[] = { 1, 1, 1, 1 };
+const int pyeclib_type_needs_addr_align[] = {
+ -1,
+ 1,
+ 1,
+ 1,
+ 1
+};
#define PYECC_FLAGS_MASK 0x1
#define PYECC_FLAGS_READ_VERIFY 0x1