diff mbox

[04/13] Add {mark,is}_{empty,deleted} to pointer_hash

Message ID 87y4jk11bt.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford June 16, 2015, 8:53 a.m. UTC
This patch just adds the standard pointer handling of empty and deleted
entries.  As the series goes on, more and more traits classes will inherit
these definitions, to the point where we can require the functions to exist.

gcc/
	* hash-traits.h (pointer_hash::mark_deleted, pointer_hash::mark_empty)
	(pointer_hash::is_deleted, pointer_hash::is_empty): New functions.

Comments

Jeff Law June 23, 2015, 8:56 p.m. UTC | #1
On 06/16/2015 02:53 AM, Richard Sandiford wrote:
> This patch just adds the standard pointer handling of empty and deleted
> entries.  As the series goes on, more and more traits classes will inherit
> these definitions, to the point where we can require the functions to exist.
>
> gcc/
> 	* hash-traits.h (pointer_hash::mark_deleted, pointer_hash::mark_empty)
> 	(pointer_hash::is_deleted, pointer_hash::is_empty): New functions.
OK.
jeff
diff mbox

Patch

Index: gcc/hash-traits.h
===================================================================
--- gcc/hash-traits.h	2015-06-15 16:04:53.375564430 +0100
+++ gcc/hash-traits.h	2015-06-15 16:04:53.371564477 +0100
@@ -66,9 +66,12 @@  struct pointer_hash : typed_noop_remove
   typedef Type *compare_type;
 
   static inline hashval_t hash (const value_type &);
-
   static inline bool equal (const value_type &existing,
 			    const compare_type &candidate);
+  static inline void mark_deleted (Type *&);
+  static inline void mark_empty (Type *&);
+  static inline bool is_deleted (Type *);
+  static inline bool is_empty (Type *);
 };
 
 template <typename Type>
@@ -88,6 +91,34 @@  pointer_hash <Type>::equal (const value_
   return existing == candidate;
 }
 
+template <typename Type>
+inline void
+pointer_hash <Type>::mark_deleted (Type *&e)
+{
+  e = reinterpret_cast<Type *> (1);
+}
+
+template <typename Type>
+inline void
+pointer_hash <Type>::mark_empty (Type *&e)
+{
+  e = NULL;
+}
+
+template <typename Type>
+inline bool
+pointer_hash <Type>::is_deleted (Type *e)
+{
+  return e == reinterpret_cast<Type *> (1);
+}
+
+template <typename Type>
+inline bool
+pointer_hash <Type>::is_empty (Type *e)
+{
+  return e == NULL;
+}
+
 /* Hasher for entry in gc memory.  */
 
 template<typename T>