Skip to content

Commit 66df264

Browse files
authored
Let LHD_insert return dummy (not NULL) cache obj ptr (#287)
* Let LHD_insert return dummy (not NULL) cache obj ptr * Apply chatbot suggestion * Code format
1 parent 06bddc5 commit 66df264

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

libCacheSim/cache/eviction/LHD/LHD_Interface.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ using namespace repl;
1212
extern "C" {
1313
#endif
1414

15+
// NOTE: Since LHD uses internal data struct to reprensent cache_obj_t, to suit
16+
// the interface, we use a dummy pointer to represent the cache_obj_t.
17+
// Specifically, for find and insert, we return a dummy pointer when the object
18+
// is found or inserted and NULL when the object is not found.
19+
static cache_obj_t *const DUMMY_CACHE_OBJ_PTR =
20+
reinterpret_cast<cache_obj_t *>(1);
21+
1522
typedef struct {
1623
void *LHD_cache;
1724

@@ -176,7 +183,7 @@ static cache_obj_t *LHD_find(cache_t *cache, const request_t *req,
176183
lhd->update(id, req);
177184
}
178185

179-
return reinterpret_cast<cache_obj_t *>(0x1);
186+
return DUMMY_CACHE_OBJ_PTR;
180187
}
181188

182189
/**
@@ -205,7 +212,7 @@ static cache_obj_t *LHD_insert(cache_t *cache, const request_t *req) {
205212
cache->occupied_byte += req->obj_size + cache->obj_md_size;
206213
cache->n_obj += 1;
207214

208-
return NULL;
215+
return DUMMY_CACHE_OBJ_PTR;
209216
}
210217

211218
/**

0 commit comments

Comments
 (0)