Browse Source

Dependent base resolution needed for GCC-3.4

* include/cln/GV.h: Preceed inherited members with this->.
	* include/cln/SV.h: Likewise.
	* include/cln/object.h: Likewise.
	* src/base/hash/cl_hash1.h: Likewise.
	* src/base/hash/cl_hash1weak.h: Likewise.
	* src/base/hash/cl_hash2.h: Likewise.
	* src/base/hash/cl_hashuniq.h: Likewise.
	* src/base/hash/cl_hash.h: Make lookup of static member function
	explicit.
	* src/base/hash/cl_hash2weak.h: Likewise.
	* src/base/hash/cl_hashuniqweak.h: Likewise.
	* src/modinteger/cl_MI.cc: Make shell-comment a C-comment. Geez.
master
Richard Kreckel 22 years ago
parent
commit
34f61129e8
  1. 16
      ChangeLog
  2. 8
      include/cln/GV.h
  3. 6
      include/cln/SV.h
  4. 4
      include/cln/object.h
  5. 4
      src/base/hash/cl_hash.h
  6. 74
      src/base/hash/cl_hash1.h
  7. 6
      src/base/hash/cl_hash1weak.h
  8. 78
      src/base/hash/cl_hash2.h
  9. 6
      src/base/hash/cl_hash2weak.h
  10. 70
      src/base/hash/cl_hashuniq.h
  11. 6
      src/base/hash/cl_hashuniqweak.h
  12. 4
      src/modinteger/cl_MI.cc

16
ChangeLog

@ -1,3 +1,19 @@
2003-06-29 Richard Kreckel <kreckel@ginac.de>
Dependent base resolution needed for GCC-3.4
* include/cln/GV.h: Preceed inherited members with this->.
* include/cln/SV.h: Likewise.
* include/cln/object.h: Likewise.
* src/base/hash/cl_hash1.h: Likewise.
* src/base/hash/cl_hash1weak.h: Likewise.
* src/base/hash/cl_hash2.h: Likewise.
* src/base/hash/cl_hashuniq.h: Likewise.
* src/base/hash/cl_hash.h: Make lookup of static member function
explicit.
* src/base/hash/cl_hash2weak.h: Likewise.
* src/base/hash/cl_hashuniqweak.h: Likewise.
* src/modinteger/cl_MI.cc: Make shell-comment a C-comment. Geez.
2003-02-24 Bruno Haible <bruno@clisp.org>
* src/base/random/cl_random_from.cc (random_state::random_state): Add

8
include/cln/GV.h

@ -221,16 +221,16 @@ public:
// Length.
uintL length () const
{
return ((const cl_heap_GV<T> *) pointer)->v.length();
return ((const cl_heap_GV<T> *) this->pointer)->v.length();
}
// Reference. Forbid modification of `const cl_GV&' arguments.
const cl_GV_constindex<T> operator[] (unsigned long index) const
{
return ((const cl_heap_GV<T> *) pointer)->v[index];
return ((const cl_heap_GV<T> *) this->pointer)->v[index];
}
const cl_GV_index<T> operator[] (unsigned long index)
{
return ((cl_heap_GV<T> *) pointer)->v[index];
return ((cl_heap_GV<T> *) this->pointer)->v[index];
}
const cl_GV_constindex<T> operator[] (long index) const
{ return operator[]((unsigned long)index); }
@ -277,7 +277,7 @@ template <class T, class BASE>
template <class T, class BASE>
inline CL_GV(T,BASE)::operator cl_heap_GV<T>* () const
{
cl_heap_GV<T>* hpointer = (cl_heap_GV<T>*)pointer;
cl_heap_GV<T>* hpointer = (cl_heap_GV<T>*)this->pointer;
cl_inc_refcount(*this);
return hpointer;
}

6
include/cln/SV.h

