#include "privatebcb-priv.h"
#include "sharedcachemap-priv.h"
#include <glib-object.h>
+#include "captive/macros.h"
struct _CaptivePrivateBcbPinObject {
gulong FileSizes_changed_after_handler_id;
gulong purge_handler_id;
guint64 offset;
- guint32 length;
- gpointer buffer;
};
struct _CaptivePrivateBcbPinObjectClass {
CaptivePrivateBcbObjectClass parent_class;
return (*offsetp)^((*offsetp)>>32);
}
-static gint captive_private_bcb_pin_object_hash_new_key_compare_func(const guint64 *offset_ap,const guint64 *offset_bp)
+static gboolean captive_private_bcb_pin_object_hash_new_key_compare_func(const guint64 *offset_ap,const guint64 *offset_bp)
{
- return (*offset_bp>*offset_ap)-(*offset_bp<*offset_ap);
+ return (*offset_ap)==(*offset_bp);
}
GHashTable *captive_private_bcb_pin_object_hash_new(void)
CAPTIVE_PRIVATE_BCB_OBJECT(captive_private_bcb_pin_object)->SharedCacheMap));
start=captive_private_bcb_pin_object->offset;
- end =captive_private_bcb_pin_object->offset+captive_private_bcb_pin_object->length;
+ end =captive_private_bcb_pin_object->offset+PAGE_SIZE;
- g_assert(end<=CAPTIVE_PRIVATE_BCB_OBJECT(captive_private_bcb_pin_object)->SharedCacheMap->ValidDataLength);
+ g_assert(end<=CAPTIVE_ROUND_UP64(
+ CAPTIVE_PRIVATE_BCB_OBJECT(captive_private_bcb_pin_object)->SharedCacheMap->FileSize,PAGE_SIZE));
}
static void captive_private_bcb_pin_object_FileSizes_changed(CaptiveSharedCacheMapObject *captive_shared_cache_map_object,
CaptivePrivateBcbPinObject *captive_private_bcb_pin_object;
g_return_val_if_fail(CAPTIVE_SHARED_CACHE_MAP_IS_OBJECT(captive_shared_cache_map_object),NULL);
+ g_return_val_if_fail(0==CAPTIVE_ROUND_DOWN_EXCEEDING64(offset,PAGE_SIZE),NULL);
g_assert(captive_shared_cache_map_object->PinAccess);
NULL); /* first_property_name; FIXME: support properties */
captive_private_bcb_pin_object->offset=offset;
- captive_private_bcb_pin_object->length=PAGE_SIZE;
_captive_private_bcb_pin_object_connect_SharedCacheMap(captive_private_bcb_pin_object,
captive_shared_cache_map_object);
- captive_private_bcb_pin_object->buffer=captive_shared_cache_map_object->buffer+offset;
-
g_assert(captive_shared_cache_map_object->pin_hash!=NULL);
g_assert(!g_hash_table_lookup(captive_shared_cache_map_object->pin_hash,
&captive_private_bcb_pin_object->offset));
return captive_private_bcb_pin_object;
}
-CaptivePrivateBcbPinObject *captive_private_bcb_pin_object_get_ref(CaptiveSharedCacheMapObject *captive_shared_cache_map_object,
+CaptivePrivateBcbPinObject *captive_private_bcb_pin_object_get(CaptiveSharedCacheMapObject *captive_shared_cache_map_object,
guint64 offset)
{
CaptivePrivateBcbPinObject *captive_private_bcb_pin_object;
g_return_val_if_fail(CAPTIVE_SHARED_CACHE_MAP_IS_OBJECT(captive_shared_cache_map_object),NULL);
+ g_return_val_if_fail(0==CAPTIVE_ROUND_DOWN_EXCEEDING64(offset,PAGE_SIZE),NULL);
if ((captive_private_bcb_pin_object=g_hash_table_lookup(captive_shared_cache_map_object->pin_hash,
&offset))) {
g_assert(CAPTIVE_PRIVATE_BCB_PIN_IS_OBJECT(captive_private_bcb_pin_object));
+ return captive_private_bcb_pin_object;
+ }
+ return NULL;
+}
+
+CaptivePrivateBcbPinObject *captive_private_bcb_pin_object_get_ref(CaptiveSharedCacheMapObject *captive_shared_cache_map_object,
+ guint64 offset)
+{
+CaptivePrivateBcbPinObject *captive_private_bcb_pin_object;
+
+ g_return_val_if_fail(CAPTIVE_SHARED_CACHE_MAP_IS_OBJECT(captive_shared_cache_map_object),NULL);
+ g_return_val_if_fail(0==CAPTIVE_ROUND_DOWN_EXCEEDING64(offset,PAGE_SIZE),NULL);
+
+ if ((captive_private_bcb_pin_object=captive_private_bcb_pin_object_get(captive_shared_cache_map_object,offset))) {
+ g_assert(CAPTIVE_PRIVATE_BCB_PIN_IS_OBJECT(captive_private_bcb_pin_object));
g_object_ref(captive_private_bcb_pin_object);
return captive_private_bcb_pin_object;
}
/* Flush synchronously here. */
captive_shared_cache_map_flush(CAPTIVE_PRIVATE_BCB_OBJECT(captive_private_bcb_pin_object)->SharedCacheMap,
captive_private_bcb_pin_object->offset,
- captive_private_bcb_pin_object->offset+captive_private_bcb_pin_object->length);
+ captive_private_bcb_pin_object->offset+PAGE_SIZE);
}
void captive_private_bcb_pin_object_set_dirty(CaptivePrivateBcbPinObject *captive_private_bcb_pin_object)
captive_shared_cache_map_set_dirty(CAPTIVE_PRIVATE_BCB_OBJECT(captive_private_bcb_pin_object)->SharedCacheMap,
captive_private_bcb_pin_object->offset,
- captive_private_bcb_pin_object->offset+captive_private_bcb_pin_object->length);
+ captive_private_bcb_pin_object->offset+PAGE_SIZE);
}
void captive_private_bcb_pin_object_set_lsn(CaptivePrivateBcbPinObject *captive_private_bcb_pin_object,gint64 lsn)