Merge branch 'refs/heads/t/sha3' into master
[osl.git] / osl_core.h
index 1220a09eac1a9aa7cd59742828d8c7c4ca865c9d..e98c33538bfff043b2ae94145e9dee2b836f28bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2007-2009 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -38,6 +38,13 @@ struct osl_column {
 struct osl_table {
        /** Pointer to the table description */
        const struct osl_table_description *desc;
+       /**
+        * The CURRENT_TABLE_VERSION value of the library which created the
+        * table. This value is stored in the index header at table creation
+        * time. When the table is opened, the field is initialized from the
+        * on-disk value.
+        */
+       uint8_t version;
        /** The size of the index header of this table. */
        uint16_t index_header_size;
        /** Contains the mapping of the table's index file */
@@ -194,14 +201,7 @@ _static_inline_ size_t index_column_description_size(const char *name)
  * The version used by this instance of the library. Written to the index of
  * newly created tables.
  */
-#define CURRENT_TABLE_VERSION 1
-
-/*
- * The lowest library version that is able to use tables of version
- * CURRENT_TABLE_VERSION. Also written to the index of new tables. If
- * compat_version(table) > current_version(lib) the table can not be opened.
- */
-#define COMPAT_TABLE_VERSION 0
+#define CURRENT_TABLE_VERSION 3
 
 /*
  * The lowest table version this library understands. On open, if
@@ -363,8 +363,8 @@ _static_inline_ char *disk_storage_path(const struct osl_table *t,
  * \sa FOR_EACH_COLUMN_OF_TYPE, FOR_EACH_MAPPED_COLUMN, FOR_EACH_RBTREE_COLUMN,
  * FOR_EACH_DISK_STORAGE_COLUMN, FOR_EACH_VOLATILE_COLUMN, osl_storage_type.
  */
-_static_inline_ int next_column_of_type(enum osl_storage_type type, int col_num,
-               const struct osl_table *t,
+_static_inline_ unsigned next_column_of_type(enum osl_storage_type type,
+               unsigned col_num, const struct osl_table *t,
                const struct osl_column_description **cd)
 {
        *cd = NULL;
@@ -456,12 +456,14 @@ _static_inline_ struct osl_row *get_row_pointer(const struct rb_node *node,
 /**
  * Compute a cryptographic hash of an osl object.
  *
+ * \param t Determines the hash function to use.
  * \param obj the Object to compute the hash value from.
  * \param hash Result is returned here.
  */
-_static_inline_ void hash_object(const struct osl_object *obj, HASH_TYPE *hash)
+_static_inline_ void hash_object(const struct osl_table *t,
+               const struct osl_object *obj, HASH_TYPE *hash)
 {
-       hash_function(obj->data, obj->size, hash);
+       hash_function(t->version, obj->data, obj->size, hash);
 }
 
 /**