@ -117,16 +117,16 @@ public:
// Length.
uintL length () const
{
return ((const cl_heap_SV<T> *) pointer)->v.length();
return ((const cl_heap_SV<T> *) this->pointer)->v.length();
}
// Reference. Forbid modification of `const cl_SV&' arguments.
const T & operator[] (unsigned long index) const
{
return ((const cl_heap_SV<T> *) pointer)->v[index];
return ((const cl_heap_SV<T> *) this->pointer)->v[index];
}
T & operator[] (unsigned long index)
{
return ((cl_heap_SV<T> *) pointer)->v[index];
return ((cl_heap_SV<T> *) this->pointer)->v[index];
}
// New ANSI C++ compilers also want the following.
const T & operator[] (unsigned int index) const

4
include/cln/object.h

@ -243,7 +243,7 @@ inline _class_::_classname_ (const _class_& x) \
{ \
cl_uint x_word = x.word; \
cl_inc_refcount(x); \
word = x_word; \
this->word = x_word; \
}
// The declaration of a copy constructor.
@ -263,7 +263,7 @@ inline dest_class& dest_class::operator= (const src_class& x) \
cl_uint x_word = x.word; \
cl_inc_refcount(x); \
cl_dec_refcount(*this); \
word = x_word; \
this->word = x_word; \
return *this; \
}

4
src/base/hash/cl_hash.h

@ -17,7 +17,7 @@ template <class htentry> struct _cl_hashtable_iterator;
template <class htentry>
struct cl_heap_hashtable : public cl_heap {
friend struct _cl_hashtable_iterator<htentry>;
friend struct _cl_hashtable_iterator<htentry>;
protected:
typedef struct htxentry {
long next; // > 0: pseudo-list continues at next-1
@ -43,7 +43,7 @@ public:
void operator delete (void* ptr) { free_hook(ptr); }
// Constructor: build a new, empty table.
cl_heap_hashtable (long initial_size = 5) : cl_heap (),
_size (initial_size), _count (0), _garcol_fun (no_garcol)
_size (initial_size), _count (0), _garcol_fun (cl_heap_hashtable<htentry>::no_garcol)
{
_modulus = compute_modulus(_size);
_total_vector = malloc_hook(_modulus*sizeof(long) + _size*sizeof(htxentry));

74
src/base/hash/cl_hash1.h

@ -45,13 +45,13 @@ public:
// if it is not NULL.
value_type* get (const key1_type& key)
{
var long index = _slots[hashcode(key) % _modulus] - 1;
var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
while (index >= 0) {
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key,_entries[index].entry.key))
return &_entries[index].entry.val;
index = _entries[index].next - 1;
if (equal(key,this->_entries[index].entry.key))
return &this->_entries[index].entry.val;
index = this->_entries[index].next - 1;
}
return NULL;
}
@ -61,45 +61,45 @@ public:
var unsigned long hcode = hashcode(key);
// Search whether it is already there.
{
var long index = _slots[hcode % _modulus] - 1;
var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key,_entries[index].entry.key)) {
_entries[index].entry.val = val;
if (equal(key,this->_entries[index].entry.key)) {
this->_entries[index].entry.val = val;
return;
}
index = _entries[index].next - 1;
index = this->_entries[index].next - 1;
}
}
// Put it into the table.
prepare_store();
var long hindex = hcode % _modulus; // _modulus may have changed!
var long hindex = hcode % this->_modulus; // _modulus may have changed!
var long index = get_free_index();
new (&_entries[index].entry) cl_htentry1<key1_type,value_type> (key,val);
_entries[index].next = _slots[hindex];
_slots[hindex] = 1+index;
_count++;
new (&this->_entries[index].entry) cl_htentry1<key1_type,value_type> (key,val);
this->_entries[index].next = this->_slots[hindex];
this->_slots[hindex] = 1+index;
this->_count++;
}
// Remove (htrem alias remhash).
void remove (const key1_type& key)
{
var long* _index = &_slots[hashcode(key) % _modulus];
var long* _index = &this->_slots[hashcode(key) % this->_modulus];
while (*_index > 0) {
var long index = *_index - 1;
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key,_entries[index].entry.key)) {
if (equal(key,this->_entries[index].entry.key)) {
// Remove _entries[index].entry
*_index = _entries[index].next;
_entries[index].~htxentry();
*_index = this->_entries[index].next;
this->_entries[index].~htxentry();
// The entry is now free.
put_free_index(index);
// That's it.
_count--;
this->_count--;
return;
}
_index = &_entries[index].next;
_index = &this->_entries[index].next;
}
}
// Iterate through the table.
@ -113,25 +113,25 @@ private:
void prepare_store ()
{
#if !(defined(__sparc__) && !defined(__GNUC__))
if (_freelist < -1)
if (this->_freelist < -1)
return;
// Can we make room?
if (_garcol_fun(this))
if (_freelist < -1)
if (this->_garcol_fun(this))
if (this->_freelist < -1)
return;
// No! Have to grow the hash table.
grow();
#else
// workaround Sun C++ 4.1 inline function compiler bug
if (_freelist >= -1) {
if (!_garcol_fun(this) || (_freelist >= -1))
if (this->_freelist >= -1) {
if (!this->_garcol_fun(this) || (this->_freelist >= -1))
grow();
}
#endif
}
void grow ()
{
var long new_size = _size + (_size >> 1) + 1; // _size*1.5
var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
var long new_modulus = compute_modulus(new_size);
var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
var long* new_slots = (long*) ((char*)new_total_vector + 0);
@ -143,8 +143,8 @@ private:
new_entries[i].next = free_list_head;
free_list_head = -2-i;
}
var htxentry* old_entries = _entries;
for (var long old_index = 0; old_index < _size; old_index++)
var htxentry* old_entries = this->_entries;
for (var long old_index = 0; old_index < this->_size; old_index++)
if (old_entries[old_index].next >= 0) {
var key1_type& key = old_entries[old_index].entry.key;
var value_type& val = old_entries[old_index].entry.val;
@ -156,13 +156,13 @@ private:
new_slots[hindex] = 1+index;
old_entries[old_index].~htxentry();
}
free_hook(_total_vector);
_modulus = new_modulus;
_size = new_size;
_freelist = free_list_head;
_slots = new_slots;
_entries = new_entries;
_total_vector = new_total_vector;
free_hook(this->_total_vector);
this->_modulus = new_modulus;
this->_size = new_size;
this->_freelist = free_list_head;
this->_slots = new_slots;
this->_entries = new_entries;
this->_total_vector = new_total_vector;
}
};

