X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=osl_core.h;h=91489c95a3aa3b606652568c02ece75bc5158ffa;hb=6811bf3ef3f157e82c189f22e0b5cedd8a8ba1db;hp=3359aa782a2e2cc8232dc12b6fa339885b5f4e11;hpb=2dba3a38dcfe721842404f01e9b2adb59c302604;p=osl.git diff --git a/osl_core.h b/osl_core.h index 3359aa7..91489c9 100644 --- a/osl_core.h +++ b/osl_core.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 Andre Noll + * Copyright (C) 2007-2009 Andre Noll * * 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 */ @@ -190,9 +197,20 @@ _static_inline_ size_t index_column_description_size(const char *name) return MIN_IDX_COLUMN_DESCRIPTION_SIZE + strlen(name) - 1; } +/* + * The version used by this instance of the library. Written to the index of + * newly created tables. + */ #define CURRENT_TABLE_VERSION 1 + +/* + * The lowest table version this library understands. On open, if + * current_version(table) < min_version(lib) the osl_open_table() call + * fails. + */ #define MIN_TABLE_VERSION 1 -#define MAX_TABLE_VERSION 1 + + /** An index header must be at least that many bytes long. */ #define MIN_INDEX_HEADER_SIZE(num_cols) (MIN_IDX_COLUMN_DESCRIPTION_SIZE \ * num_cols + IDX_COLUMN_DESCRIPTIONS) @@ -438,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); } /**