forked from Imagelibrary/binutils-gdb
This adds 'Innovative Computing Labs' as an external author to update-copyright.py, to cover the copyright notice in gprofng/common/opteron_pcbe.c, and uses that plus another external author 'Oracle and' to update gprofng copyright dates. I'm not going to commit 'Oracle and' as an accepted author, but that covers the string "Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved." found in gprofng/testsuite/gprofng.display/jsynprog files.
110 lines
2.4 KiB
C++
110 lines
2.4 KiB
C++
/* Copyright (C) 2021-2023 Free Software Foundation, Inc.
|
|
Contributed by Oracle.
|
|
|
|
This file is part of GNU Binutils.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, 51 Franklin Street - Fifth Floor, Boston,
|
|
MA 02110-1301, USA. */
|
|
|
|
/*
|
|
* Dbe Cache Map implementation.
|
|
*
|
|
* Simple Cache Map makes the following assumptions:
|
|
* - Cache Map is used for very fast but not guaranteed mapping;
|
|
* - No Relations can be used;
|
|
* - all objects used as keys or values has to be managed
|
|
* outside CacheMap (f.e. deletion);
|
|
*/
|
|
|
|
#ifndef _DbeCacheMap_h
|
|
#define _DbeCacheMap_h
|
|
|
|
#include <Map.h>
|
|
|
|
template <typename Key_t, class ITEM>
|
|
class DbeCacheMap : public Map<Key_t, ITEM *>
|
|
{
|
|
public:
|
|
|
|
DbeCacheMap (int _size = DefaultSize)
|
|
{ // _size should be 2 ** N
|
|
size = _size;
|
|
table = new DbeCache_T[size];
|
|
memset (table, 0, size * sizeof (DbeCache_T));
|
|
};
|
|
|
|
~DbeCacheMap ()
|
|
{
|
|
delete[] table;
|
|
};
|
|
|
|
void
|
|
put (Key_t key, ITEM *val)
|
|
{
|
|
int ind = get_hash (key);
|
|
table[ind].key = key;
|
|
table[ind].value = val;
|
|
};
|
|
|
|
ITEM *
|
|
get (Key_t key)
|
|
{
|
|
int ind = get_hash (key);
|
|
if (table[ind].key == key)
|
|
return table[ind].value;
|
|
return (ITEM *) NULL;
|
|
};
|
|
|
|
ITEM *
|
|
remove (Key_t key)
|
|
{
|
|
int ind = get_hash (key);
|
|
ITEM *v = table[ind].value;
|
|
table[ind].value = (ITEM *) NULL;
|
|
return v;
|
|
};
|
|
|
|
ITEM *
|
|
get (Key_t /* key */, typename Map<Key_t, ITEM *>::Relation /* rel */)
|
|
{
|
|
return (ITEM *) NULL;
|
|
};
|
|
|
|
private:
|
|
|
|
enum
|
|
{
|
|
DefaultSize = (1 << 13)
|
|
};
|
|
|
|
typedef struct DbeCache_S
|
|
{
|
|
Key_t key;
|
|
ITEM *value;
|
|
} DbeCache_T;
|
|
DbeCache_T *table;
|
|
int size;
|
|
|
|
int
|
|
get_hash (Key_t key)
|
|
{
|
|
unsigned long long h = (unsigned long long) key;
|
|
h ^= (h >> 20) ^ (h >> 12);
|
|
return (h ^ (h >> 7) ^ (h >> 4)) & (size - 1);
|
|
}
|
|
};
|
|
|
|
#endif
|