6
src/base/hash/cl_hash1weak.h

@ -33,7 +33,7 @@ public:
: cl_heap_hashtable_1 <key1_type,value_type> (),
_maygc_htentry (maygc_htentry)
{
_garcol_fun = garcol;
this->_garcol_fun = cl_heap_weak_hashtable_1<key1_type,value_type>::garcol;
}
private:
// Garbage collection.
@ -75,7 +75,7 @@ private:
else if (2*removed < ht->_count) {
// Table shrank by less than a factor of 1/1.5.
// Don't expand the table now, but expand it next time.
ht->_garcol_fun = garcol_nexttime;
ht->_garcol_fun = cl_heap_weak_hashtable_1<key1_type,value_type>::garcol_nexttime;
return cl_true;
} else {
// Table shrank much. Don't expand the table now,
@ -87,7 +87,7 @@ private:
{
var cl_heap_weak_hashtable_1* ht = (cl_heap_weak_hashtable_1*)_ht;
// Now ht->_garcol_fun = garcol_nexttime.
ht->_garcol_fun = garcol;
ht->_garcol_fun = cl_heap_weak_hashtable_1<key1_type,value_type>::garcol;
return cl_false;
}
};

78
src/base/hash/cl_hash2.h

@ -43,14 +43,14 @@ public:
// if it is not NULL.
value_type* get (const key1_type& key1, const key2_type& key2)
{
var long index = _slots[hashcode(key1,key2) % _modulus] - 1;
var long index = this->_slots[hashcode(key1,key2) % this->_modulus] - 1;
while (index >= 0) {
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key1,_entries[index].entry.key1)
&& equal(key2,_entries[index].entry.key2))
return &_entries[index].entry.val;
index = _entries[index].next - 1;
if (equal(key1,this->_entries[index].entry.key1)
&& equal(key2,this->_entries[index].entry.key2))
return &this->_entries[index].entry.val;
index = this->_entries[index].next - 1;
}
return NULL;
}
@ -60,47 +60,47 @@ public:
var unsigned long hcode = hashcode(key1,key2);
// Search whether it is already there.
{
var long index = _slots[hcode % _modulus] - 1;
var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key1,_entries[index].entry.key1)
&& equal(key2,_entries[index].entry.key2)) {
_entries[index].entry.val = val;
if (equal(key1,this->_entries[index].entry.key1)
&& equal(key2,this->_entries[index].entry.key2)) {
this->_entries[index].entry.val = val;
return;
}
index = _entries[index].next - 1;
index = this->_entries[index].next - 1;
}
}
// Put it into the table.
prepare_store();
var long hindex = hcode % _modulus; // _modulus may have changed!
var long hindex = hcode % this->_modulus; // _modulus may have changed!
var long index = get_free_index();
new (&_entries[index].entry) cl_htentry2<key1_type,key2_type,value_type> (key1,key2,val);
_entries[index].next = _slots[hindex];
_slots[hindex] = 1+index;
_count++;
new (&this->_entries[index].entry) cl_htentry2<key1_type,key2_type,value_type> (key1,key2,val);
this->_entries[index].next = this->_slots[hindex];
this->_slots[hindex] = 1+index;
this->_count++;
}
// Remove (htrem alias remhash).
void remove (const key1_type& key1, const key2_type& key2)
{
var long* _index = &_slots[hashcode(key1,key2) % _modulus];
var long* _index = &this->_slots[hashcode(key1,key2) % this->_modulus];
while (*_index > 0) {
var long index = *_index - 1;
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key1,_entries[index].entry.key1)
&& equal(key2,_entries[index].entry.key2)) {
if (equal(key1,this->_entries[index].entry.key1)
&& equal(key2,this->_entries[index].entry.key2)) {
// Remove _entries[index].entry
*_index = _entries[index].next;
_entries[index].~htxentry();
*_index = this->_entries[index].next;
this->_entries[index].~htxentry();
// The entry is now free.
put_free_index(index);
// That's it.
_count--;
this->_count--;
return;
}
_index = &_entries[index].next;
_index = &this->_entries[index].next;
}
}
// Iterate through the table.
@ -114,25 +114,25 @@ private:
void prepare_store ()
{
#if !(defined(__sparc__) && !defined(__GNUC__))
if (_freelist < -1)
if (this->_freelist < -1)
return;
// Can we make room?
if (_garcol_fun(this))
if (_freelist < -1)
if (this->_freelist < -1)
return;
// No! Have to grow the hash table.
grow();
#else
// workaround Sun C++ 4.1 inline function compiler bug
if (_freelist >= -1) {
if (!_garcol_fun(this) || (_freelist >= -1))
if (this->_freelist >= -1) {
if (!_garcol_fun(this) || (this->_freelist >= -1))
grow();
}
#endif
}
void grow ()
{
var long new_size = _size + (_size >> 1) + 1; // _size*1.5
var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
var long new_modulus = compute_modulus(new_size);
var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
var long* new_slots = (long*) ((char*)new_total_vector + 0);
@ -144,8 +144,8 @@ private:
new_entries[i].next = free_list_head;
free_list_head = -2-i;
}
var htxentry* old_entries = _entries;
for (var long old_index = 0; old_index < _size; old_index++)
var htxentry* old_entries = this->_entries;
for (var long old_index = 0; old_index < this->_size; old_index++)
if (old_entries[old_index].next >= 0) {
var key1_type& key1 = old_entries[old_index].entry.key1;
var key2_type& key2 = old_entries[old_index].entry.key2;
@ -158,13 +158,13 @@ private:
new_slots[hindex] = 1+index;
old_entries[old_index].~htxentry();
}
free_hook(_total_vector);
_modulus = new_modulus;
_size = new_size;
_freelist = free_list_head;
_slots = new_slots;
_entries = new_entries;
_total_vector = new_total_vector;
free_hook(this->_total_vector);
this->_modulus = new_modulus;
this->_size = new_size;
this->_freelist = free_list_head;
this->_slots = new_slots;
this->_entries = new_entries;
this->_total_vector = new_total_vector;
}
};

6
src/base/hash/cl_hash2weak.h

@ -33,7 +33,7 @@ public:
: cl_heap_hashtable_2 <key1_type,key2_type,value_type> (),
_maygc_htentry (maygc_htentry)
{
_garcol_fun = garcol;
this->_garcol_fun = cl_heap_weak_hashtable_2<key1_type,key2_type,value_type>::garcol;
}
private:
// Garbage collection.
@ -75,7 +75,7 @@ private:
else if (2*removed < ht->_count) {
// Table shrank by less than a factor of 1/1.5.
// Don't expand the table now, but expand it next time.
ht->_garcol_fun = garcol_nexttime;
ht->_garcol_fun = cl_heap_weak_hashtable_2<key1_type,key2_type,value_type>::garcol_nexttime;
return cl_true;
} else {
// Table shrank much. Don't expand the table now,
@ -87,7 +87,7 @@ private:
{
var cl_heap_weak_hashtable_2* ht = (cl_heap_weak_hashtable_2*)_ht;
// Now ht->_garcol_fun = garcol_nexttime.
ht->_garcol_fun = garcol;
ht->_garcol_fun = cl_heap_weak_hashtable_2<key1_type,key2_type,value_type>::garcol;
return cl_false;
}
};

70
src/base/hash/cl_hashuniq.h

@ -45,13 +45,13 @@ public:
// if it is not NULL.
value_type * get (const key1_type& key)
{
var long index = _slots[hashcode(key) % _modulus] - 1;
var long index = this->_slots[hashcode(key) % this->_modulus] - 1;
while (index >= 0) {
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key,hashkey(_entries[index].entry.val)))
return &_entries[index].entry.val;
index = _entries[index].next - 1;
if (equal(key,hashkey(this->_entries[index].entry.val)))
return &this->_entries[index].entry.val;
index = this->_entries[index].next - 1;
}
return NULL;
}
@ -61,43 +61,43 @@ public:
var unsigned long hcode = hashcode(key);
// Search whether it is already there.
{
var long index = _slots[hcode % _modulus] - 1;
var long index = this->_slots[hcode % this->_modulus] - 1;
while (index >= 0) {
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key,hashkey(_entries[index].entry.val)))
if (equal(key,hashkey(this->_entries[index].entry.val)))
return;
index = _entries[index].next - 1;
index = this->_entries[index].next - 1;
}
}
// Put it into the table.
prepare_store();
var long hindex = hcode % _modulus; // _modulus may have changed!
var long hindex = hcode % this->_modulus; // _modulus may have changed!
var long index = get_free_index();
new (&_entries[index].entry) cl_htuniqentry<key1_type,value_type> (value_type((struct hashuniq *)0, key));
_entries[index].next = _slots[hindex];
_slots[hindex] = 1+index;
_count++;
new (&this->_entries[index].entry) cl_htuniqentry<key1_type,value_type> (value_type((struct hashuniq *)0, key));
this->_entries[index].next = this->_slots[hindex];
this->_slots[hindex] = 1+index;
this->_count++;
}
// Remove (htrem alias remhash).
void remove (const key1_type& key)
{
var long* _index = &_slots[hashcode(key) % _modulus];
var long* _index = &this->_slots[hashcode(key) % this->_modulus];
while (*_index > 0) {
var long index = *_index - 1;
if (!(index < _size))
if (!(index < this->_size))
cl_abort();
if (equal(key,hashkey(_entries[index].entry.val))) {
if (equal(key,hashkey(this->_entries[index].entry.val))) {
// Remove _entries[index].entry
*_index = _entries[index].next;
_entries[index].~htxentry();
*_index = this->_entries[index].next;
this->_entries[index].~htxentry();
// The entry is now free.
put_free_index(index);
// That's it.
_count--;
this->_count--;
return;
}
_index = &_entries[index].next;
_index = &this->_entries[index].next;
}
}
// Iterate through the table.
@ -111,25 +111,25 @@ private:
void prepare_store ()
{
#if !(defined(__sparc__) && !defined(__GNUC__))
if (_freelist < -1)
if (this->_freelist < -1)
return;
// Can we make room?
if (_garcol_fun(this))
if (_freelist < -1)
if (this->_freelist < -1)
return;
// No! Have to grow the hash table.
grow();
#else
// workaround Sun C++ 4.1 inline function compiler bug
if (_freelist >= -1) {
if (!_garcol_fun(this) || (_freelist >= -1))
if (this->_freelist >= -1) {
if (!_garcol_fun(this) || (this->_freelist >= -1))
grow();
}
#endif
}
void grow ()
{
var long new_size = _size + (_size >> 1) + 1; // _size*1.5
var long new_size = this->_size + (this->_size >> 1) + 1; // _size*1.5
var long new_modulus = compute_modulus(new_size);
var void* new_total_vector = malloc_hook(new_modulus*sizeof(long) + new_size*sizeof(htxentry));
var long* new_slots = (long*) ((char*)new_total_vector + 0);
@ -141,8 +141,8 @@ private:
new_entries[i].next = free_list_head;
free_list_head = -2-i;
}
var htxentry* old_entries = _entries;
for (var long old_index = 0; old_index < _size; old_index++)
var htxentry* old_entries = this->_entries;
for (var long old_index = 0; old_index < this->_size; old_index++)
if (old_entries[old_index].next >= 0) {
var value_type& val = old_entries[old_index].entry.val;
var long hindex = hashcode(hashkey(val)) % new_modulus;
@ -153,13 +153,13 @@ private:
new_slots[hindex] = 1+index;
old_entries[old_index].~htxentry();
}
free_hook(_total_vector);
_modulus = new_modulus;
_size = new_size;
_freelist = free_list_head;
_slots = new_slots;
_entries = new_entries;
_total_vector = new_total_vector;
free_hook(this->_total_vector);
this->_modulus = new_modulus;
this->_size = new_size;
this->_freelist = free_list_head;
this->_slots = new_slots;
this->_entries = new_entries;
this->_total_vector = new_total_vector;
}
};

6
src/base/hash/cl_hashuniqweak.h

@ -32,7 +32,7 @@ public:
cl_heap_weak_hashtable_uniq ()
: cl_heap_hashtable_uniq <key1_type,value_type> ()
{
_garcol_fun = garcol;
this->_garcol_fun = cl_heap_weak_hashtable_uniq<key1_type,value_type>::garcol;
}
private:
// Garbage collection.
@ -75,7 +75,7 @@ private:
else if (2*removed < ht->_count) {
// Table shrank by less than a factor of 1/1.5.
// Don't expand the table now, but expand it next time.
ht->_garcol_fun = garcol_nexttime;
ht->_garcol_fun = cl_heap_weak_hashtable_uniq<key1_type,value_type>::garcol_nexttime;
return cl_true;
} else {
// Table shrank much. Don't expand the table now,
@ -87,7 +87,7 @@ private:
{
var cl_heap_weak_hashtable_uniq* ht = (cl_heap_weak_hashtable_uniq*)_ht;
// Now ht->_garcol_fun = garcol_nexttime.
ht->_garcol_fun = garcol;
ht->_garcol_fun = cl_heap_weak_hashtable_uniq<key1_type,value_type>::garcol;
return cl_false;
}
};

4
src/modinteger/cl_MI.cc

@ -21,8 +21,8 @@ CL_PROVIDE(cl_MI)
#include "cln/abort.h"
#include "cl_alloca.h"
# MacOS X does "#define _R 0x00040000L"
# Grr...
// MacOS X does "#define _R 0x00040000L"
// Grr...
#undef _R
namespace cln {

Loading…
Cancel
Save